This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[gfortran,commited] Named constants as part of complex named constant
- From: "François-Xavier Coudert" <fxcoudert at gmail dot com>
- To: "Fortran List" <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 2 Oct 2006 11:24:52 +0200
- Subject: [gfortran,commited] Named constants as part of complex named constant
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type:content-transfer-encoding:content-disposition; b=L5CR0MTVZ2NjW9AroSaZgA5nDUBXRqpXuDBgJkdXY8pYfPFxkmnnM5VyqOLltfk4odV47HacOa8qHjQsB2/Gwg+dmoLWl+pg7Bj6KRC3weK9Ih55VQnYzhqStK9acsW6LCnyt55hQlD7uWZZkQzzVv7MvVs0nLk1FB68y25/1FE=
Commited after bootstrap and regtesting on i686-linux. This patch
checks that, in strict F95 mode, named constants aren't used as part
of a complex parameter value.
FX
PR fortran/29210
* primary.c (match_sym_complex_part): Named constants as real or
imaginary part of complex a named constant are only allowed in
Fortran 2003.
* gfortran.dg/complex_parameter_1.f90: New test.
Index: gcc/fortran/primary.c
===================================================================
--- gcc/fortran/primary.c (revision 116798)
+++ gcc/fortran/primary.c (working copy)
@@ -1084,6 +1084,10 @@
return MATCH_ERROR;
}
+ if (gfc_notify_std (GFC_STD_F2003, "Fortran 2003: PARAMETER symbol in "
+ "complex constant at %C") == FAILURE)
+ return MATCH_ERROR;
+
switch (sym->value->ts.type)
{
case BT_REAL:
Index: gcc/testsuite/gfortran.dg/complex_parameter_1.f90
===================================================================
--- gcc/testsuite/gfortran.dg/complex_parameter_1.f90 (revision 0)
+++ gcc/testsuite/gfortran.dg/complex_parameter_1.f90 (revision 0)
@@ -0,0 +1,10 @@
+! { dg-do compile }
+! { dg-options "-std=f95" }
+ integer,parameter :: i = 42
+ real,parameter :: x = 17.
+ complex,parameter :: z = (1.,2.)
+ complex,parameter :: c1 = (i, 0.5) ! { dg-error "Fortran 2003:
PARAMETER symbol in complex constant" }
+ complex,parameter :: c2 = (x, 0.5) ! { dg-error "Fortran 2003:
PARAMETER symbol in complex constant" }
+ complex,parameter :: c3 = (z, 0.) ! { dg-error "Fortran 2003:
PARAMETER symbol in complex constant" }
+ print *, c1, c2, c3