public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/30876] New: incorrect error message for valid code
@ 2007-02-20 7:52 jv244 at cam dot ac dot uk
2007-02-20 16:28 ` [Bug fortran/30876] Array valued recursive function rejected burnus at gcc dot gnu dot org
` (11 more replies)
0 siblings, 12 replies; 13+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-02-20 7:52 UTC (permalink / raw)
To: gcc-bugs
With recent trunk, gfortran incorrectly generates an error for the following
standard code:
MODULE M1
CONTAINS
FUNCTION correct_input(i)
INTEGER :: i,correct_input(5)
IF (i<1) correct_input=test(1)
IF (i>5) correct_input=test(5)
END FUNCTION correct_input
RECURSIVE FUNCTION test(i)
INTEGER :: test(5),i,j
IF (i<1 .OR. i>5) THEN
test=correct_input(i)
ELSE
test=0
test(1:6-i)=(/(j,j=i,5)/)
test=test(3)
ENDIF
END FUNCTION
END MODULE M1
USE M1
IF (ANY(TEST(3).NE.(/5,5,5,5,5/))) CALL ABORT()
IF (ANY(TEST(6).NE.(/0,0,0,0,0/))) CALL ABORT()
END
--
Summary: incorrect error message for valid code
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jv244 at cam dot ac dot uk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
@ 2007-02-20 16:28 ` burnus at gcc dot gnu dot org
2007-02-21 16:33 ` pault at gcc dot gnu dot org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-20 16:28 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from burnus at gcc dot gnu dot org 2007-02-20 16:28 -------
Compiles with nagf95 and g95.
ifort and gfortran give however the following error messages:
test=test(3)
1
Error: 'test' is array valued and directly recursive at (1) , so the keyword
RESULT must be specified in the FUNCTION statement
and
fortcom: Warning: dtgv.f90, line 9: Recursive array-valued function without
result variable ambiguous [TEST]
RECURSIVE FUNCTION test(i)
--------------------^
fortcom: Error: dtgv.f90, line 15: A recursive function name must not be used
in this context. [TEST]
test(1:6-i)=(/(j,j=i,5)/)
----^
fortcom: Error: dtgv.f90, line 15: A colon (:) is not valid in this context.
[1]
test(1:6-i)=(/(j,j=i,5)/)
---------^
--
burnus at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |burnus at gcc dot gnu dot
| |org
Keywords| |rejects-valid
Summary|incorrect error message for |Array valued recursive
|valid code |function rejected
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
2007-02-20 16:28 ` [Bug fortran/30876] Array valued recursive function rejected burnus at gcc dot gnu dot org
@ 2007-02-21 16:33 ` pault at gcc dot gnu dot org
2007-02-21 17:03 ` burnus at gcc dot gnu dot org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-21 16:33 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2007-02-21 16:33 -------
> fortcom: Warning: dtgv.f90, line 9: Recursive array-valued function without
> result variable ambiguous [TEST]
Goes right to the nub of it. Within test, is an r-value expression that
contains a reference to test (<int_expr>) a reference to the function result
array or a recursive call to test?
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
2007-02-20 16:28 ` [Bug fortran/30876] Array valued recursive function rejected burnus at gcc dot gnu dot org
2007-02-21 16:33 ` pault at gcc dot gnu dot org
@ 2007-02-21 17:03 ` burnus at gcc dot gnu dot org
2007-02-21 18:52 ` pault at gcc dot gnu dot org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-02-21 17:03 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from burnus at gcc dot gnu dot org 2007-02-21 17:03 -------
Paul,
> > fortcom: Warning: dtgv.f90, line 9: Recursive array-valued function without
> > result variable ambiguous [TEST]
> Goes right to the nub of it. Within test, is an r-value expression that
> contains a reference to test (<int_expr>) a reference to the function result
> array or a recursive call to test?
Well, it is easy:
"12.5.2.1 Function subprogram"
"If RESULT is not specified, the result variable is <function- name> and all
occurrences of the function name in execution-part statements are references to
the result variable."
See also:
http://gcc.gnu.org/ml/fortran/2006-05/msg00342.html
--
burnus 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-02-21 17:03:09
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (2 preceding siblings ...)
2007-02-21 17:03 ` burnus at gcc dot gnu dot org
@ 2007-02-21 18:52 ` pault at gcc dot gnu dot org
2007-03-22 0:22 ` fxcoudert at gcc dot gnu dot org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-02-21 18:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2007-02-21 18:52 -------
Tobias,
> Well, it is easy:
> "12.5.2.1 Function subprogram"
> "If RESULT is not specified, the result variable is <function- name> and all
> occurrences of the function name in execution-part statements are references to
> the result variable."
Ahhhh! OK, thanks - I can feel a patch coming on.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (3 preceding siblings ...)
2007-02-21 18:52 ` pault at gcc dot gnu dot org
@ 2007-03-22 0:22 ` fxcoudert at gcc dot gnu dot org
2007-03-22 7:41 ` burnus at gcc dot gnu dot org
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2007-03-22 0:22 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from fxcoudert at gcc dot gnu dot org 2007-03-22 00:22 -------
(In reply to comment #3)
> "12.5.2.1 Function subprogram"
> "If RESULT is not specified, the result variable is <function- name> and all
> occurrences of the function name in execution-part statements are references to
> the result variable."
Then, the following should be invalid and rejected, shouldn't it?
recursive function f(i)
integer :: f, i
f = 0
if (i > 0) f = f(i-1) + 1
end function
If every occurence of f is a reference to the variable result, it's strictly
equivalent to the following, clearly invalid code:
recursive function f(i) result(g)
integer :: g, i
g = 0
if (i > 0) g = g(i-1) + 1
end function
--
fxcoudert at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fxcoudert at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (4 preceding siblings ...)
2007-03-22 0:22 ` fxcoudert at gcc dot gnu dot org
@ 2007-03-22 7:41 ` burnus at gcc dot gnu dot org
2007-05-08 12:51 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: burnus at gcc dot gnu dot org @ 2007-03-22 7:41 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from burnus at gcc dot gnu dot org 2007-03-22 07:41 -------
(In reply to comment #5)
> Then, the following should be invalid and rejected, shouldn't it?
> recursive function f(i)
> integer :: f, i
> f = 0
> if (i > 0) f = f(i-1) + 1
> end function
NAG f95:
line 4: Recursive invocation of F which has no RESULT clause
(gfortran and ifort allow this)
> recursive function f(i) result(g)
> integer :: g, i
> g = 0
> if (i > 0) g = g(i-1) + 1
> end function
NAG f95: Inconsistent usage of G
ifort: This name has not been declared as an array or a function
gfortran: Cannot assign to a named constant
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (5 preceding siblings ...)
2007-03-22 7:41 ` burnus at gcc dot gnu dot org
@ 2007-05-08 12:51 ` pault at gcc dot gnu dot org
2007-05-08 12:52 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-08 12:51 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from pault at gcc dot gnu dot org 2007-05-08 13:51 -------
I'll submit a fix tonight.
Paul
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (6 preceding siblings ...)
2007-05-08 12:51 ` pault at gcc dot gnu dot org
@ 2007-05-08 12:52 ` pault at gcc dot gnu dot org
2007-05-08 12:53 ` pault at gcc dot gnu dot org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-08 12:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2007-05-08 13:52 -------
Oops!
--
pault at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
Resolution|FIXED |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (7 preceding siblings ...)
2007-05-08 12:52 ` pault at gcc dot gnu dot org
@ 2007-05-08 12:53 ` pault at gcc dot gnu dot org
2007-05-10 7:14 ` patchapp at dberlin dot org
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-08 12:53 UTC (permalink / raw)
To: gcc-bugs
--
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|REOPENED |ASSIGNED
Last reconfirmed|2007-02-21 17:03:09 |2007-05-08 13:53:03
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (8 preceding siblings ...)
2007-05-08 12:53 ` pault at gcc dot gnu dot org
@ 2007-05-10 7:14 ` patchapp at dberlin dot org
2007-05-11 11:47 ` pault at gcc dot gnu dot org
2007-05-11 11:47 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: patchapp at dberlin dot org @ 2007-05-10 7:14 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from patchapp at dberlin dot org 2007-05-10 08:13 -------
Subject: Bug number Pr30876
A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2007-05/msg00579.html
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (9 preceding siblings ...)
2007-05-10 7:14 ` patchapp at dberlin dot org
@ 2007-05-11 11:47 ` pault at gcc dot gnu dot org
2007-05-11 11:47 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-11 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from pault at gcc dot gnu dot org 2007-05-11 12:47 -------
Subject: Bug 30876
Author: pault
Date: Fri May 11 11:46:47 2007
New Revision: 124616
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124616
Log:
2007-05-11 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30876
* trans-expr.c (gfc_conv_function_call): Reduce indirection for
direct assignments of recursive array valued functions.
* primary.c (gfc_match_rvalue): Correct error for recursive
function calls such that directly recursive calls of scalar
function without an explicit result are disallowed.
2007-05-11 Paul Thomas <pault@gcc.gnu.org>
PR fortran/30876
* gfortran.dg/recursive_reference_1.f90: Put error at correct
line.
* gfortran.dg/recursive_reference_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/recursive_reference_2.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/primary.c
trunk/gcc/fortran/trans-expr.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/recursive_reference_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug fortran/30876] Array valued recursive function rejected
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
` (10 preceding siblings ...)
2007-05-11 11:47 ` pault at gcc dot gnu dot org
@ 2007-05-11 11:47 ` pault at gcc dot gnu dot org
11 siblings, 0 replies; 13+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-05-11 11:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #11 from pault at gcc dot gnu dot org 2007-05-11 12:47 -------
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=30876
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2007-05-11 11:47 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-20 7:52 [Bug fortran/30876] New: incorrect error message for valid code jv244 at cam dot ac dot uk
2007-02-20 16:28 ` [Bug fortran/30876] Array valued recursive function rejected burnus at gcc dot gnu dot org
2007-02-21 16:33 ` pault at gcc dot gnu dot org
2007-02-21 17:03 ` burnus at gcc dot gnu dot org
2007-02-21 18:52 ` pault at gcc dot gnu dot org
2007-03-22 0:22 ` fxcoudert at gcc dot gnu dot org
2007-03-22 7:41 ` burnus at gcc dot gnu dot org
2007-05-08 12:51 ` pault at gcc dot gnu dot org
2007-05-08 12:52 ` pault at gcc dot gnu dot org
2007-05-08 12:53 ` pault at gcc dot gnu dot org
2007-05-10 7:14 ` patchapp at dberlin dot org
2007-05-11 11:47 ` pault at gcc dot gnu dot org
2007-05-11 11:47 ` 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).