]> gcc.gnu.org Git - gcc.git/commitdiff
re PR fortran/40402 (Problem with data statement involving structure constructors...
authorPaul Thomas <pault@gcc.gnu.org>
Thu, 11 Jun 2009 20:11:59 +0000 (20:11 +0000)
committerPaul Thomas <pault@gcc.gnu.org>
Thu, 11 Jun 2009 20:11:59 +0000 (20:11 +0000)
2009-06-11  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/40402
* resolve.c (next_data_value): It is an error if the value is
not constant.

2009-06-11  Paul Thomas  <pault@gcc.gnu.org>

PR fortran/40402
* gfortran.dg/data_value_1.f90: New test.

From-SVN: r148396

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

index 1a2f41b24561ae4ba9a9cf1b1ac7f03aeb2f3413..2f0ff9dee8cc7b0b685afb3373c84d62c67fcdad 100644 (file)
@@ -1,3 +1,9 @@
+2009-06-11  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/40402
+       * resolve.c (next_data_value): It is an error if the value is
+       not constant.
+
 2009-06-11  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR fortran/38718
index 5bb38fec5772e34b5277ea4bbc010a054aee72ba..04e03cc659b6c6ca9e9e3943bb3b7a09903ea6e3 100644 (file)
@@ -9852,9 +9852,12 @@ values;
 static gfc_try
 next_data_value (void)
 {
-
   while (mpz_cmp_ui (values.left, 0) == 0)
     {
+      if (!gfc_is_constant_expr (values.vnode->expr))
+       gfc_error ("non-constant DATA value at %L",
+                  &values.vnode->expr->where);
+
       if (values.vnode->next == NULL)
        return FAILURE;
 
index 9a36badabe4814c58049d96db1a3964490236017..d49243f41d58d7684d2ce56be852a97ba1280e89 100644 (file)
@@ -1,3 +1,8 @@
+2009-06-11  Paul Thomas  <pault@gcc.gnu.org>
+
+       PR fortran/40402
+       * gfortran.dg/data_value_1.f90: New test.
+
 2009-06-11  Francois-Xavier Coudert  <fxcoudert@gcc.gnu.org>
 
        PR testsuite/39831
diff --git a/gcc/testsuite/gfortran.dg/data_value_1.f90 b/gcc/testsuite/gfortran.dg/data_value_1.f90
new file mode 100644 (file)
index 0000000..ea05a91
--- /dev/null
@@ -0,0 +1,14 @@
+! { dg-do compile }
+! Test the fix for PR40402, in which it was not detected that X
+! is not a constant and so the DATA statement did not have
+! a constant value expression.
+!
+! Contributed by Philippe Marguinaud <philippe.marguinaud@meteo.fr>
+!
+      TYPE POINT
+        REAL :: X 
+      ENDTYPE
+      TYPE(POINT) :: P
+      DATA P / POINT(1.+X) / ! { dg-error "non-constant DATA value" }
+      print *, p
+      END
This page took 0.102411 seconds and 5 git commands to generate.