re PR fortran/34495 (accepts invalid initialization expressions withTRANSFER)

2007-12-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34495
        * intrinsic.c (add_functions): Mark float and sngl as STD_GNU.
        (gfc_intrinsic_func_interface): Reject REAL, DBLE and CMPLX
        in initialization expressions for -std=f95.

2007-12-16  Tobias Burnus  <burnus@net-b.de>

        PR fortran/34495
        * gfortran.dg/initialization_16.f90: New.

From-SVN: r130994
This commit is contained in:
Tobias Burnus 2007-12-16 23:12:55 +01:00 committed by Tobias Burnus
parent df80a455ed
commit b7970354e8
4 changed files with 37 additions and 2 deletions

View file

@ -1,3 +1,10 @@
2007-12-16 Tobias Burnus <burnus@net-b.de>
PR fortran/34495
* intrinsic.c (add_functions): Mark float and sngl as STD_GNU.
(gfc_intrinsic_func_interface): Reject REAL, DBLE and CMPLX
in initialization expressions for -std=f95.
2007-12-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34305

View file

@ -2047,11 +2047,11 @@ add_functions (void)
gfc_check_fn_c, gfc_simplify_realpart, gfc_resolve_realpart,
a, BT_UNKNOWN, dr, REQUIRED);
add_sym_1 ("float", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
add_sym_1 ("float", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
gfc_check_i, gfc_simplify_float, NULL,
a, BT_INTEGER, di, REQUIRED);
add_sym_1 ("sngl", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_F77,
add_sym_1 ("sngl", GFC_ISYM_REAL, CLASS_ELEMENTAL, ACTUAL_NO, BT_REAL, dr, GFC_STD_GNU,
NULL, gfc_simplify_sngl, NULL,
a, BT_REAL, dd, REQUIRED);
@ -3388,6 +3388,14 @@ gfc_intrinsic_func_interface (gfc_expr *expr, int error_flag)
if (check_intrinsic_standard (name, isym->standard, &expr->where) == FAILURE)
return MATCH_ERROR;
if ((isym->id == GFC_ISYM_REAL || isym->id == GFC_ISYM_DBLE
|| isym->id == GFC_ISYM_CMPLX)
&& gfc_init_expr
&& gfc_notify_std (GFC_STD_F2003, "Fortran 2003: Function '%s' "
"as initialization expression at %L", name,
&expr->where) == FAILURE)
return MATCH_ERROR;
gfc_current_intrinsic_where = &expr->where;
/* Bypass the generic list for min and max. */

View file

@ -1,3 +1,8 @@
2007-12-16 Tobias Burnus <burnus@net-b.de>
PR fortran/34495
* gfortran.dg/initialization_16.f90: New.
2007-12-16 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/34305

View file

@ -0,0 +1,15 @@
! { dg-do compile }
! { dg-options "-std=f95 -Wall" }
!
! PR fortran/34495
!
! Check for invalid Fortran 95 initialization expressions
!
program main
implicit none
real, parameter :: r1 = real(33) ! { dg-error "Fortran 2003: Function 'real' as initialization expression" }
real, parameter :: r2 = dble(33) ! { dg-error "Fortran 2003: Function 'dble' as initialization expression" }
real, parameter :: r4 = cmplx(33,33)! { dg-error "Fortran 2003: Function 'cmplx' as initialization expression" }
print *, sngl(1.0d0) ! { dg-error "not included in the selected standard" }
print *, float(1.0) ! { dg-error "not included in the selected standard" }
end program main