[Bug fortran/92754] ICE in gfc_finish_var_decl, at fortran/trans-decl.c:693

2019-12-04 Thread burnus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92754

Tobias Burnus  changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution|--- |FIXED

--- Comment #5 from Tobias Burnus  ---
FIXED on the GCC 10 trunk – not a (real) regression and potentially fragile
(cf. email); hence, no backporting.

Thanks for the bug report!

[Bug fortran/92754] ICE in gfc_finish_var_decl, at fortran/trans-decl.c:693

2019-12-04 Thread burnus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92754

--- Comment #4 from Tobias Burnus  ---
Author: burnus
Date: Wed Dec  4 12:19:55 2019
New Revision: 278961

URL: https://gcc.gnu.org/viewcvs?rev=278961=gcc=rev
Log:
Fortran] PR92754 - fix an issue with resolving intrinsic functions

gcc/fortran/
PR fortran/92754
* intrinsic.c (gfc_intrinsic_func_interface): Set
sym's flavor, intrinsic and function attribute if
unset.

gcc/testsuite/
PR fortran/92754
gfortran.dg/intrinsic_9.f90: New.


Added:
trunk/gcc/testsuite/gfortran.dg/intrinsic_9.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/intrinsic.c
trunk/gcc/testsuite/ChangeLog

[Bug fortran/92754] ICE in gfc_finish_var_decl, at fortran/trans-decl.c:693

2019-12-04 Thread burnus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92754

--- Comment #3 from Tobias Burnus  ---
Patch: https://gcc.gnu.org/ml/gcc-patches/2019-12/msg00153.html

[Bug fortran/92754] ICE in gfc_finish_var_decl, at fortran/trans-decl.c:693

2019-12-03 Thread burnus at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92754

--- Comment #2 from Tobias Burnus  ---
Created attachment 47407
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=47407=edit
Lightly tested patch

(In reply to Martin Liška from comment #1)
> Confirmed, started with r218068, it was rejected before the revision.
Which is from 2014 - 5 years ago … I am not sure whether it then really makes
sense to add someone as CC :-)


The problem is that gfc_finish_var_decl's
690   else if (sym->module && !sym->attr.result && !sym->attr.dummy)
is evaluated as true for the 'max' function as sym->module is "(intrinsic)" but
it is still marked as sym->attr.flavor == FL_VARIABLE and sym->attr.function ==
0

Or in other words, gfc_intrinsic_func_interface does:

  expr->value.function.isym = specific;
  if (!expr->symtree->n.sym->module)
gfc_intrinsic_symbol (expr->symtree->n.sym);

which updates expr->value.function and sets expr->symtree->n.sym to intrinsic,
but otherwise,  expr->symtree->n.sym is still FL_UNKNOWN and attr.function = 0.

As this is now fine, resolve_unknown_f returns and nothing happens later. (The
expr type is expr->type == EXPR_CONST).


Something like the following seems to work. But one really needs to do
something like that for all gfc_intrinsic_func_interface calls, e.g. by adding
such a resolve call to gfc_intrinsic_func_interface itself.

[Bug fortran/92754] ICE in gfc_finish_var_decl, at fortran/trans-decl.c:693

2019-12-03 Thread marxin at gcc dot gnu.org
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92754

Martin Liška  changed:

   What|Removed |Added

 Status|UNCONFIRMED |NEW
   Last reconfirmed||2019-12-03
 CC||burnus at gcc dot gnu.org,
   ||marxin at gcc dot gnu.org
 Ever confirmed|0   |1

--- Comment #1 from Martin Liška  ---
Confirmed, started with r218068, it was rejected before the revision.