diff options
author | Tobias Schlüter <tobias.schlueter@physik.uni-muenchen.de> | 2004-07-10 19:30:40 +0200 |
---|---|---|
committer | Tobias Schlüter <tobi@gcc.gnu.org> | 2004-07-10 19:30:40 +0200 |
commit | 104b260cac1c7d17b1a325f98c35f4a27a163cd1 (patch) | |
tree | 7f70f15047d4c324c8509ed89a37edaf52fa838b | |
parent | 794ba78be2148d3a92bccea446169e4dfad90c45 (diff) | |
download | gcc-104b260cac1c7d17b1a325f98c35f4a27a163cd1.zip gcc-104b260cac1c7d17b1a325f98c35f4a27a163cd1.tar.gz gcc-104b260cac1c7d17b1a325f98c35f4a27a163cd1.tar.bz2 |
re PR fortran/15969 (ICE and assertion failure in trans-expr.c)
PR fortran/15969
* trans-expr.c (gfc_conv_structure): Handle initialization
of scalar pointer components.
From-SVN: r84464
-rw-r--r-- | gcc/fortran/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 31 |
2 files changed, 28 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index c2551f2..ded551c 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -6,6 +6,10 @@ PR fortran/16336 * match.c (match_common): Fix error reporting for used common. + PR fortran/15969 + * trans-expr.c (gfc_conv_structure): Handle initialization + of scalar pointer components. + 2004-07-10 Tobias Schlueter <tobias.schlueter@physik.uni-muenchen.de> * trans-common.c: Fix whitespace issues, make variable names diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 47a844d..5c62234 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -1381,7 +1381,7 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init) tree type; tree arraytype; - assert (expr->expr_type == EXPR_STRUCTURE); + assert (expr->expr_type == EXPR_STRUCTURE || expr->expr_type == EXPR_NULL); type = gfc_typenode_for_spec (&expr->ts); head = build1 (CONSTRUCTOR, type, NULL_TREE); tail = NULL_TREE; @@ -1397,15 +1397,32 @@ gfc_conv_structure (gfc_se * se, gfc_expr * expr, int init) /* Evaluate the expression for this component. */ if (init) { - if (cm->dimension) + if (!cm->pointer) { - arraytype = TREE_TYPE (cm->backend_decl); - cse.expr = gfc_conv_array_initializer (arraytype, c->expr); + /* Initializing a non-pointer element. */ + if (cm->dimension) + { + arraytype = TREE_TYPE (cm->backend_decl); + cse.expr = gfc_conv_array_initializer (arraytype, c->expr); + } + else if (cm->ts.type == BT_DERIVED) + gfc_conv_structure (&cse, c->expr, 1); + else + gfc_conv_expr (&cse, c->expr); + } - else if (cm->ts.type == BT_DERIVED) - gfc_conv_structure (&cse, c->expr, 1); else - gfc_conv_expr (&cse, c->expr); + { + /* Pointer components may only be initialized to + NULL. This should have been enforced by the frontend. */ + if (cm->dimension) + { + gfc_todo_error ("Initialization of pointer members"); + } + else + cse.expr = fold_convert (TREE_TYPE (cm->backend_decl), + null_pointer_node); + } } else { |