[Patch, Fortran] PRs 60283/60543: Fix two wrong-code bugs related for implicit pure

Tobias Burnus burnus@net-b.de
Sun Mar 16 19:21:00 GMT 2014


This patch fixes two issues, where gfortran claims that a function is 
implicit pure, but it is not. That will cause a wrong-code optimization 
in the middle end.

First problem, cf. PR60543, is that implicit pure was not set to 0 for 
calls to impure intrinsic subroutines. (BTW: There are no impure 
intrinsic functions.) Example:

   module m
   contains
     REAL(8) FUNCTION random()
       CALL RANDOM_NUMBER(random)
     END FUNCTION random
   end module m


The second problem pops up if one adds a BLOCK ... END BLOCK around the 
random_number call after applying the patch of the PR, which just does: 
gfc_current_ns->proc_name->attr.implicit_pure = 0.

The problem is that one sets only the implicit_pure of the block to 0 
and not of the function. That's the reason that the patch became much 
longer and that I added gfc_unset_implicit_pure as new function.

Thus, the suspicion I had when reviewing the OpenACC patches turned out 
to be founded. Cf. PR60283.

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

Note: I failed to create a test case.

Tobias
-------------- next part --------------
A non-text attachment was scrubbed...
Name: implicit-pure.diff
Type: text/x-patch
Size: 13033 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20140316/3045de49/attachment.bin>


More information about the Fortran mailing list