]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[multiple changes]
authorTobias Burnus <burnus@net-b.de>
Sun, 19 Aug 2007 20:08:14 +0000 (22:08 +0200)
committerTobias Burnus <burnus@gcc.gnu.org>
Sun, 19 Aug 2007 20:08:14 +0000 (22:08 +0200)
2007-08-18  Tobias Burnus  <burnus@net-b.de>

* 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  <burnus@net-b.de>

* gfortran.dg/interface_abstract_2.f90: New.
* gfortran.dg/interface_abstract_1.f90: Fix typo.

From-SVN: r127626

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/gfortran.h
gcc/fortran/module.c
gcc/fortran/parse.c
gcc/fortran/symbol.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/interface_abstract_1.f90
gcc/testsuite/gfortran.dg/interface_abstract_2.f90 [new file with mode: 0644]

index 0a27333bdf9d897f70a6cec42b76559d995a981c..ed172470f4c2b399e25365e836b32777f9f3a33a 100644 (file)
@@ -1,3 +1,13 @@
+2007-08-18  Tobias Burnus  <burnus@net-b.de>
+
+       * 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  <roger@eyesopen.com>
 
        * primary.c (match_logical_constant_string): New function to match
index ed0defd9782f1d56edf38eb9b92dbad66fdea45d..eb1e4236a3b500980fb58556f98fa78f02c02ddd 100644 (file)
@@ -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);
index ef7811d05b7c02378aeb1cdbaeae2c08df137c20..01b9d93330d97b9494da6421be7293c5d97c66c5 100644 (file)
@@ -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 *);
index 2839386a3621bafcb4648523bc9abbb6ddc42dce..00f3674b597be22d3229d54609bf0b28542d5021 100644 (file)
@@ -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)
index 40b2816c62df02151ef461ff91a96f8f115157da..835b05a97e20a68bf9fce52f7d378f1cb9ebf72e 100644 (file)
@@ -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);
index a1cd815c47d1f04248e1b1694ab8d379c06b92c2..6f91e75eab8f9a01cf4b40760323bd89964558ae 100644 (file)
@@ -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
index 0ef6f864005527b5665ffc753f17c4cb121507b0..871df930c0ebadb8fe4524d7bfe05682686600fd 100644 (file)
@@ -1,3 +1,8 @@
+2007-08-19  Tobias Burnus  <burnus@net-b.de>
+
+       * gfortran.dg/interface_abstract_2.f90: New.
+       * gfortran.dg/interface_abstract_1.f90: Fix typo.
+
 2007-08-19  Dorit Nuzman  <dorit@il.ibm.com>
 
        * gcc.dg/vect/vect-117.c: Change inner-loop bound to
index 7bb583af825a09024cd11c2b5a2cb292fdc0981c..afb3d6a2aac515c32adb3117348f70ceba9c3827 100644 (file)
@@ -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 (file)
index 0000000..5eb5a0e
--- /dev/null
@@ -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