re PR fortran/27954 (ICE on garbage in DATA statement)
authorJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 27 Oct 2006 20:47:28 +0000 (20:47 +0000)
committerJerry DeLisle <jvdelisle@gcc.gnu.org>
Fri, 27 Oct 2006 20:47:28 +0000 (20:47 +0000)
2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

PR fortran/27954
* decl.c (gfc_free_data_all): New function to free all data structures
after errors in DATA statements and declarations.
(top_var_list): Use new function.(top_val_list): Use new function.
(gfc_match_data_decl): Use new function.
* misc.c (gfc_typename): Fixed incorrect function name in error text.

From-SVN: r118084

gcc/fortran/ChangeLog
gcc/fortran/decl.c
gcc/fortran/misc.c

index 0d29f46d3c71c02b018d191740acbe73b7fc59ac..8ff4a5fff5649ec82aa17eb9402bebab003e3a7c 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-27  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
+
+       PR fortran/27954
+       * decl.c (gfc_free_data_all): New function to free all data structures
+       after errors in DATA statements and declarations.
+       (top_var_list): Use new function.(top_val_list): Use new function.
+       (gfc_match_data_decl): Use new function.
+       * misc.c (gfc_typename): Fixed incorrect function name in error text. 
+
 2006-10-24  Erik Edelmann  <eedelman@gcc.gnu.org>
 
        PR fortran/29393
index 02dc38cc8bb49664fc4effaa97cfee2f22cdcd9f..fbd2bbbe360375ec6b39b59b65aea970aadc472b 100644 (file)
@@ -128,6 +128,21 @@ gfc_free_data (gfc_data * p)
 }
 
 
+/* Free all data in a namespace.  */
+static void
+gfc_free_data_all (gfc_namespace * ns)
+{
+  gfc_data *d;
+
+  for (;ns->data;)
+    {
+      d = ns->data->next;
+      gfc_free (ns->data);
+      ns->data = d;
+    }
+}
+
+
 static match var_element (gfc_data_variable *);
 
 /* Match a list of variables terminated by an iterator and a right
@@ -262,6 +277,7 @@ top_var_list (gfc_data * d)
 
 syntax:
   gfc_syntax_error (ST_DATA);
+  gfc_free_data_all (gfc_current_ns);
   return MATCH_ERROR;
 }
 
@@ -374,6 +390,7 @@ top_val_list (gfc_data * data)
 
 syntax:
   gfc_syntax_error (ST_DATA);
+  gfc_free_data_all (gfc_current_ns);
   return MATCH_ERROR;
 }
 
@@ -2368,6 +2385,8 @@ ok:
   gfc_error ("Syntax error in data declaration at %C");
   m = MATCH_ERROR;
 
+  gfc_free_data_all (gfc_current_ns);
+
 cleanup:
   gfc_free_array_spec (current_as);
   current_as = NULL;
index 4d94d7fab72e6afb5bd9e43cd4b5b85d99a7a626..bafb69819dddf70d37f7db77c7b5619e6ed943a8 100644 (file)
@@ -193,7 +193,7 @@ gfc_typename (gfc_typespec * ts)
       strcpy (buffer, "UNKNOWN");
       break;
     default:
-      gfc_internal_error ("gfc_typespec(): Undefined type");
+      gfc_internal_error ("gfc_typename(): Undefined type");
     }
 
   return buffer;