public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo()
@ 2007-12-11 9:53 burnus at gcc dot gnu dot org
2007-12-11 11:09 ` [Bug fortran/34429] " jv244 at cam dot ac dot uk
` (9 more replies)
0 siblings, 10 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-12-11 9:53 UTC (permalink / raw)
To: gcc-bugs
I believe the following program is valid; it is compiled by g95, ifort, NAG
f95, but gfortran rejects it with:
Error: Expression at (1) must be of INTEGER type
For the for KIND we had a similar problem, see
PR fortran/31154
PR fortran/31229
PR fortran/33334
and PR 34254
module m
integer, parameter :: strlen = 5
end module m
character(strlen) function test()
use m
test = 'A'
end function test
--
Summary: Fails: character(len=use_associated_const) function
foo()
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: burnus at gcc dot gnu dot org
OtherBugsDependingO 32834
nThis:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
@ 2007-12-11 11:09 ` jv244 at cam dot ac dot uk
2008-01-08 13:09 ` pault at gcc dot gnu dot org
` (8 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-12-11 11:09 UTC (permalink / raw)
To: gcc-bugs
--
jv244 at cam dot ac dot uk changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed|0 |1
Last reconfirmed|0000-00-00 00:00:00 |2007-12-11 11:09:22
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
2007-12-11 11:09 ` [Bug fortran/34429] " jv244 at cam dot ac dot uk
@ 2008-01-08 13:09 ` pault at gcc dot gnu dot org
2008-01-17 8:18 ` pault at gcc dot gnu dot org
` (7 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-08 13:09 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from pault at gcc dot gnu dot org 2008-01-08 12:57 -------
This is fixed in a patch that I am working on that sorts out the whole business
of function characteristics in one go.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |pault at gcc dot gnu dot org
|dot org |
Status|NEW |ASSIGNED
Last reconfirmed|2007-12-11 11:09:22 |2008-01-08 12:57:15
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
2007-12-11 11:09 ` [Bug fortran/34429] " jv244 at cam dot ac dot uk
2008-01-08 13:09 ` pault at gcc dot gnu dot org
@ 2008-01-17 8:18 ` pault at gcc dot gnu dot org
2008-01-17 10:53 ` pault at gcc dot gnu dot org
` (6 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-17 8:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2008-01-17 07:19 -------
Subject: Bug 34429
Author: pault
Date: Thu Jan 17 07:19:04 2008
New Revision: 131592
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131592
Log:
2008-01-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34429
PR fortran/34431
PR fortran/34471
* decl.c : Remove gfc_function_kind_locus and
gfc_function_type_locus. Add gfc_matching_function.
(match_char_length): If matching a function and the length
does not match, return MATCH_YES and try again later.
(gfc_match_kind_spec): The same.
(match_char_kind): The same.
(gfc_match_type_spec): The same for numeric and derived types.
(match_prefix): Rename as gfc_match_prefix.
(gfc_match_function_decl): Except for function valued character
lengths, defer applying kind, type and charlen info until the
end of specification block.
gfortran.h (gfc_statement): Add ST_GET_FCN_CHARACTERISTICS.
parse.c (decode_specification_statement): New function.
(decode_statement): Call it when a function has kind = -1. Set
and reset gfc_matching function, as function statement is being
matched.
(match_deferred_characteristics): Simplify with a single call
to gfc_match_prefix. Do appropriate error handling. In any
case, make sure that kind = -1 is reset or corrected.
(parse_spec): Call above on seeing ST_GET_FCN_CHARACTERISTICS.
Throw an error if kind = -1 after last specification statement.
parse.h : Prototype for gfc_match_prefix.
2008-01-17 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34429
* gfortran.dg/function_charlen_1.f90: New test.
PR fortran/34431
* gfortran.dg/function_types_1.f90: New test.
* gfortran.dg/function_types_2.f90: New test.
PR fortran/34471
* gfortran.dg/function_kinds_4.f90: New test.
* gfortran.dg/function_kinds_5.f90: New test.
* gfortran.dg/defined_operators_1.f90: Errors now at function
declarations.
* gfortran.dg/private_type_4.f90: The same.
* gfortran.dg/interface_15.f90: The same.
* gfortran.dg/elemental_args_check_2.f90: The same.
* gfortran.dg/auto_internal_assumed.f90: The same.
Added:
trunk/gcc/testsuite/gfortran.dg/function_charlen_1.f90
trunk/gcc/testsuite/gfortran.dg/function_kinds_4.f90
trunk/gcc/testsuite/gfortran.dg/function_kinds_5.f90
trunk/gcc/testsuite/gfortran.dg/function_types_1.f90
trunk/gcc/testsuite/gfortran.dg/function_types_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/misc.c
trunk/gcc/fortran/parse.c
trunk/gcc/fortran/parse.h
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/auto_internal_assumed.f90
trunk/gcc/testsuite/gfortran.dg/defined_operators_1.f90
trunk/gcc/testsuite/gfortran.dg/elemental_args_check_2.f90
trunk/gcc/testsuite/gfortran.dg/interface_15.f90
trunk/gcc/testsuite/gfortran.dg/private_type_4.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (2 preceding siblings ...)
2008-01-17 8:18 ` pault at gcc dot gnu dot org
@ 2008-01-17 10:53 ` pault at gcc dot gnu dot org
2008-01-17 17:56 ` burnus at gcc dot gnu dot org
` (5 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-17 10:53 UTC (permalink / raw)
To: gcc-bugs
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1505 bytes --]
------- Comment #3 from pault at gcc dot gnu dot org 2008-01-17 10:12 -------
Fixed on trunk - see below for some remaining wrinkles, dug up by Tobias. I
will keep this pR open until both are fixed.
Paul
wrinkle #1: This one is easily fixed.
Index: gcc/fortran/decl.c
===================================================================
--- gcc/fortran/decl.c (révision 131592)
+++ gcc/fortran/decl.c (copie de travail)
@@ -2156,6 +2156,7 @@
after the specification statements. */
if (gfc_matching_function
&& !(len && len->expr_type != EXPR_VARIABLE
+ && len->expr_type != EXPR_CONSTANT
&& len->expr_type != EXPR_OP))
{
gfc_undo_symbols ();
module m
integer, parameter :: l = 2
end module m
program test
implicit none
integer, parameter :: l = 5
character(len=10) :: c
c = f()
contains
character(len=l) function f()
use m
print *, len(f)
! if (len(f) /= 2) call abort ! gives 5 right now...
f = "a"
end function f
end program test
! { dg-final { cleanup-modules "m" } }
wrinkle #2: This one is proving to be a bit recalcitrant.
module m
character(2) :: l
end module m
implicit none
! character(4) :: l
print *, f()
contains
character(len=len(l)) function f()
use m
f = "4"
if (len(f)==2) f= "2"
end function f
end
where 'l' is found to be ambiguous; this must arise because the first match of
the length is leaving the symbol intact.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (3 preceding siblings ...)
2008-01-17 10:53 ` pault at gcc dot gnu dot org
@ 2008-01-17 17:56 ` burnus at gcc dot gnu dot org
2008-01-17 18:02 ` dominiq at lps dot ens dot fr
` (4 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-17 17:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from burnus at gcc dot gnu dot org 2008-01-17 17:26 -------
For cross reference the commit patch was:
http://gcc.gnu.org/ml/fortran/2008-01/msg00197.html
Besides the previously mentioned problems, there is also the following:
gfc_clear_ts (gfc_typespec *ts)
[...]
+ if (ts->kind != -1)
+ ts->kind = 0;
This causes a problem if *ts is uninitalized, which happens for instance in
intrinsic.c's add_conv:
gfc_typespec from, to;
[...]
gfc_clear_ts (&from);
Assume now that the uninitialized memory contains "-1" ...
(Found using valgrind which has dozens of warnings of the type "jump depends on
uninitialized memory".)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (4 preceding siblings ...)
2008-01-17 17:56 ` burnus at gcc dot gnu dot org
@ 2008-01-17 18:02 ` dominiq at lps dot ens dot fr
2008-01-17 18:19 ` burnus at gcc dot gnu dot org
` (3 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-01-17 18:02 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from dominiq at lps dot ens dot fr 2008-01-17 17:49 -------
>From comment #4:
+ if (ts->kind != -1)
+ ts->kind = 0;
I think this has been removed in the commit. However if you had it, it is not
removed by svn update
(I had to remove it manually).
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (5 preceding siblings ...)
2008-01-17 18:02 ` dominiq at lps dot ens dot fr
@ 2008-01-17 18:19 ` burnus at gcc dot gnu dot org
2008-01-17 22:32 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
9 siblings, 0 replies; 11+ messages in thread
From: burnus at gcc dot gnu dot org @ 2008-01-17 18:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2008-01-17 18:07 -------
> + if (ts->kind != -1)
> I think this has been removed in the commit.
Indeed. Thanks for the check, Dominique. Thus: Ignore that comment.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (6 preceding siblings ...)
2008-01-17 18:19 ` burnus at gcc dot gnu dot org
@ 2008-01-17 22:32 ` pault at gcc dot gnu dot org
2008-01-30 8:44 ` pault at gcc dot gnu dot org
2008-01-30 9:53 ` pault at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-17 22:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2008-01-17 22:09 -------
(In reply to comment #6)
> > + if (ts->kind != -1)
> > I think this has been removed in the commit.
> Indeed. Thanks for the check, Dominique. Thus: Ignore that comment.
Gents,
I tried to deal with the useful comment about branching on kind = -1. I have
used the somewhat brutal device that you will now find in the tree.
Cheers
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (7 preceding siblings ...)
2008-01-17 22:32 ` pault at gcc dot gnu dot org
@ 2008-01-30 8:44 ` pault at gcc dot gnu dot org
2008-01-30 9:53 ` pault at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-30 8:44 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2008-01-30 06:56 -------
Subject: Bug 34429
Author: pault
Date: Wed Jan 30 06:56:10 2008
New Revision: 131956
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=131956
Log:
2008-01-30 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34975
* symbol.c (gfc_delete_symtree, gfc_undo_symbols): Rename
delete_symtree to gfc_delete_symtree.
* gfortran.h : Add prototype for gfc_delete_symtree.
* module.c (load_generic_interfaces): Transfer symbol to a
unique symtree and delete old symtree, instead of renaming.
(read_module): The rsym and the found symbol are the same, so
the found symtree can be deleted.
PR fortran/34429
* decl.c (match_char_spec): Remove the constraint on deferred
matching of functions and free the length expression.
delete_symtree to gfc_delete_symtree.
(gfc_match_type_spec): Whitespace.
(gfc_match_function_decl): Defer characteristic association for
all types except BT_UNKNOWN.
* parse.c (decode_specification_statement): Only derived type
function matching is delayed to the end of specification.
2008-01-30 Paul Thomas <pault@gcc.gnu.org>
PR fortran/34975
* gfortran.dg/use_only_3.f90: New test.
* gfortran.dg/use_only_3.inc: Modules for new test.
PR fortran/34429
* gfortran.dg/function_charlen_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/function_charlen_2.f90
trunk/gcc/testsuite/gfortran.dg/use_only_3.f90
trunk/gcc/testsuite/gfortran.dg/use_only_3.inc
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/decl.c
trunk/gcc/fortran/gfortran.h
trunk/gcc/fortran/module.c
trunk/gcc/fortran/parse.c
trunk/gcc/fortran/symbol.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
* [Bug fortran/34429] Fails: character(len=use_associated_const) function foo()
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
` (8 preceding siblings ...)
2008-01-30 8:44 ` pault at gcc dot gnu dot org
@ 2008-01-30 9:53 ` pault at gcc dot gnu dot org
9 siblings, 0 replies; 11+ messages in thread
From: pault at gcc dot gnu dot org @ 2008-01-30 9:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2008-01-30 07:03 -------
Fixed on trunk
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34429
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2008-01-30 7:04 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-12-11 9:53 [Bug fortran/34429] New: Fails: character(len=use_associated_const) function foo() burnus at gcc dot gnu dot org
2007-12-11 11:09 ` [Bug fortran/34429] " jv244 at cam dot ac dot uk
2008-01-08 13:09 ` pault at gcc dot gnu dot org
2008-01-17 8:18 ` pault at gcc dot gnu dot org
2008-01-17 10:53 ` pault at gcc dot gnu dot org
2008-01-17 17:56 ` burnus at gcc dot gnu dot org
2008-01-17 18:02 ` dominiq at lps dot ens dot fr
2008-01-17 18:19 ` burnus at gcc dot gnu dot org
2008-01-17 22:32 ` pault at gcc dot gnu dot org
2008-01-30 8:44 ` pault at gcc dot gnu dot org
2008-01-30 9:53 ` pault 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).