public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs
@ 2010-02-25 23:57 burnus at gcc dot gnu dot org
2010-02-26 7:36 ` [Bug fortran/43185] " burnus at gcc dot gnu dot org
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-25 23:57 UTC (permalink / raw)
To: gcc-bugs
"A variable, common block, or procedure pointer declared in the scoping unit of
a main program, module, or submodule implicitly has the SAVE attribute, which
may be con\ffirmed by explicit specification." (F2008, 5.3.16 SAVE attribute).
In terms of the code generated, this already happens: The variables end up in
static memory. In the most cases, it also makes no difference in diagnostics;
however, there is one case.
Currently, the following program fails with
Error: Object 'a' at (1) must have the SAVE attribute for default
initialization of a component
module m
type t
integer :: a = 5
end type t
type(t) :: a
end module m
--
Summary: [F2008] Implicit SAVE in MODULEs
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43185] [F2008] Implicit SAVE in MODULEs
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
@ 2010-02-26 7:36 ` burnus at gcc dot gnu dot org
2010-02-26 22:26 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-26 7:36 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2010-02-26 07:36 -------
Note: One should check that the initialization properly works. It could be that
one needs to add a sym->ns->proc_name->attr.flavor == FL_MODULE in the check
in trans-decl.c's gfc_get_symbol_decl for gfc_conv_initializer (cf. patch in PR
43178).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43185] [F2008] Implicit SAVE in MODULEs
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
2010-02-26 7:36 ` [Bug fortran/43185] " burnus at gcc dot gnu dot org
@ 2010-02-26 22:26 ` burnus at gcc dot gnu dot org
2010-02-26 22:52 ` burnus at gcc dot gnu dot org
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-26 22:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2010-02-26 22:26 -------
Index: resolve.c
===================================================================
--- resolve.c (Revision 157097)
+++ resolve.c (Arbeitskopie)
@@ -8938,12 +8938,11 @@
&& !sym->ns->save_all && !sym->attr.save
&& !sym->attr.pointer && !sym->attr.allocatable
&& has_default_initializer (sym->ts.u.derived))
- {
- gfc_error("Object '%s' at %L must have the SAVE attribute for "
- "default initialization of a component",
- sym->name, &sym->declared_at);
- return FAILURE;
- }
+ && (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Implied SAVE for "
+ "module variable '%s' at %L, needed due to "
+ "the default initializer", sym->name,
+ &sym->declared_at) == FAILURE)
+ return FAILURE;
if (sym->ts.type == BT_CLASS)
{
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43185] [F2008] Implicit SAVE in MODULEs
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
2010-02-26 7:36 ` [Bug fortran/43185] " burnus at gcc dot gnu dot org
2010-02-26 22:26 ` burnus at gcc dot gnu dot org
@ 2010-02-26 22:52 ` burnus at gcc dot gnu dot org
2010-02-27 17:25 ` burnus at gcc dot gnu dot org
2010-02-27 17:26 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-26 22:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2010-02-26 22:52 -------
(In reply to comment #2)
> && has_default_initializer (sym->ts.u.derived))
s/)//
> + && (gfc_notify_std (GFC_STD_F2008, "Fortran 2008: Implied SAVE for "
s/(//
> + "the default initializer", sym->name,
s/initializer/initialization/
Fortran 2008 Standard (5.3.16 SAVE attribute):
"A variable, common block, or procedure pointer declared in the scoping unit of
a main program, module, or submodule implicitly has the SAVE attribute, which
may be confirmed by explicit specification."
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43185] [F2008] Implicit SAVE in MODULEs
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2010-02-26 22:52 ` burnus at gcc dot gnu dot org
@ 2010-02-27 17:25 ` burnus at gcc dot gnu dot org
2010-02-27 17:26 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-27 17:25 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2010-02-27 17:25 -------
Subject: Bug 43185
Author: burnus
Date: Sat Feb 27 17:25:05 2010
New Revision: 157109
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=157109
Log:
2010-02-27 Tobias Burnus <burnus@net-b.de>
PR fortran/43185
* resolve.c (resolve_fl_variable_derived): Imply SAVE
for module variables for Fortran 2008.
2010-02-27 Tobias Burnus <burnus@net-b.de>
PR fortran/43185
* gfortran.dg/default_initialization_1.f90: Add -std=f2003.
* gfortran.dg/default_initialization_4.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/default_initialization_4.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/default_initialization_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug fortran/43185] [F2008] Implicit SAVE in MODULEs
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2010-02-27 17:25 ` burnus at gcc dot gnu dot org
@ 2010-02-27 17:26 ` burnus at gcc dot gnu dot org
4 siblings, 0 replies; 6+ messages in thread
From: burnus at gcc dot gnu dot org @ 2010-02-27 17:26 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from burnus at gcc dot gnu dot org 2010-02-27 17:26 -------
... and fixed on the 4.5 trunk.
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43185
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2010-02-27 17:26 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-02-25 23:57 [Bug fortran/43185] New: [F2008] Implicit SAVE in MODULEs burnus at gcc dot gnu dot org
2010-02-26 7:36 ` [Bug fortran/43185] " burnus at gcc dot gnu dot org
2010-02-26 22:26 ` burnus at gcc dot gnu dot org
2010-02-26 22:52 ` burnus at gcc dot gnu dot org
2010-02-27 17:25 ` burnus at gcc dot gnu dot org
2010-02-27 17:26 ` burnus at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).