From e9c06563626f034b29c8ccb35b01632a3fede753 Mon Sep 17 00:00:00 2001 From: Tobias Burnus Date: Sun, 19 Aug 2007 22:08:14 +0200 Subject: [PATCH] [multiple changes] 2007-08-18 Tobias Burnus * gfortran.h (gfc_is_intrinsic_typename): Add declaration. * symbol.c (gfc_is_intrinsic_typename): New function. * parse.c (decode_statement): Check for space in ABSTRACT INTERFACE. (parse_interface): Use gfc_is_intrinsic_typename. * decl.c (gfc_match_derived_decl): Ditto. * module.c (gfc_match_use): Use gcc_unreachable() for INTERFACE_ABSTRACT in switch(). 2007-08-19 Tobias Burnus * gfortran.dg/interface_abstract_2.f90: New. * gfortran.dg/interface_abstract_1.f90: Fix typo. From-SVN: r127626 --- gcc/fortran/ChangeLog | 10 ++++++++++ gcc/fortran/decl.c | 13 ++----------- gcc/fortran/gfortran.h | 1 + gcc/fortran/module.c | 4 +++- gcc/fortran/parse.c | 14 ++++++-------- gcc/fortran/symbol.c | 18 ++++++++++++++++++ gcc/testsuite/ChangeLog | 5 +++++ .../gfortran.dg/interface_abstract_1.f90 | 2 +- .../gfortran.dg/interface_abstract_2.f90 | 7 +++++++ 9 files changed, 53 insertions(+), 21 deletions(-) create mode 100644 gcc/testsuite/gfortran.dg/interface_abstract_2.f90 diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index 0a27333bdf9..ed172470f4c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -1,3 +1,13 @@ +2007-08-18 Tobias Burnus + + * gfortran.h (gfc_is_intrinsic_typename): Add declaration. + * symbol.c (gfc_is_intrinsic_typename): New function. + * parse.c (decode_statement): Check for space in ABSTRACT INTERFACE. + (parse_interface): Use gfc_is_intrinsic_typename. + * decl.c (gfc_match_derived_decl): Ditto. + * module.c (gfc_match_use): Use gcc_unreachable() for + INTERFACE_ABSTRACT in switch(). + 2007-08-18 Roger Sayle * primary.c (match_logical_constant_string): New function to match diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c index ed0defd9782..eb1e4236a3b 100644 --- a/gcc/fortran/decl.c +++ b/gcc/fortran/decl.c @@ -5468,17 +5468,8 @@ gfc_match_derived_decl (void) if (m != MATCH_YES) return m; - /* Make sure the name isn't the name of an intrinsic type. The - '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, "doubleprecision") == 0 - || strcmp (name, "doublecomplex") == 0) + /* Make sure the name is not the name of an intrinsic type. */ + if (gfc_is_intrinsic_typename (name)) { gfc_error ("Type name '%s' at %C cannot be the same as an intrinsic " "type", name); diff --git a/gcc/fortran/gfortran.h b/gcc/fortran/gfortran.h index ef7811d05b7..01b9d93330d 100644 --- a/gcc/fortran/gfortran.h +++ b/gcc/fortran/gfortran.h @@ -2056,6 +2056,7 @@ try gfc_add_new_implicit_range (int, int); try gfc_merge_new_implicit (gfc_typespec *); void gfc_set_implicit_none (void); void gfc_check_function_type (gfc_namespace *); +bool gfc_is_intrinsic_typename (const char *); gfc_typespec *gfc_get_default_type (gfc_symbol *, gfc_namespace *); try gfc_set_default_type (gfc_symbol *, int, gfc_namespace *); diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c index 2839386a362..00f3674b597 100644 --- a/gcc/fortran/module.c +++ b/gcc/fortran/module.c @@ -599,7 +599,6 @@ gfc_match_use (void) switch (type) { case INTERFACE_NAMELESS: - case INTERFACE_ABSTRACT: gfc_error ("Missing generic specification in USE statement at %C"); goto cleanup; @@ -659,6 +658,9 @@ gfc_match_use (void) case INTERFACE_INTRINSIC_OP: new->operator = operator; break; + + default: + gcc_unreachable (); } if (gfc_match_eos () == MATCH_YES) diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c index 40b2816c62d..835b05a97e2 100644 --- a/gcc/fortran/parse.c +++ b/gcc/fortran/parse.c @@ -172,7 +172,8 @@ decode_statement (void) switch (c) { case 'a': - match ("abstract interface", gfc_match_abstract_interface, ST_INTERFACE); + match ("abstract% interface", gfc_match_abstract_interface, + ST_INTERFACE); match ("allocate", gfc_match_allocate, ST_ALLOCATE); match ("allocatable", gfc_match_allocatable, ST_ATTR_DECL); match ("assign", gfc_match_assign, ST_LABEL_ASSIGNMENT); @@ -1799,13 +1800,10 @@ loop: if (current_interface.type == INTERFACE_ABSTRACT) { gfc_new_block->attr.abstract = 1; - if (!strcmp(gfc_new_block->name,"integer") - || !strcmp(gfc_new_block->name,"real") - || !strcmp(gfc_new_block->name,"complex") - || !strcmp(gfc_new_block->name,"character") - || !strcmp(gfc_new_block->name,"logical")) - gfc_error ("Name of ABSTRACT INTERFACE at %C cannot be the same as " - "an intrinsic type: %s",gfc_new_block->name); + if (gfc_is_intrinsic_typename (gfc_new_block->name)) + gfc_error ("Name '%s' of ABSTRACT INTERFACE at %C " + "cannot be the same as an intrinsic type", + gfc_new_block->name); } push_state (&s2, new_state, gfc_new_block); diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c index a1cd815c47d..6f91e75eab8 100644 --- a/gcc/fortran/symbol.c +++ b/gcc/fortran/symbol.c @@ -2909,6 +2909,24 @@ gfc_traverse_ns (gfc_namespace *ns, void (*func) (gfc_symbol *)) } +/* Return TRUE when name is the name of an intrinsic type. */ + +bool +gfc_is_intrinsic_typename (const char *name) +{ + if (strcmp (name, "integer") == 0 + || strcmp (name, "real") == 0 + || strcmp (name, "character") == 0 + || strcmp (name, "logical") == 0 + || strcmp (name, "complex") == 0 + || strcmp (name, "doubleprecision") == 0 + || strcmp (name, "doublecomplex") == 0) + return true; + else + return false; +} + + /* Return TRUE if the symbol is an automatic variable. */ static bool diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 0ef6f864005..871df930c0e 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2007-08-19 Tobias Burnus + + * gfortran.dg/interface_abstract_2.f90: New. + * gfortran.dg/interface_abstract_1.f90: Fix typo. + 2007-08-19 Dorit Nuzman * gcc.dg/vect/vect-117.c: Change inner-loop bound to diff --git a/gcc/testsuite/gfortran.dg/interface_abstract_1.f90 b/gcc/testsuite/gfortran.dg/interface_abstract_1.f90 index 7bb583af825..afb3d6a2aac 100644 --- a/gcc/testsuite/gfortran.dg/interface_abstract_1.f90 +++ b/gcc/testsuite/gfortran.dg/interface_abstract_1.f90 @@ -9,7 +9,7 @@ abstract interface end subroutine two subroutine three() bind(C,name="three") ! { dg-error "NAME not allowed on BIND.C. for ABSTRACT INTERFACE" } end subroutine three ! { dg-error "Expecting END INTERFACE statement" } - subroutine real() ! { dg-error "cannot be be the same as an intrinsic type" } + subroutine real() ! { dg-error "cannot be the same as an intrinsic type" } end subroutine real end interface end diff --git a/gcc/testsuite/gfortran.dg/interface_abstract_2.f90 b/gcc/testsuite/gfortran.dg/interface_abstract_2.f90 new file mode 100644 index 00000000000..5eb5a0e53f4 --- /dev/null +++ b/gcc/testsuite/gfortran.dg/interface_abstract_2.f90 @@ -0,0 +1,7 @@ +! { dg-do compile } +! { dg-options "-std=f95" } +abstract interface ! { dg-error "Fortran 2003: ABSTRACT INTERFACE" } + subroutine two() + end subroutine two +end interface ! { dg-error "Expecting END PROGRAM statement" } +end