From bca4d139fd7eb1b554c6701071c27048a0e458a6 Mon Sep 17 00:00:00 2001 From: tobi Date: Thu, 22 Mar 2007 15:37:25 +0000 Subject: [PATCH] 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@123129 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/fortran/ChangeLog | 6 ++++++ gcc/fortran/decl.c | 8 ++++++-- gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gfortran.dg/derived_name_1.f90 | 19 +++++++++++++++++++ gcc/testsuite/gfortran.dg/derived_name_2.f | 19 +++++++++++++++++++ 5 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/derived_name_1.f90 create mode 100644 gcc/testsuite/gfortran.dg/derived_name_2.f diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 3f4ab3c..c32304b 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,9 @@ +2007-03-22 Tobias Schlüter + + PR fortran/20897 + * decl.c (gfc_match_derived_decl): Reliably reject + 'doubleprecision' and 'doublecomplex' as type names. + 2007-03-19 Francois-Xavier Coudert PR fortran/31203 diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index 09ded01..570a036 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -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); diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 656d05b..d993a15 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2007-03-22 Tobias Schlüter + + PR fortran/20897 + * gfortran.dg/derived_name_1.f90: New. + * gfortran.dg/derived_name_2.f: New. + 2007-03-21 Richard Sandiford * lib/target-supports.exp (check_effective_target_nonpic): New diff --git a/gcc/testsuite/gfortran.dg/derived_name_1.f90 b/gcc/testsuite/gfortran.dg/derived_name_1.f90 new file mode 100644 index 0000000..9c6b177 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/derived_name_1.f90 @@ -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 + diff --git a/gcc/testsuite/gfortran.dg/derived_name_2.f b/gcc/testsuite/gfortran.dg/derived_name_2.f new file mode 100644 index 0000000..a89dcdf --- /dev/null +++ b/gcc/testsuite/gfortran.dg/derived_name_2.f @@ -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 + -- 2.7.4