This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Fortran, PR20897] Disallow intrinsic type names as derived type names
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Fortran List <fortran at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 22 Mar 2007 16:19:48 +0100
- Subject: [Fortran, PR20897] Disallow intrinsic type names as derived type names
Hi,
this is a very simple fix for this old bug. The patch is self-explaining.
Built and tested on i386-darwin. Ok?
- Tobi
2007-03-22 Tobias Schlüter <tobi@gcc.gnu.org>
PR fortran/20897
fortran/
* decl.c (gfc_match_derived_decl): Reliably reject
'doubleprecision' and 'doublecomplex' as type names.
testsuite/
* gfortran.dg/derived_name_1.f90: New.
* gfortran.dg/derived_name_2.f: New.
Index: fortran/decl.c
===================================================================
--- fortran/decl.c (revision 123109)
+++ fortran/decl.c (working copy)
@@ -4341,12 +4341,16 @@ loop:
return m;
/* Make sure the name isn't the name of an intrinsic type. The
- 'double precision' type doesn't get past the name matcher. */
+ 'double {precision,complex}' types don't get past the name
+ matcher, unless they're written as a single word or in fixed
+ form. */
if (strcmp (name, "integer") == 0
|| strcmp (name, "real") == 0
|| strcmp (name, "character") == 0
|| strcmp (name, "logical") == 0
- || strcmp (name, "complex") == 0)
+ || strcmp (name, "complex") == 0
+ || strcmp (name, "doubleprecision") == 0
+ || strcmp (name, "doublecomplex") == 0)
{
gfc_error ("Type name '%s' at %C cannot be the same as an intrinsic "
"type", name);
Index: testsuite/gfortran.dg/derived_name_1.f90
===================================================================
--- testsuite/gfortran.dg/derived_name_1.f90 (revision 0)
+++ testsuite/gfortran.dg/derived_name_1.f90 (revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR 20897
+! Make sure intrinsic type names do not appear as names of derived types
+type integer ! { dg-error "cannot be the same as an intrinsic type" }
+type real ! { dg-error "cannot be the same as an intrinsic type" }
+type complex ! { dg-error "cannot be the same as an intrinsic type" }
+type character ! { dg-error "cannot be the same as an intrinsic type" }
+type logical ! { dg-error "cannot be the same as an intrinsic type" }
+type complex ! { dg-error "cannot be the same as an intrinsic type" }
+type double precision ! { dg-error "Unclassifiable statement" }
+type doubleprecision ! { dg-error "cannot be the same as an intrinsic type" }
+type double complex ! { dg-error "Unclassifiable statement" }
+type doublecomplex ! { dg-error "cannot be the same as an intrinsic type" }
+
+type x
+ integer y
+end type x
+end
+
Index: testsuite/gfortran.dg/derived_name_2.f
===================================================================
--- testsuite/gfortran.dg/derived_name_2.f (revision 0)
+++ testsuite/gfortran.dg/derived_name_2.f (revision 0)
@@ -0,0 +1,19 @@
+! { dg-do compile }
+! PR 20897
+! Make sure intrinsic type names do not appear as names of derived types
+ type integer ! { dg-error "cannot be the same as an intrinsic type" }
+ type real ! { dg-error "cannot be the same as an intrinsic type" }
+ type complex ! { dg-error "cannot be the same as an intrinsic type" }
+ type character ! { dg-error "cannot be the same as an intrinsic type" }
+ type logical ! { dg-error "cannot be the same as an intrinsic type" }
+ type complex ! { dg-error "cannot be the same as an intrinsic type" }
+ type double precision ! { dg-error "cannot be the same as an intrinsic type" }
+ type doubleprecision ! { dg-error "cannot be the same as an intrinsic type" }
+ type double complex ! { dg-error "cannot be the same as an intrinsic type" }
+ type doublecomplex ! { dg-error "cannot be the same as an intrinsic type" }
+
+ type x
+ integer y
+ end type x
+ end
+