diff options
author | Harald Anlauf <anlauf@gmx.de> | 2020-07-06 18:58:23 +0200 |
---|---|---|
committer | Harald Anlauf <anlauf@gmx.de> | 2020-07-06 19:00:10 +0200 |
commit | f2151227dfe90a5fe73297c370786be98b0b090f (patch) | |
tree | 78c1d2ae22e21a6a15cd25c0cda8e1a865230a46 /gcc/fortran/match.c | |
parent | 824084e72e388f81015e7f67922c75f50741355a (diff) | |
download | gcc-f2151227dfe90a5fe73297c370786be98b0b090f.zip gcc-f2151227dfe90a5fe73297c370786be98b0b090f.tar.gz gcc-f2151227dfe90a5fe73297c370786be98b0b090f.tar.bz2 |
PR fortran/95980 - ICE on using sync images with -fcheck=bounds
In SELECT TYPE, the argument may be an incorrectly specified unlimited
polymorphic variable. Avoid a NULL pointer dereference for clean error
recovery.
gcc/fortran/
PR fortran/95980
* match.c (copy_ts_from_selector_to_associate, build_class_sym):
Distinguish between unlimited polymorphic and ordinary variables
to avoid NULL pointer dereference.
* resolve.c (resolve_select_type):
Distinguish between unlimited polymorphic and ordinary variables
to avoid NULL pointer dereference.
Diffstat (limited to 'gcc/fortran/match.c')
-rw-r--r-- | gcc/fortran/match.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c index db5174f..7d3711c 100644 --- a/gcc/fortran/match.c +++ b/gcc/fortran/match.c @@ -6159,14 +6159,18 @@ copy_ts_from_selector_to_associate (gfc_expr *associate, gfc_expr *selector) while (ref && ref->next) ref = ref->next; - if (selector->ts.type == BT_CLASS && CLASS_DATA (selector)->as + if (selector->ts.type == BT_CLASS + && CLASS_DATA (selector) + && CLASS_DATA (selector)->as && CLASS_DATA (selector)->as->type == AS_ASSUMED_RANK) { assoc_sym->attr.dimension = 1; assoc_sym->as = gfc_copy_array_spec (CLASS_DATA (selector)->as); goto build_class_sym; } - else if (selector->ts.type == BT_CLASS && CLASS_DATA (selector)->as + else if (selector->ts.type == BT_CLASS + && CLASS_DATA (selector) + && CLASS_DATA (selector)->as && ref && ref->type == REF_ARRAY) { /* Ensure that the array reference type is set. We cannot use @@ -6223,7 +6227,8 @@ build_class_sym: { /* The correct class container has to be available. */ assoc_sym->ts.type = BT_CLASS; - assoc_sym->ts.u.derived = CLASS_DATA (selector)->ts.u.derived; + assoc_sym->ts.u.derived = CLASS_DATA (selector) + ? CLASS_DATA (selector)->ts.u.derived : selector->ts.u.derived; assoc_sym->attr.pointer = 1; gfc_build_class_symbol (&assoc_sym->ts, &assoc_sym->attr, &assoc_sym->as); } |