------- Comment #21 from tobi at gcc dot gnu dot org  2007-02-10 02:50 -------
Here's a much cleaner patch, which makes us give slightly worse error messages
than before.  I'll submit this to the list tomorrow when I'm done testing.

2007-02-10  Tobias Schlüter  <[EMAIL PROTECTED]>

        PR fortran/30478
fortran/
        * decl.c (gfc_match_enum): Fix typo in error message.
        * parse.c (match): Remove stray semicolon from macro definition.
        (decode_statement): Don't allow data declarations in ENUMs or
        ENUMERATOR definitions outside.
testsuite/
        * gfortran.dg/enum_2.f90: Update regexps for error messages.

Index: gcc/testsuite/gfortran.dg/enum_2.f90
===================================================================
--- gcc/testsuite/gfortran.dg/enum_2.f90        (revision 121787)
+++ gcc/testsuite/gfortran.dg/enum_2.f90        (working copy)
@@ -5,9 +5,9 @@ program main
   implicit none
   enum, bind (c)
     enumerator :: red, black
-    integer :: x  ! { dg-error "Unexpected data declaration" }
+    integer :: x  ! { dg-error "Unclassifiable statement" }
     enumerator blue = 1  ! { dg-error "Syntax error in ENUMERATOR definition"
}
   end enum

-  enumerator :: sun  ! { dg-error "ENUM" }
+  enumerator :: sun  ! { dg-error "Unclassifiable statement" }
 end program main
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c  (revision 121787)
+++ gcc/fortran/decl.c  (working copy)
@@ -4081,7 +4081,7 @@ gfc_match_enum (void)
     return m;

   if (gfc_notify_std (GFC_STD_F2003, 
-                     "New in Fortran 2003: ENUM AND ENUMERATOR at %C")
+                     "New in Fortran 2003: ENUM and ENUMERATOR at %C")
       == FAILURE)
     return MATCH_ERROR;

Index: gcc/fortran/parse.c
===================================================================
--- gcc/fortran/parse.c (revision 121787)
+++ gcc/fortran/parse.c (working copy)
@@ -84,7 +84,7 @@ match_word (const char *str, match (*sub
         return st;                                             \
       else                                                     \
         undo_new_statement ();                                  \
-    } while (0);
+    } while (0)

 static gfc_statement
 decode_statement (void)
@@ -131,8 +131,10 @@ decode_statement (void)
   match (NULL, gfc_match_pointer_assignment, ST_POINTER_ASSIGNMENT);
   match (NULL, gfc_match_st_function, ST_STATEMENT_FUNCTION);

-  match (NULL, gfc_match_data_decl, ST_DATA_DECL);
-  match (NULL, gfc_match_enumerator_def, ST_ENUMERATOR);
+  if (gfc_current_state () != COMP_ENUM)
+    match (NULL, gfc_match_data_decl, ST_DATA_DECL);
+  else 
+    match (NULL, gfc_match_enumerator_def, ST_ENUMERATOR);

   /* Try to match a subroutine statement, which has the same optional
      prefixes that functions can have.  */


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30478

Reply via email to