https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100607
anlauf at gcc dot gnu.org changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |NEW CC| |anlauf at gcc dot gnu.org Keywords| |diagnostic --- Comment #3 from anlauf at gcc dot gnu.org --- (In reply to kargl from comment #2) > Remove ice-on-invalid-code as I don't get an ICE. > > The following patch suppresses the error message with the temporary variable > and removes duplicated code. Please commit. > > diff --git a/gcc/fortran/resolve.cc b/gcc/fortran/resolve.cc > index 46585879ddc..3462d43f346 100644 > --- a/gcc/fortran/resolve.cc > +++ b/gcc/fortran/resolve.cc > @@ -9909,11 +9909,6 @@ resolve_select_rank (gfc_code *code, gfc_namespace > *old_ns) > || gfc_expr_attr (code->expr1).pointer)) > gfc_error ("RANK (*) at %L cannot be used with the pointer or " > "allocatable selector at %L", &c->where, > &code->expr1->where); > - > - if (case_value == -1 && (gfc_expr_attr (code->expr1).allocatable > - || gfc_expr_attr (code->expr1).pointer)) > - gfc_error ("RANK (*) at %L cannot be used with the pointer or " > - "allocatable selector at %L", &c->where, > &code->expr1->where); > } > > /* Add EXEC_SELECT to switch on rank. */ This is a gem: not dead code, but un-dead code ... ;-) > @@ -12948,7 +12943,9 @@ resolve_fl_var_and_proc (gfc_symbol *sym, int > mp_flag) > > if (allocatable) > { > - if (dimension && as->type != AS_ASSUMED_RANK) > + if (dimension > + && as->type != AS_ASSUMED_RANK > + && !sym->attr.select_rank_temporary) > { > gfc_error ("Allocatable array %qs at %L must have a deferred " > "shape or assumed rank", sym->name, &sym->declared_at); I remember that spot of code as it was hit by one of Gerhard's testcases with as == NULL ... I'll have a look. The diagnostic indeed was bogus.