public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [patch, fortran]  [4.5/4.4 Regression]  data statement with nested  type constructors
@ 2009-11-26 14:16 Jerry DeLisle
  0 siblings, 0 replies; only message in thread
From: Jerry DeLisle @ 2009-11-26 14:16 UTC (permalink / raw)
  To: gfortran, gcc patches

Hi folks,

Attempting to backport the simple patch from mainline to 4.4 revealed a problem 
downstream reulting in a segfault.  The issue is that the error I am giving on 
the invalid code was leaving the se->expr uninitialized and the middle-end does 
not handle that situation.  This patch resolves the issue.

Not exactly obvious, but simple enough.  Regression tested on 4.4 and 4.5.  Test 
cases as in the original patch.

OK for 4.4 and forward port to 4.5?

Jerry

2009-11-21  Jerry DeLisle  <jvdelisle@gcc.gnu.org>

	PR fortran/41807
	* trans-const.c (gfc_conv_const): Fix typo in comment. Replace assert
	with error message if not constant. Set se->expr.
	* resolve.c (next_data_value): Delete check for constant.

This is the relevant portion of the patch against current trunk
Index: trans-const.c
===================================================================
--- trans-const.c	(revision 154421)
+++ trans-const.c	(working copy)
@@ -356,6 +356,7 @@
    if (expr->expr_type != EXPR_CONSTANT)
      {
        gfc_error ("non-constant initialization expression at %L", &expr->where);
+      se->expr = gfc_conv_constant_to_tree (gfc_int_expr (0));
        return;
      }

Full patch for 4.4:

Index: trans-const.c
===================================================================
--- trans-const.c	(revision 154660)
+++ trans-const.c	(working copy)
@@ -336,7 +336,7 @@ void
  gfc_conv_constant (gfc_se * se, gfc_expr * expr)
  {
    /* We may be receiving an expression for C_NULL_PTR or C_NULL_FUNPTR.  If
-     so, they expr_type will not yet be an EXPR_CONSTANT.  We need to make
+     so, the expr_type will not yet be an EXPR_CONSTANT.  We need to make
       it so here.  */
    if (expr->ts.type == BT_DERIVED && expr->ts.derived
        && expr->ts.derived->attr.is_iso_c)
@@ -349,7 +349,12 @@ gfc_conv_constant (gfc_se * se, gfc_expr * expr)
          }
      }

-  gcc_assert (expr->expr_type == EXPR_CONSTANT);
+  if (expr->expr_type != EXPR_CONSTANT)
+    {
+      gfc_error ("non-constant initialization expression at %L", &expr->where);
+      se->expr = gfc_conv_constant_to_tree (gfc_int_expr (0));
+      return;
+    }

    if (se->ss != NULL)
      {
Index: resolve.c
===================================================================
--- resolve.c	(revision 154660)
+++ resolve.c	(working copy)
@@ -9447,10 +9447,6 @@ 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;



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2009-11-26 13:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-26 14:16 [patch, fortran] [4.5/4.4 Regression] data statement with nested type constructors Jerry DeLisle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).