[Bug fortran/30876] Array valued recursive function rejected

2007-05-11 Thread pault at gcc dot gnu dot org


--- 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=gccview=revrev=124616
Log:
2007-05-11 Paul Thomas [EMAIL PROTECTED]

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 [EMAIL PROTECTED]

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



[Bug fortran/30876] Array valued recursive function rejected

2007-05-11 Thread pault at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-05-10 Thread patchapp at dberlin dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-05-08 Thread pault at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-05-08 Thread pault at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-05-08 Thread pault at gcc dot gnu dot org


-- 

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



[Bug fortran/30876] Array valued recursive function rejected

2007-03-22 Thread burnus at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-03-21 Thread fxcoudert at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-02-21 Thread pault at gcc dot gnu dot org


--- 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



[Bug fortran/30876] Array valued recursive function rejected

2007-02-21 Thread burnus at gcc dot gnu dot org


--- 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|-00-00 00:00:00 |2007-02-21 17:03:09
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876



[Bug fortran/30876] Array valued recursive function rejected

2007-02-21 Thread pault at gcc dot gnu dot org


--- 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.

A! OK, thanks - I can feel a patch coming on.

Paul


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30876



[Bug fortran/30876] Array valued recursive function rejected

2007-02-20 Thread burnus at gcc dot gnu dot org


--- 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