+2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
+
+ PR fortran/54730
+ * array.c (gfc_match_array_constructor): Set a checkpoint before
+ matching a typespec. Drop it on success, restore it otherwise.
+
2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
PR fortran/54730
gfc_match_array_constructor (gfc_expr **result)
{
gfc_constructor_base head, new_cons;
+ gfc_undo_change_set changed_syms;
gfc_expr *expr;
gfc_typespec ts;
locus where;
/* Try to match an optional "type-spec ::" */
gfc_clear_ts (&ts);
+ gfc_new_undo_checkpoint (changed_syms);
if (gfc_match_decl_type_spec (&ts, 0) == MATCH_YES)
{
seen_ts = (gfc_match (" ::") == MATCH_YES);
{
if (gfc_notify_std (GFC_STD_F2003, "Array constructor "
"including type specification at %C") == FAILURE)
- goto cleanup;
+ {
+ gfc_restore_last_undo_checkpoint ();
+ goto cleanup;
+ }
if (ts.deferred)
{
gfc_error ("Type-spec at %L cannot contain a deferred "
"type parameter", &where);
+ gfc_restore_last_undo_checkpoint ();
goto cleanup;
}
}
}
- if (! seen_ts)
- gfc_current_locus = where;
+ if (seen_ts)
+ gfc_drop_last_undo_checkpoint ();
+ else
+ {
+ gfc_restore_last_undo_checkpoint ();
+ gfc_current_locus = where;
+ }
if (gfc_match (end_delim) == MATCH_YES)
{
+2013-03-03 Mikael Morin <mikael@gcc.gnu.org>
+
+ PR fortran/54730
+ * gfortran.dg/array_constructor_42.f90: New test.
+
2013-03-02 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/52688
--- /dev/null
+! { dg-do compile }
+!
+! PR fortran/54730
+! A symbol 'a' was created while attempting to parse a typespec in the array
+! constructor. That (invalid) symbol was kept until translation stage
+! where it was leading to an ICE.
+!
+! Original testcase from Paul Kapinos <kapinos@rz.rwth-aachen.de>
+!
+
+ subroutine s
+ implicit none
+ intrinsic :: real
+ real :: vec(1:2)
+ vec = (/ real(a = 1), 1. /)
+ end subroutine s
+
+ program main
+ implicit none
+ intrinsic :: real
+ print *,(/ real(a = 1) /)
+ end