Message ID | 637338bf-e3b4-764e-9f4c-f230585be820@sig-st.de |
---|---|
State | New |
Headers | show |
Series | ICE on wrong code [PR94192] | expand |
On Sat, Apr 11, 2020 at 10:27 AM Linus König <link@sig-st.de> wrote: > > Hi, > > Here is the patch with some of the null pointer tests removed. > > This is regression-tested. ChangeLog and test case are as in > https://gcc.gnu.org/pipermail/fortran/2020-April/054193.html . Thanks. Sorry I missed the ChangeLog entry and tests in my previous email. Those look good. > The list of test cases that fail without the remaining NULL > check is below. Is this OK for trunk? Thank you for the test listing. I apologize for being pedantic, but the remaining NULL check is still superfluous. The check can be removed simply by moving the new code past the BT_CLASS and EXPR_VARIABLE checks, just before the loop, like in my previous diffs. The idea is that when array->expr_type is EXPR_VARIABLE, array->symtree is guaranteed not to be NULL. If this invariant was violated, there are at least five functions in simplify.c alone which would segfault, including simplify_bound, even with this patch. Therefore I prefer not to check array->symtree for NULL before the EXPR_VARIABLE test. With that change I will OK the patch. If you and the regression tests concur, I can commit for you. I believe this is appropriate for backporting to 8 and 9 as well. Thanks again for your work. --- Fritz
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index 23b5a2b4439..ca149c0dd00 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -12607,6 +12607,7 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int mp_flag) { gfc_error ("Array pointer %qs at %L must have a deferred shape or " "assumed rank", sym->name, &sym->declared_at); + sym->error = 1; return false; } } diff --git a/gcc/fortran/simplify.c b/gcc/fortran/simplify.c index 66ed925c10d..f5953f801b8 100644 --- a/gcc/fortran/simplify.c +++ b/gcc/fortran/simplify.c @@ -4093,6 +4093,10 @@ simplify_bound (gfc_expr *array, gfc_expr *dim, gfc_expr *kind, int upper) gfc_array_spec *as; int d; + /* Do not attempt to resolve if error has already been issued. */ + if (array->symtree && array->symtree->n.sym->error) + return NULL; + if (array->ts.type == BT_CLASS) return NULL;