re PR fortran/13826 (Derived types in DATA statements not PARAMETERs)
authorTobias Schlüter <tobias.schlueter@physik.uni-muenchen.de>
Sat, 15 May 2004 18:02:20 +0000 (20:02 +0200)
committerTobias Schlüter <tobi@gcc.gnu.org>
Sat, 15 May 2004 18:02:20 +0000 (20:02 +0200)
fortran:
PR fortran/13826
* primary.c (match_structure_constructor): Rename ...
(gfc_match_structure_constructor): ... to this. Make non-static.
(gfc_match_rvalue): Call renamed function.
* match.h (gfc_match_structure_constructor): Declare.
* match.c (gfc_match_data_constant): Handle structure
constructor.

testsuite:
PR fortran/13826
* gfortran.fortran-torture/compile/data_1.f90: New test.

From-SVN: r81891

gcc/fortran/ChangeLog
gcc/fortran/match.c
gcc/fortran/match.h
gcc/fortran/primary.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.fortran-torture/compile/data_1.f90 [new file with mode: 0644]

index a1542b5db3ef256b0ec1420cab0992950bfdd4d7..16ea4470998b03db8e1c78b7f15de721d45c82fc 100644 (file)
@@ -1,3 +1,13 @@
+2004-05-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/13826
+       * primary.c (match_structure_constructor): Rename ...
+       (gfc_match_structure_constructor): ... to this. Make non-static.
+       (gfc_match_rvalue): Call renamed function.
+       * match.h (gfc_match_structure_constructor): Declare.
+       * match.c (gfc_match_data_constant): Handle structure
+       constructor.
+
 2004-05-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        PR fortran/13702 
@@ -47,7 +57,6 @@
        preprocessor flags.
        (all): Add missing initializers.
 
-
 2004-05-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
 
        * Make-lang.in (trans-common.o): Remove redundant dependency.
index dc8dc3e73335fcec353d0b92f6cd040c5ad8b79a..1b2b763013e28cbbad4ee67d698655070495d659 100644 (file)
@@ -2907,12 +2907,15 @@ match_data_constant (gfc_expr ** result)
   if (gfc_find_symbol (name, NULL, 1, &sym))
     return MATCH_ERROR;
 
-  if (sym == NULL || sym->attr.flavor != FL_PARAMETER)
+  if (sym == NULL
+      || (sym->attr.flavor != FL_PARAMETER && sym->attr.flavor != FL_DERIVED))
     {
       gfc_error ("Symbol '%s' must be a PARAMETER in DATA statement at %C",
                 name);
       return MATCH_ERROR;
     }
+  else if (sym->attr.flavor == FL_DERIVED)
+    return gfc_match_structure_constructor (sym, result);
 
   *result = gfc_copy_expr (sym->value);
   return MATCH_YES;
index 25e551caa6c6de21ff0e3c9e657c73c6a1c48606..6cff5cc0aa0c562e8caf189403928816ced8ad3a 100644 (file)
@@ -120,6 +120,7 @@ match gfc_match_modproc (void);
 match gfc_match_target (void);
 
 /* primary.c */
+match gfc_match_structure_constructor (gfc_symbol *, gfc_expr **);
 match gfc_match_rvalue (gfc_expr **);
 match gfc_match_variable (gfc_expr **, int);
 match gfc_match_actual_arglist (int, gfc_actual_arglist **);
index 03e975776ea816bd7a4d9a69a3aed91c3355b1fd..d10a46244e9f37950c6e3c6ae816d063475a1002 100644 (file)
@@ -1747,8 +1747,8 @@ gfc_expr_attr (gfc_expr * e)
 /* Match a structure constructor.  The initial symbol has already been
    seen.  */
 
-static match
-match_structure_constructor (gfc_symbol * sym, gfc_expr ** result)
+match
+gfc_match_structure_constructor (gfc_symbol * sym, gfc_expr ** result)
 {
   gfc_constructor *head, *tail;
   gfc_component *comp;
@@ -1908,7 +1908,7 @@ gfc_match_rvalue (gfc_expr ** result)
       if (sym == NULL)
        m = MATCH_ERROR;
       else
-        m = match_structure_constructor (sym, &e);
+        m = gfc_match_structure_constructor (sym, &e);
       break;
 
     /* If we're here, then the name is known to be the name of a
index 0f1ec72238c6a39f81f6c4049873d1639b93ad73..d23aed287c8bf11087cbeda029647fa31ea4c086 100644 (file)
@@ -1,3 +1,8 @@
+2004-05-15  Tobias Schlueter  <tobias.schlueter@physik.uni-muenchen.de>
+
+       PR fortran/13826
+       * gfortran.fortran-torture/compile/data_1.f90: New test.
+
 2004-05-15  Ulrich Weigand  <uweigand@de.ibm.com>
 
        * gcc.dg/const-elim-1.c: Remove XFAIL for s390*-*-*.
diff --git a/gcc/testsuite/gfortran.fortran-torture/compile/data_1.f90 b/gcc/testsuite/gfortran.fortran-torture/compile/data_1.f90
new file mode 100644 (file)
index 0000000..fa8ab9f
--- /dev/null
@@ -0,0 +1,7 @@
+! this tests the fix for PR 13826
+TYPE a
+   REAL x
+END TYPE
+TYPE(a) :: y
+DATA y /a(1.)/ ! used to give an error about non-PARAMETER
+END