[PATCH, Fortran] PR78259: ICE in gfc_trans_subcomponent_assign, at fortran/trans-expr.c:7330
Fritz Reese
fritzoreese@gmail.com
Wed Nov 9 16:07:00 GMT 2016
All,
Will commit the below to trunk as an obvious fix for PR78259. (The
regression was introduced in r241626 from
https://gcc.gnu.org/ml/fortran/2016-10/msg00206.html). The patch
clears regtests.
---
Fritz Reese
From: Fritz O. Reese <fritzoreese@gmail.com>
Date: Wed, 9 Nov 2016 10:59:17 -0500
Subject: [PATCH] Fix ICE in gfc_trans_subcomponent_assign due to NULL
components.
PR fortran/78259
* gcc/fortran/trans-expr.c (gfc_trans_subcomponent_assign): Guard
against NULL values.
PR fortran/78259
* gcc/testsuite/gfortran.dg/pr78259.f90: New test.
---
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 7159b17..0352916 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -7321,7 +7321,8 @@ gfc_trans_subcomponent_assign (tree dest, gfc_component *
gfc_constructor *c = gfc_constructor_first (expr->value.constructor);
/* We mark that the entire union should be initialized with a contrived
EXPR_NULL expression at the beginning. */
- if (c->n.component == NULL && c->expr->expr_type == EXPR_NULL)
+ if (c != NULL && c->n.component == NULL
+ && c->expr != NULL && c->expr->expr_type == EXPR_NULL)
{
tmp = build2_loc (input_location, MODIFY_EXPR, void_type_node,
dest, build_constructor (TREE_TYPE (dest), NULL));
diff --git a/gcc/testsuite/gfortran.dg/pr78259.f90 b/gcc/testsuite/gfortran.dg/p
new file mode 100644
index 0000000..82f48ea
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/pr78259.f90
@@ -0,0 +1,22 @@
+! { dg-do "compile" }
+! { dg-options "-fdec-structure" }
+!
+! PR fortran/78259
+!
+! ICE in gfc_trans_subcomponent_assign
+!
+
+subroutine sub
+ structure /s/
+ union
+ map
+ integer n(2)
+ end map
+ map
+ integer(8) m /2/
+ end map
+ end union
+ end structure
+ record /s/ r
+ r.n(1) = 1
+end
More information about the Fortran
mailing list