Bug 19425 - Duplicate SAVE attribute problem
Summary: Duplicate SAVE attribute problem
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: fortran (show other bugs)
Version: 4.0.0
: P2 enhancement
Target Milestone: 4.1.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
: 21434 (view as bug list)
Depends on:
Blocks: 19292
  Show dependency treegraph
 
Reported: 2005-01-13 14:26 UTC by Toby White
Modified: 2005-10-24 15:09 UTC (History)
4 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-09-18 05:35:52


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Toby White 2005-01-13 14:26:35 UTC
Consider the following program: 
parabrisas:~/test% cat C578.f  
      subroutine s( ) 
      logical frstme 
      save frstme 
      save 
      continue 
      end 
 
Under constraint C578 of the f95 standard this is illegal, since a global save 
is not permitted in the same scoping unit as any other explicit use of the 
save attribute or save statement. gfortran correctly recognises this and 
diagnoses an error. 
 
However, this constraint did not exist in F77 (I am unsure about F90). 
Therefore, the above is a perfectly legal F77 program (and, indeed g77 
compiles it without complaint).
Comment 1 Toby White 2005-01-13 14:59:15 UTC
Brief correction - the reference to C578 is actually from the F2003 standard. 
In f95 is it is the second, unnumbered, constraint in section 5.2.4. 
Comment 2 Andrew Pinski 2005-01-14 23:41:11 UTC
f90 has the same constraint as f95 at least that is what ICC reports.
Comment 3 Andrew Pinski 2005-02-12 23:19:15 UTC
Confirmed.
Comment 4 kargl 2005-03-22 18:36:16 UTC
Fortran 77 also forbids the behavior.  It looks like the
code is illegal, and g77 contains a bug.
Comment 5 Konrad Bernlöhr 2005-05-06 13:08:08 UTC
In the Fortran 77 standard (ANSI X3.9-1978) I could not find any sentence that
indicates that a SAVE statement without a list cannot appear in the same program
unit as a SAVE statement with a list of variables. I would conclude that
gfortran does NOT compile valid F77 code. Code which, by the way, is not only
compiled by
g77 but by commercial compilers as well.

Please be more specific if you think that I am wrong.

Comment 6 Toby White 2005-05-06 13:21:50 UTC
(In reply to comment #5) 
> In the Fortran 77 standard (ANSI X3.9-1978) I could not find any sentence 
that 
> indicates that a SAVE statement without a list cannot appear in the same 
program 
> unit as a SAVE statement with a list of variables. 
> [snip] 
> Please be more specific if you think that I am wrong. 
 
Please see the thread on the gfortran mailing list, starting at 
<URL:http://gcc.gnu.org/ml/fortran/2005-03/msg00372.html> 
 
The definitive answer is probably Richard Maine's at: 
<URL:http://gcc.gnu.org/ml/fortran/2005-03/msg00410.html> 
 
In brief, the code is almost certainly illegal - but since g77 compiles it (as 
do several other compilers), it is a clear regression for gfortran to not 
allow its compilation (albeit not under -std=f95) 
 
Comment 7 Tobias Schlüter 2005-05-07 15:56:41 UTC
*** Bug 21434 has been marked as a duplicate of this bug. ***
Comment 8 Andrew Pinski 2005-10-24 15:09:42 UTC
Fixed for 4.1 by:
        fortran/
        * decl.c (gfc_match_save): Changed duplicate SAVE errors to
        warnings in the absence of strict standard conformance
        * symbol.c (gfc_add_save): Same.