[Patch, Fortran] PR92754 - fix an issue with resolving intrinsic functions

Tobias Burnus tobias@codesourcery.com
Tue Dec 3 16:41:00 GMT 2019


The problem here is that one gets two symbols - one inside the block and 
one outside and they do not really agree whether one has a function or a 
variable – which later gives an ICE. As sym->module was "(intrinsic)" 
and FL_VARIABLE, one was running into an assert.

The problem is that when resolving the expression with "max", gfortran 
detects that it got an intrinsic function and resolves the 
expression/function call (in this case to a constant). However, the 
information that "max" was regarded as intrinsic procedure never ends up 
in the symbol itself, only in the expression.

My first idea was to call gfc_resolve_intrinsic, which does a lot of 
nice things like setting the attributes, warning that the type is 
ignored with intrinsic procedures (-Wsurprsing, only) etc. However, that 
gives a bunch of ICE. Even a more Spartan attr setting had similar 
issues – hence, I moved it below the simplification, in the hope it 
would work there. Well, gfc_resolve_intrinsic still gave tons of errors 
and ICEs, but what I now have works. (I think it also works w/o the 
FL_UNKNOWN condition, but, in any case, I am not sure which variant is 
better)

The settings I use with this patch seem to work and I have the hope that 
it covers all valid/invalid code correctly (fingers crossed).

Build and regtested on x86-64-gnu-linux.
OK for the trunk?

Tobias

PS: I added 'sym' as after simplifcation, expr->symtree->n.sym might no 
longer exist; getting rid of 'name' was only a cleanup as sym->name is a 
tad clearer and avoids another variable.

PPS: I ended up fixing this PR as Martin CC'ed me – after finding that 
my commit caused the ICE; well, that one was in 2014 (!), somewhat 
unrelated, and before that commit the code was rejected… With a lot of 
good (evil?) will, one can still call it a regression ;-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr92754-v2.diff
Type: text/x-patch
Size: 3304 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20191203/fdbc850b/attachment.bin>


More information about the Fortran mailing list