public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables
@ 2007-11-25 20:14 burnus at gcc dot gnu dot org
2007-11-27 22:12 ` [Bug fortran/34228] " terry at chem dot gu dot se
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-11-25 20:14 UTC (permalink / raw)
To: gcc-bugs
The following is frequently used and accepted by many compilers; thus it should
continue to work in -std=gnu, but - if feasible - one should reject it with
-std=f95/f2003.
subroutine y
data emname/'bar'/
character(len=3) :: emname
end subroutine y
Accepted by most compilers including the picky NAG f95. Rejected by g95:
Symbol 'emname' at (1) being given type CHARACTER(1) already has implicit
type REAL(4)
"5.2.5 DATA statement
[...] A variable that appears in a DATA statement and has not been typed
previously may appear in a subsequent type declaration only if that declaration
confirms the implicit typing. An array name, array section, or array element
that appears in a DATA statement shall have had its array properties
established by a previous specification statement."
The part about DIMENSION is taken into account.
* * *
subroutine y(A,n)
implicit none
real :: A(n)
integer :: n
end subroutine y
This is invalid as "n" is first used and then typed. NAG f95 rejects it with:
Error: Implicit type for N
Error: Symbol N has already been implicitly typed
as other compilers accept this, it frequently occurs and should be allowed for
-std=gnu.
See:
F2003, 7.1.6 (Specification expression), pg 126
F95, 7.1.6.2 (Specification expression), pg 96
"A variable in a specification expression shall have its type and type
parameters, if any, specified by a previous declaration in the scoping
unit, by the implicit typing rules in effect for the scoping unit, or by
host association. If a variable in a specification expression is typed
by the implicit typing rules, its appearance in any subsequent type
declaration statement shall confirm the implicit type and type
parameters".
--
Summary: -std=f* should diagnose used but later typed variables
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: diagnostic
Severity: enhancement
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=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
@ 2007-11-27 22:12 ` terry at chem dot gu dot se
2007-11-27 22:16 ` burnus at gcc dot gnu dot org
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: terry at chem dot gu dot se @ 2007-11-27 22:12 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from terry at chem dot gu dot se 2007-11-27 22:12 -------
But a character string is not an array. The len parameter is a type parameter.
That part of the standard does not apply. It's legal.
--
terry at chem dot gu dot se changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |terry at chem dot gu dot se
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
2007-11-27 22:12 ` [Bug fortran/34228] " terry at chem dot gu dot se
@ 2007-11-27 22:16 ` burnus at gcc dot gnu dot org
2007-11-27 22:23 ` terry at chem dot gu dot se
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-11-27 22:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from burnus at gcc dot gnu dot org 2007-11-27 22:16 -------
(In reply to comment #1)
> But a character string is not an array. The len parameter is a type parameter.
> That part of the standard does not apply. It's legal.
I don't worry about "len=3", I'm worrying about the type:
data emname/'bar'/
is implicitly types REAL and then one line later comes:
character(len=3) :: emname
I still think that this violates: "A variable that appears in a DATA statement
and has not been typed previously may appear in a subsequent type declaration
only if that declaration confirms the implicit typing."
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
2007-11-27 22:12 ` [Bug fortran/34228] " terry at chem dot gu dot se
2007-11-27 22:16 ` burnus at gcc dot gnu dot org
@ 2007-11-27 22:23 ` terry at chem dot gu dot se
2007-11-29 11:24 ` fxcoudert at gcc dot gnu dot org
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: terry at chem dot gu dot se @ 2007-11-27 22:23 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from terry at chem dot gu dot se 2007-11-27 22:23 -------
> I don't worry about "len=3", I'm worrying about the type:
>
> data emname/'bar'/
>
> is implicitly types REAL and then one line later comes:
>
> character(len=3) :: emname
>
> I still think that this violates: "A variable that appears in a DATA statement
> and has not been typed previously may appear in a subsequent type declaration
> only if that declaration confirms the implicit typing."
Ah, yes, you're right. I misinterpreted your concern.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2007-11-27 22:23 ` terry at chem dot gu dot se
@ 2007-11-29 11:24 ` fxcoudert at gcc dot gnu dot org
2008-08-01 8:28 ` domob at gcc dot gnu dot org
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-11-29 11:24 UTC (permalink / raw)
To: gcc-bugs
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-11-29 11:24:37
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-11-29 11:24 ` fxcoudert at gcc dot gnu dot org
@ 2008-08-01 8:28 ` domob at gcc dot gnu dot org
2008-08-22 7:16 ` domob at gcc dot gnu dot org
2008-08-22 7:18 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-08-01 8:28 UTC (permalink / raw)
To: gcc-bugs
--
domob at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |domob at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-11-29 11:24:37 |2008-08-01 08:26:38
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-08-01 8:28 ` domob at gcc dot gnu dot org
@ 2008-08-22 7:16 ` domob at gcc dot gnu dot org
2008-08-22 7:18 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-08-22 7:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from domob at gcc dot gnu dot org 2008-08-22 07:14 -------
Subject: Bug 34228
Author: domob
Date: Fri Aug 22 07:13:25 2008
New Revision: 139425
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139425
Log:
2008-08-22 Daniel Kraft <d@domob.eu>
PR fortran/32095
PR fortran/34228
* gfortran.h (in_prefix): New global.
(gfc_check_symbol_typed), (gfc_check_expr_typed): New methods.
* array.c (match_array_element_spec): Check that bounds-expressions
don't have symbols not-yet-typed in them.
* decl.c (var_element): Check that variable used is already typed.
(char_len_param_value): Check that expression does not contain
not-yet-typed symbols.
(in_prefix): New global.
(gfc_match_prefix): Record using `in_prefix' if we're at the moment
parsing a prefix or not.
* expr.c (gfc_expr_check_typed): New method.
* parse.c (verify_st_order): New argument to disable error output.
(check_function_result_typed): New helper method.
(parse_spec): Check that the function-result declaration, if given in
a prefix, contains no not-yet-typed symbols when the IMPLICIT rules are
parsed.
* symbol.c (gfc_check_symbol_typed): Check that a symbol already has
a type associated to it, otherwise use the IMPLICIT rules or signal
an error.
2008-08-22 Daniel Kraft <d@domob.eu>
PR fortran/32095
PR fortran/34228
* gfortran.dg/used_before_typed_1.f90: New test.
* gfortran.dg/used_before_typed_2.f90: New test.
* gfortran.dg/used_before_typed_3.f90: New test.
* gfortran.dg/array_constructor_26.f03: Add -std=gnu to not enable
legacy-behaviour for the new check.
* gfortran.dg/array_constructor_27.f03: Ditto.
* gfortran.dg/blockdata_4.f90: Ditto.
* gfortran.dg/bound_2.f90: Reordered declarations to satisfy the check.
* gfortran.dg/result_in_spec_1.f90: Ditto.
* gfortran.dg/argument_checking_7.f90: Adapted expected error messages.
Added:
trunk/gcc/testsuite/gfortran.dg/used_before_typed_1.f90
trunk/gcc/testsuite/gfortran.dg/used_before_typed_2.f90
trunk/gcc/testsuite/gfortran.dg/used_before_typed_3.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/array.c
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/expr.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/parse.c
trunk/gcc/fortran/symbol.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/argument_checking_7.f90
trunk/gcc/testsuite/gfortran.dg/array_constructor_26.f03
trunk/gcc/testsuite/gfortran.dg/array_constructor_27.f03
trunk/gcc/testsuite/gfortran.dg/blockdata_4.f90
trunk/gcc/testsuite/gfortran.dg/bound_2.f90
trunk/gcc/testsuite/gfortran.dg/result_in_spec_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
* [Bug fortran/34228] -std=f* should diagnose used but later typed variables
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-08-22 7:16 ` domob at gcc dot gnu dot org
@ 2008-08-22 7:18 ` domob at gcc dot gnu dot org
6 siblings, 0 replies; 8+ messages in thread
From: domob at gcc dot gnu dot org @ 2008-08-22 7:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from domob at gcc dot gnu dot org 2008-08-22 07:17 -------
Fixed.
--
domob at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34228
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-08-22 7:18 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-25 20:14 [Bug fortran/34228] New: -std=f* should diagnose used but later typed variables burnus at gcc dot gnu dot org
2007-11-27 22:12 ` [Bug fortran/34228] " terry at chem dot gu dot se
2007-11-27 22:16 ` burnus at gcc dot gnu dot org
2007-11-27 22:23 ` terry at chem dot gu dot se
2007-11-29 11:24 ` fxcoudert at gcc dot gnu dot org
2008-08-01 8:28 ` domob at gcc dot gnu dot org
2008-08-22 7:16 ` domob at gcc dot gnu dot org
2008-08-22 7:18 ` domob 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).