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

--- Comment #8 from Mikael Morin <mikael at gcc dot gnu.org> 2013-04-03 
20:58:25 UTC ---
Another tentative patch.
This moves the namespace release after the call to gfc_undo_symbols.

With it, one gets among a trail of other errors:
bug_report.f03:322.8:

        select type ( v => this % value
        1
Error: Unclassifiable statement at (1)



Index: match.c
===================================================================
--- match.c    (révision 196417)
+++ match.c    (copie de travail)
@@ -5364,7 +5364,6 @@ gfc_match_select_type (void)
   char name[GFC_MAX_SYMBOL_LEN];
   bool class_array;
   gfc_symbol *sym;
-  gfc_namespace *parent_ns;

   m = gfc_match_label ();
   if (m == MATCH_ERROR)
@@ -5374,8 +5373,6 @@ gfc_match_select_type (void)
   if (m != MATCH_YES)
     return m;

-  gfc_current_ns = gfc_build_block_ns (gfc_current_ns);
-
   m = gfc_match (" %n => %e", name, &expr2);
   if (m == MATCH_YES)
     {
@@ -5444,9 +5441,6 @@ gfc_match_select_type (void)
   return MATCH_YES;

 cleanup:
-  parent_ns = gfc_current_ns->parent;
-  gfc_free_namespace (gfc_current_ns);
-  gfc_current_ns = parent_ns;
   return m;
 }

Index: parse.c
===================================================================
--- parse.c    (révision 196417)
+++ parse.c    (copie de travail)
@@ -262,6 +262,7 @@ end_of_block:
 static gfc_statement
 decode_statement (void)
 {
+  gfc_namespace *ns;
   gfc_statement st;
   locus old_locus;
   match m;
@@ -363,7 +364,12 @@ decode_statement (void)
   match (NULL, gfc_match_associate, ST_ASSOCIATE);
   match (NULL, gfc_match_critical, ST_CRITICAL);
   match (NULL, gfc_match_select, ST_SELECT_CASE);
+
+  gfc_current_ns = gfc_build_block_ns (gfc_current_ns);
   match (NULL, gfc_match_select_type, ST_SELECT_TYPE);
+  ns = gfc_current_ns;
+  gfc_current_ns = gfc_current_ns->parent;
+  gfc_free_namespace (ns);

   /* General statement matching: Instead of testing every possible
      statement, we eliminate most possibilities by peeking at the

Reply via email to