Commit 4874b4d2 by Steven G. Kargl

re PR fortran/88357 (ICE in parse_associate, at fortran/parse.c:4568)

2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	PR fortran/88357
	* class.c (insert_component_ref): Check for NULL pointer and 
	previous error message issued.
	* parse.c (parse_associate): Check for NULL pointer.
	* resolve.c (resolve_assoc_var): Check for NULL pointer.

2018-12-08  Steven G. Kargl  <kargl@gcc.gnu.org>

	* gfortran.dg/pr88357_1.f90: New test.
	* gfortran.dg/pr88357_2.f90: New test.

From-SVN: r266908
parent 47e1596c
2018-12-08 Steven G. Kargl <kargl@gcc.gnu.org>
PR fortran/88357
* class.c (insert_component_ref): Check for NULL pointer and
previous error message issued.
* parse.c (parse_associate): Check for NULL pointer.
* resolve.c (resolve_assoc_var): Check for NULL pointer.
2018-12-07 Jakub Jelinek <jakub@redhat.com> 2018-12-07 Jakub Jelinek <jakub@redhat.com>
PR fortran/88377 PR fortran/88377
......
...@@ -72,14 +72,18 @@ along with GCC; see the file COPYING3. If not see ...@@ -72,14 +72,18 @@ along with GCC; see the file COPYING3. If not see
static void static void
insert_component_ref (gfc_typespec *ts, gfc_ref **ref, const char * const name) insert_component_ref (gfc_typespec *ts, gfc_ref **ref, const char * const name)
{ {
gfc_symbol *type_sym;
gfc_ref *new_ref; gfc_ref *new_ref;
int wcnt, ecnt;
gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS); gcc_assert (ts->type == BT_DERIVED || ts->type == BT_CLASS);
type_sym = ts->u.derived;
gfc_find_component (type_sym, name, true, true, &new_ref); gfc_find_component (ts->u.derived, name, true, true, &new_ref);
gfc_get_errors (&wcnt, &ecnt);
if (ecnt > 0 && !new_ref)
return;
gcc_assert (new_ref->u.c.component); gcc_assert (new_ref->u.c.component);
while (new_ref->next) while (new_ref->next)
new_ref = new_ref->next; new_ref = new_ref->next;
new_ref->next = *ref; new_ref->next = *ref;
......
...@@ -4563,7 +4563,7 @@ parse_associate (void) ...@@ -4563,7 +4563,7 @@ parse_associate (void)
else else
rank = a->target->rank; rank = a->target->rank;
/* When the rank is greater than zero then sym will be an array. */ /* When the rank is greater than zero then sym will be an array. */
if (sym->ts.type == BT_CLASS) if (sym->ts.type == BT_CLASS && CLASS_DATA (sym))
{ {
if ((!CLASS_DATA (sym)->as && rank != 0) if ((!CLASS_DATA (sym)->as && rank != 0)
|| (CLASS_DATA (sym)->as || (CLASS_DATA (sym)->as
......
...@@ -8715,7 +8715,8 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target) ...@@ -8715,7 +8715,8 @@ resolve_assoc_var (gfc_symbol* sym, bool resolve_target)
{ {
/* target's rank is 0, but the type of the sym is still array valued, /* target's rank is 0, but the type of the sym is still array valued,
which has to be corrected. */ which has to be corrected. */
if (sym->ts.type == BT_CLASS && CLASS_DATA (sym)->as) if (sym->ts.type == BT_CLASS
&& CLASS_DATA (sym) && CLASS_DATA (sym)->as)
{ {
gfc_array_spec *as; gfc_array_spec *as;
symbol_attribute attr; symbol_attribute attr;
......
2018-12-08 Steven G. Kargl <kargl@gcc.gnu.org>
* gfortran.dg/pr88357_1.f90: New test.
* gfortran.dg/pr88357_2.f90: New test.
2018-12-08 Jakub Jelinek <jakub@redhat.com> 2018-12-08 Jakub Jelinek <jakub@redhat.com>
PR fortran/88304 PR fortran/88304
......
! { dg-do compile }
! { dg-options "-fcoarray=single" }
program p
type t
end type
class(t) :: x[*] ! { dg-error "must be dummy, allocatable or pointer" }
associate (y => x)
end associate
end
! { dg-do compile }
program p
type t
end type
class(t) :: x ! { dg-error "must be dummy, allocatable or pointer" }
associate (y => x)
end associate
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment