Bug 85352 - [11/12/13/14 Regression] Incorrect error diagnosed for dummy argument used in specification expression to subprogram with ENTRY
Summary: [11/12/13/14 Regression] Incorrect error diagnosed for dummy argument used in...
Status: NEW
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 7.2.1
: P4 normal
Target Milestone: 11.5
Assignee: Not yet assigned to anyone
URL:
Keywords: rejects-valid
Depends on:
Blocks:
 
Reported: 2018-04-11 16:32 UTC by mecej4
Modified: 2023-07-07 10:33 UTC (History)
0 users

See Also:
Host:
Target:
Build:
Known to work: 4.5.4
Known to fail: 4.6.4, 4.7.3, 4.8.5, 4.9.3, 5.5.0, 6.4.0, 7.3.0, 8.0.1
Last reconfirmed: 2018-04-11 00:00:00


Attachments
fortran free form source code (516 bytes, text/plain)
2018-04-11 16:32 UTC, mecej4
Details

Note You need to log in before you can comment on or make changes to this bug.
Description mecej4 2018-04-11 16:32:07 UTC
Created attachment 43912 [details]
fortran free form source code

There are some old codes (e.g., RMAT SWMOL3 - Molecule-Sweden code) in which there are subroutines with ENTRY statements. A dummy argument to the ENTRY name is allowed in specification expressions; F2003 12.5.2.4 says:

"If a dummy argument is used in a specification expression to specify an array bound or character length of an object, the appearance of the object in a statement that is executed during a procedure reference is permitted only if the dummy argument appears in the dummy argument list of the procedure name referenced and it is present (12.4.1.6)."

I constructed the example code to mimic the SWMOL3 code http://www.tampa.phys.ucl.ac.uk/rmat/old/swmol3.f .

G95, Intel Fortran 18 and Lahey-Fujitsu 7.1 compile the example code with no error messages. Gfortran 7.2.1 20170915 (Red Hat 7.2.1-2) (GCC) says:

"sh-4.4$ gfortran -c bug.f90                                                  
bug.f90:17:27:                                                               
                                                                             
       CALL acomp(Sabb,nuca)                                                 
                           1                                                 
Error: Variable 'nuc1', used in a specification expression, is referenced at (1) before the ENTRY statement in which it is a parameter bug.f90:17:27: "
Comment 1 mecej4 2018-04-11 16:38:01 UTC
The bug goes away if some apparently unrelated changes are made. For example, if "ENTRY rfinit" is commented out, the bug is not seen.
Comment 2 Dominique d'Humieres 2018-04-11 16:58:56 UTC
Confirmed from 4.8 up to trunk (8.0).
Comment 3 mecej4 2018-04-12 08:57:52 UTC
I found a server that had an older version of GCC, on which the test code compiled without error messages from the compiler:

      gcc version 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
Comment 4 Dominique d'Humieres 2018-04-12 09:50:56 UTC
> I found a server that had an older version of GCC, on which the test code
> compiled without error messages from the compiler:

It compiles also with 4.5.4, but not with 4.6.4.

The change occurred between revisions r162456 (2010-07-23, compiles) and r1635293 (2010-08-24, error), r162486 (pr45030)?
Comment 5 Jakub Jelinek 2018-10-26 10:25:41 UTC
GCC 6 branch is being closed
Comment 6 Richard Biener 2019-11-14 07:59:10 UTC
The GCC 7 branch is being closed, re-targeting to GCC 8.4.
Comment 7 Jakub Jelinek 2020-03-04 09:40:00 UTC
GCC 8.4.0 has been released, adjusting target milestone.
Comment 8 Jakub Jelinek 2021-05-14 09:50:22 UTC
GCC 8 branch is being closed.
Comment 9 Richard Biener 2021-06-01 08:11:21 UTC
GCC 9.4 is being released, retargeting bugs to GCC 9.5.
Comment 10 Richard Biener 2022-05-27 09:38:53 UTC
GCC 9 branch is being closed
Comment 11 Jakub Jelinek 2022-06-28 10:35:08 UTC
GCC 10.4 is being released, retargeting bugs to GCC 10.5.
Comment 12 Richard Biener 2023-07-07 10:33:46 UTC
GCC 10 branch is being closed.