[gfortran] PR 13628: derived type constructor not recognized in DATA

Tobias Schlüter tobias.schlueter@physik.uni-muenchen.de
Tue May 11 19:31:00 GMT 2004


We didn't allow a structure constructor in data constants. This 
straightforward patch fixes that. Compile test attached.

Compiled and regtested.

- Tobi

2004-05-11  Tobias Schlüter <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.

Index: match.h
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/Attic/match.h,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 match.h
--- match.h     2 Aug 2003 00:26:48 -0000       1.1.2.2
+++ match.h     11 May 2004 18:47:21 -0000
@@ -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: match.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/Attic/match.c,v
retrieving revision 1.1.2.8
diff -u -p -r1.1.2.8 match.c
--- match.c     11 Jan 2004 15:21:50 -0000      1.1.2.8
+++ match.c     11 May 2004 18:47:27 -0000
@@ -2915,12 +2933,16 @@ match_data_constant (gfc_expr ** result)
    if (gfc_find_symbol (name, NULL, 1, &sym))
      return MATCH_ERROR;

-  if (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",
-                sym->name);
+                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: primary.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/fortran/Attic/primary.c,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 primary.c
--- primary.c   12 Dec 2003 12:47:08 -0000      1.1.2.4
+++ primary.c   11 May 2004 18:47:35 -0000
@@ -1735,8 +1749,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;
@@ -1896,7 +1910,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

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: data.f90
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20040511/9f1ecc06/attachment.f90>


More information about the Gcc-patches mailing list