public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug fortran/29389] New: Statement functions are not recognized as pure when they are
@ 2006-10-08 20:47 fxcoudert at gcc dot gnu dot org
2006-10-08 20:48 ` [Bug fortran/29389] " fxcoudert at gcc dot gnu dot org
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-10-08 20:47 UTC (permalink / raw)
To: gcc-bugs
The F95 standard says (12.6): "A pure procedure is [...] or (4) A statement
function that references only pure functions." But gfortran doesn't like that:
$ cat a5.f90
INTEGER :: st1,i,a(4)
st1(i)=i*i*i
FORALL(i=1:4) a(i)=st1(i)
print *, a
print *, u(2)
contains
pure integer function u(x)
integer,intent(in) :: x
st2(i) = i*i
u = st2(x)
end function
END
$ gfortran a5.f90
In file a5.f90:12
u = st2(x)
1
Error: Function reference to 'st2' at (1) is to a non-PURE procedure within a
PURE procedure
In file a5.f90:3
FORALL(i=1:4) a(i)=st1(i)
1
Error: reference to non-PURE function 'st1' at (1) inside a FORALL block
--
Summary: Statement functions are not recognized as pure when they
are
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Keywords: rejects-valid
Severity: normal
Priority: P3
Component: fortran
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fxcoudert at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
@ 2006-10-08 20:48 ` fxcoudert at gcc dot gnu dot org
2006-10-31 0:10 ` fxcoudert at gcc dot gnu dot org
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-10-08 20:48 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 |2006-10-08 20:47:53
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
2006-10-08 20:48 ` [Bug fortran/29389] " fxcoudert at gcc dot gnu dot org
@ 2006-10-31 0:10 ` fxcoudert at gcc dot gnu dot org
2006-12-31 7:39 ` pault at gcc dot gnu dot org
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: fxcoudert at gcc dot gnu dot org @ 2006-10-31 0:10 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from fxcoudert at gcc dot gnu dot org 2006-10-31 00:09 -------
Created an attachment (id=12516)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=12516&action=view)
Tentative patch
This patch doesn't work :)
It's working fine except that the following code:
implicit none
INTEGER :: st1,i,a(4)
st1(i)=i*i*g(i)
!FORALL(i=1:4) a(i)=st1(i)
print *, a
print *, u(2)
contains
pure integer function u(x)
integer :: st2, i
integer,intent(in) :: x
st2(i) = i*i
u = st2(x)
end function
pure integer function f(x)
integer,intent(in) :: x
f = x
end function
integer function g(x)
integer,intent(in) :: x
g = x
end function
end
gives the erroneous error message:
In file pr29389.f90:3
st1(i)=i*i*g(i)
1
Error: Function reference to 'g' at (1) is to a non-PURE procedure within a
PURE procedure
When the statement function is resolved, gfc_current_ns points to u. I don't
understand why.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
2006-10-08 20:48 ` [Bug fortran/29389] " fxcoudert at gcc dot gnu dot org
2006-10-31 0:10 ` fxcoudert at gcc dot gnu dot org
@ 2006-12-31 7:39 ` pault at gcc dot gnu dot org
2007-01-15 8:16 ` pault at gcc dot gnu dot org
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2006-12-31 7:39 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from pault at gcc dot gnu dot org 2006-12-31 07:39 -------
This is fixed by:
resolve.c:1429
static int
pure_function (gfc_expr * e, const char **name)
{
int pure;
/* This is the fix. */
if (e->expr_type == EXPR_FUNCTION
&& e->symtree->n.sym->attr.proc == PROC_ST_FUNCTION)
return 1;
if (e->value.function.esym)
The testcase should set i = 0 and test its value at the end of the main
program, in order to demonstrate that there are no side-effects.
Regtests OK on amd64/Cygwin_NT
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|2006-10-08 20:47:53 |2006-12-31 07:39:01
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (2 preceding siblings ...)
2006-12-31 7:39 ` pault at gcc dot gnu dot org
@ 2007-01-15 8:16 ` pault at gcc dot gnu dot org
2007-01-15 8:19 ` pault at gcc dot gnu dot org
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-01-15 8:16 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from pault at gcc dot gnu dot org 2007-01-15 08:16 -------
Subject: Bug 29389
Author: pault
Date: Mon Jan 15 08:16:17 2007
New Revision: 120790
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=120790
Log:
2007-01-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/28172
* trans-stmt.c (gfc_trans_call): If it does not have one, get
a backend_decl for an alternate return.
PR fortran/29389
* resolve.c (pure_function): Statement functions are pure. Note
that this will have to recurse to comply fully with F95.
PR fortran/29712
* resolve.c (resolve_function): Only a reference to the final
dimension of an assumed size array is an error in an inquiry
function.
PR fortran/30283
* resolve.c (resolve_function): Make sure that the function
expression has a type.
2007-01-15 Paul Thomas <pault@gcc.gnu.org>
PR fortran/28172
* gfortran.dg/altreturn_4.f90: New test.
PR fortran/29389
* gfortran.dg/stfunc_4.f90: New test.
PR fortran/29712
* gfortran.dg/bound_2.f90: Reinstate commented out line.
* gfortran.dg/initialization_1.f90: Change warning.
PR fortran/30283
* gfortran.dg/specification_type_resolution_2.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/altreturn_4.f90
trunk/gcc/testsuite/gfortran.dg/specification_type_resolution_2.f90
trunk/gcc/testsuite/gfortran.dg/stfunc_4.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/testsuite/ChangeLog
trunk/gcc/testsuite/gfortran.dg/bound_2.f90
trunk/gcc/testsuite/gfortran.dg/initialization_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (3 preceding siblings ...)
2007-01-15 8:16 ` pault at gcc dot gnu dot org
@ 2007-01-15 8:19 ` pault at gcc dot gnu dot org
2007-01-23 5:53 ` pault at gcc dot gnu dot org
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-01-15 8:19 UTC (permalink / raw)
To: gcc-bugs
------- Comment #4 from pault at gcc dot gnu dot org 2007-01-15 08:19 -------
> Author: pault
> Date: Mon Jan 15 08:16:17 2007
> New Revision: 120790
As pointed out by FX on the list, this patch does not quite do it yet:
The F95 standard says (12.6): "A pure procedure is [...] or (4) A statement
function that references only pure functions." Not all statement functions are
pure. Are you sure that check ("references only pure functions") is performed
by your patch?
I'll do this asap.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (4 preceding siblings ...)
2007-01-15 8:19 ` pault at gcc dot gnu dot org
@ 2007-01-23 5:53 ` pault at gcc dot gnu dot org
2007-01-23 5:56 ` pault at gcc dot gnu dot org
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-01-23 5:53 UTC (permalink / raw)
To: gcc-bugs
------- Comment #5 from pault at gcc dot gnu dot org 2007-01-23 05:53 -------
Subject: Bug 29389
Author: pault
Date: Tue Jan 23 05:53:14 2007
New Revision: 121077
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=121077
Log:
2007-01-23 Paul Thomas <pault@gcc.gnu.org>
Backports from trunk
PR fortran/28172
* trans-stmt.c (gfc_trans_call): If it does not have one, get
a backend_decl for an alternate return.
PR fortran/29389
* resolve.c (pure_function): Statement functions are pure. Note
that this will have to recurse to comply fully with F95.
PR fortran/29712
* resolve.c (resolve_function): Only a reference to the final
dimension of an assumed size array is an error in an inquiry
function.
PR fortran/30283
* resolve.c (resolve_function): Make sure that the function
expression has a type.
2007-01-23 Paul Thomas <pault@gcc.gnu.org>
PR fortran/28172
* gfortran.dg/altreturn_4.f90: New test.
PR fortran/29389
* gfortran.dg/stfunc_4.f90: New test.
PR fortran/29712
* gfortran.dg/bound_2.f90: Reinstate commented out line.
* gfortran.dg/initialization_1.f90: Change warning.
PR fortran/30283
* gfortran.dg/specification_type_resolution_2.f90: New test.
Added:
branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/altreturn_4.f90
branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/specification_type_resolution_2.f90
branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/stfunc_4.f90
Modified:
branches/gcc-4_2-branch/gcc/fortran/ChangeLog
branches/gcc-4_2-branch/gcc/fortran/resolve.c
branches/gcc-4_2-branch/gcc/fortran/trans-stmt.c
branches/gcc-4_2-branch/gcc/testsuite/ChangeLog
branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/bound_2.f90
branches/gcc-4_2-branch/gcc/testsuite/gfortran.dg/initialization_1.f90
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (5 preceding siblings ...)
2007-01-23 5:53 ` pault at gcc dot gnu dot org
@ 2007-01-23 5:56 ` pault at gcc dot gnu dot org
2007-07-04 6:29 ` jv244 at cam dot ac dot uk
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-01-23 5:56 UTC (permalink / raw)
To: gcc-bugs
------- Comment #6 from pault at gcc dot gnu dot org 2007-01-23 05:56 -------
Partially fixed - see list.
Paul
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (6 preceding siblings ...)
2007-01-23 5:56 ` pault at gcc dot gnu dot org
@ 2007-07-04 6:29 ` jv244 at cam dot ac dot uk
2007-11-27 20:48 ` pault at gcc dot gnu dot org
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: jv244 at cam dot ac dot uk @ 2007-07-04 6:29 UTC (permalink / raw)
To: gcc-bugs
------- Comment #7 from jv244 at cam dot ac dot uk 2007-07-04 06:29 -------
list link:
http://gcc.gnu.org/ml/fortran/2007-01/msg00361.html
this suggests that it is now an accepts-invalid bug with an easy fix
(Bug reporter / assignee should change keyword)
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (7 preceding siblings ...)
2007-07-04 6:29 ` jv244 at cam dot ac dot uk
@ 2007-11-27 20:48 ` pault at gcc dot gnu dot org
2007-11-27 20:52 ` pault at gcc dot gnu dot org
2008-09-06 17:00 ` dominiq at lps dot ens dot fr
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-11-27 20:48 UTC (permalink / raw)
To: gcc-bugs
------- Comment #8 from pault at gcc dot gnu dot org 2007-11-27 20:48 -------
Subject: Bug 29389
Author: pault
Date: Tue Nov 27 20:47:55 2007
New Revision: 130472
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=130472
Log:
2007-11-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29389
*resolve.c (resolve_ordinary_assign): Use find_sym_in_expr to
test if a temporary should be written for a vector subscript
on the lhs.
PR fortran/33850
* restore.c (pure_stmt_function): Add prototype and new
function. Calls impure_stmt_fcn.
(pure_function): Call it.
(impure_stmt_fcn): New function.
* expr.c (gfc_traverse_expr): Call *func for all expression
types, not just variables. Add traversal of character lengths,
iterators and component character lengths and arrayspecs.
(expr_set_symbols_referenced): Return false if not a variable.
* trans-stmt.c (forall_replace, forall_restore): Ditto.
* resolve.c (forall_index): Ditto.
(sym_in_expr): New function.
(find_sym_in_expr): Rewrite to traverse expression calling
sym_in_expr.
*trans-decl.c (expr_decls): New function.
(generate_expr_decls): Rewrite to traverse expression calling
expr_decls.
*match.c (check_stmt_fcn): New function.
(recursive_stmt_fcn): Rewrite to traverse expression calling
check_stmt_fcn.
2007-11-27 Paul Thomas <pault@gcc.gnu.org>
PR fortran/29389
* gfortran.dg/stfunc_6.f90: New test.
PR fortran/33850
* gfortran.dg/assign_10.f90: New test.
Added:
trunk/gcc/testsuite/gfortran.dg/assign_10.f90
trunk/gcc/testsuite/gfortran.dg/stfunc_6.f90
Modified:
trunk/gcc/fortran/ChangeLog
trunk/gcc/fortran/expr.c
trunk/gcc/fortran/match.c
trunk/gcc/fortran/resolve.c
trunk/gcc/fortran/trans-decl.c
trunk/gcc/fortran/trans-stmt.c
trunk/gcc/testsuite/ChangeLog
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (8 preceding siblings ...)
2007-11-27 20:48 ` pault at gcc dot gnu dot org
@ 2007-11-27 20:52 ` pault at gcc dot gnu dot org
2008-09-06 17:00 ` dominiq at lps dot ens dot fr
10 siblings, 0 replies; 12+ messages in thread
From: pault at gcc dot gnu dot org @ 2007-11-27 20:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #9 from pault at gcc dot gnu dot org 2007-11-27 20:52 -------
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=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Bug fortran/29389] Statement functions are not recognized as pure when they are
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
` (9 preceding siblings ...)
2007-11-27 20:52 ` pault at gcc dot gnu dot org
@ 2008-09-06 17:00 ` dominiq at lps dot ens dot fr
10 siblings, 0 replies; 12+ messages in thread
From: dominiq at lps dot ens dot fr @ 2008-09-06 17:00 UTC (permalink / raw)
To: gcc-bugs
------- Comment #10 from dominiq at lps dot ens dot fr 2008-09-06 16:58 -------
Note that before the patch for pr35837, the code in comment #1 was wrongly
rejected. This is now fixed by this patch. Also if the FORALL statement is this
code is uncommented, it is now accepted while it is invalid, see pr37398.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29389
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2008-09-06 17:00 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-08 20:47 [Bug fortran/29389] New: Statement functions are not recognized as pure when they are fxcoudert at gcc dot gnu dot org
2006-10-08 20:48 ` [Bug fortran/29389] " fxcoudert at gcc dot gnu dot org
2006-10-31 0:10 ` fxcoudert at gcc dot gnu dot org
2006-12-31 7:39 ` pault at gcc dot gnu dot org
2007-01-15 8:16 ` pault at gcc dot gnu dot org
2007-01-15 8:19 ` pault at gcc dot gnu dot org
2007-01-23 5:53 ` pault at gcc dot gnu dot org
2007-01-23 5:56 ` pault at gcc dot gnu dot org
2007-07-04 6:29 ` jv244 at cam dot ac dot uk
2007-11-27 20:48 ` pault at gcc dot gnu dot org
2007-11-27 20:52 ` pault at gcc dot gnu dot org
2008-09-06 17:00 ` dominiq at lps dot ens dot fr
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).