[patch, fortran] PR27954 ICE on garbage in DATA statement
Paul Thomas
paulthomas2@wanadoo.fr
Sat Oct 21 08:35:00 GMT 2006
Jerry
:REVIEWMAIL:
>
>
> The three test cases provided gave three different internal errors on
> i686-linux. One on a bad symbol, one on a bad type, and one segfault.
Putting the three tests in separate procedures would combine them into
one, would it not?
>
> Regression tested on i686-linux. I would not count on consistent
> error messages before the patch. :)
>
> OK for 4.3 I presume when that trunk is open?
It was there, as promised, a few minutes ago.
Paul
>
>
> Regards,
>
> Jerry
>
> 2006-10-20 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.
>
>
>------------------------------------------------------------------------
>
>! { dg-do compile }
>! PR27954 Internal compiler error on bad statements
>! Derived from test case submitted in PR.
>program bad
> character*20 :: y, x 00 ! { dg-error "Syntax error" }
> data y /'abcdef'/, x /'jbnhjk'/ pp ! { dg-error "Syntax error" }
>end program bad
>
>------------------------------------------------------------------------
>
>! { dg-do compile }
>! PR27954 Internal compiler error on bad statements
>! Derived from test case submitted in PR.
>program bad
> character*20 :: y, x 00 ! { dg-error "Syntax error" }
> data y /'abcdef'/, x /'jbnhjk'/ pp ! { dg-error "Syntax error" }
> print *, "basket case."
>end program bad
>
>------------------------------------------------------------------------
>
>! { dg-do compile }
>! PR27954 Internal compiler error on bad statements
>! Derived from test case submitted in PR.
>program bad
> implicit none
> character*20 :: y, x 00 ! { dg-error "Syntax error" }
> data y /'abcdef'/, x /'jbnhjk'/ pp ! { dg-error "Syntax error" }
> print *, "basket case that segfaults without patch."
>end program bad
>
>------------------------------------------------------------------------
>
>Index: decl.c
>===================================================================
>*** decl.c (revision 117876)
>--- decl.c (working copy)
>*************** gfc_free_data (gfc_data * p)
>*** 128,133 ****
>--- 128,148 ----
> }
>
>
>+ /* 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
>*************** top_var_list (gfc_data * d)
>*** 262,267 ****
>--- 277,283 ----
>
> syntax:
> gfc_syntax_error (ST_DATA);
>+ gfc_free_data_all (gfc_current_ns);
> return MATCH_ERROR;
> }
>
>*************** top_val_list (gfc_data * data)
>*** 374,379 ****
>--- 390,396 ----
>
> syntax:
> gfc_syntax_error (ST_DATA);
>+ gfc_free_data_all (gfc_current_ns);
> return MATCH_ERROR;
> }
>
>*************** ok:
>*** 2368,2373 ****
>--- 2385,2392 ----
> 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: ChangeLog
>===================================================================
>*** ChangeLog (revision 117876)
>--- ChangeLog (working copy)
>***************
>*** 1,8 ****
> 2006-10-16 Tobias Burnus <burnus@net-b.de>
>
> * primary.c: Revert 'significand'-to-'significant' comment change.
>! * invoke.texi (Warning Options): Minor cleanup for
>! -Wimplicit-interface.
>
> 2006-10-17 Paul Thomas <pault@gcc.gnu.org>
>
>--- 1,17 ----
>+ 2006-10-20 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 statments 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-16 Tobias Burnus <burnus@net-b.de>
>
> * primary.c: Revert 'significand'-to-'significant' comment change.
>! * invoke.texi (Warning Options): Minor cleanup for -Wimplicit-interface.
>
> 2006-10-17 Paul Thomas <pault@gcc.gnu.org>
>
>Index: misc.c
>===================================================================
>*** misc.c (revision 117876)
>--- misc.c (working copy)
>*************** gfc_typename (gfc_typespec * ts)
>*** 193,199 ****
> strcpy (buffer, "UNKNOWN");
> break;
> default:
>! gfc_internal_error ("gfc_typespec(): Undefined type");
> }
>
> return buffer;
>--- 193,199 ----
> strcpy (buffer, "UNKNOWN");
> break;
> default:
>! gfc_internal_error ("gfc_typename(): Undefined type");
> }
>
> return buffer;
>
>
More information about the Gcc-patches
mailing list