OSDN Git Service

2006-12-04 Paul Thomas <pault@gcc.gnu.org>
authorpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Dec 2006 19:30:33 +0000 (19:30 +0000)
committerpault <pault@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 4 Dec 2006 19:30:33 +0000 (19:30 +0000)
PR fortran/29821
* resolve.c (resolve_operator): Only return result of
gfc_simplify_expr if expression is constant.

2006-12-04  Paul  Thomas <pault@gcc.gnu.org>

PR fortran/29821
* gfortran.dg/parameter_array_section_1.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@119504 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/resolve.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/parameter_array_section_1.f90 [new file with mode: 0644]

index 5dad677..2ce1ec6 100644 (file)
@@ -1,5 +1,11 @@
 2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
 
+       PR fortran/29821
+       * resolve.c (resolve_operator): Only return result of
+       gfc_simplify_expr if expression is constant.
+
+2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
+
        PR fortran/29916
        * resolve.c (resolve_symbol): Allow host-associated variables
          the specification expression of an array-valued function.
index 75a6ca3..e31ecbd 100644 (file)
@@ -2191,7 +2191,14 @@ resolve_operator (gfc_expr * e)
 
   /* Attempt to simplify the expression.  */
   if (t == SUCCESS)
-    t = gfc_simplify_expr (e, 0);
+    {
+      t = gfc_simplify_expr (e, 0);
+      /* Some calls do not succeed in simplification and return FAILURE
+        even though there is no error; eg. variable references to
+        PARAMETER arrays.  */
+      if (!gfc_is_constant_expr (e))
+       t = SUCCESS;
+    }
   return t;
 
 bad_op:
index 0d55808..a0c4f78 100644 (file)
@@ -1,3 +1,8 @@
+2006-12-04  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/29821
+       * gfortran.dg/parameter_array_section_1.f90: New test.
+
 2006-12-04  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/29733
diff --git a/gcc/testsuite/gfortran.dg/parameter_array_section_1.f90 b/gcc/testsuite/gfortran.dg/parameter_array_section_1.f90
new file mode 100644 (file)
index 0000000..6c69593
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do compile }
+! Tests the fix for PR29821, which was due to failure to simplify the
+! array section, since the section is not constant, provoking failure
+! to resolve the argument of SUM and therefore to resolve SUM itself.
+!
+! Contributed by Harald Anlauf  <anlauf@gmx.de>
+!
+module gfcbug45
+  implicit none
+contains
+  subroutine foo 
+    real, external :: mysum
+    integer :: i
+    real    :: a
+    real, parameter :: eps(2) = (/ 1, 99 /)
+    i = 1
+    a = sum (eps(i:i+1) * eps)
+    print *, a
+  end subroutine foo
+end module gfcbug45
+  use gfcbug45
+  call foo
+end
+! { dg-final { cleanup-modules "gfcbug45" } }