diff options
author | Fritz Reese <fritzoreese@gmail.com> | 2016-10-27 17:21:46 +0000 |
---|---|---|
committer | Fritz Reese <foreese@gcc.gnu.org> | 2016-10-27 17:21:46 +0000 |
commit | f8da53e09357859d707925e770348636b19206a7 (patch) | |
tree | 0ced59424def8217861da26fe0ebd3ed918a6110 /gcc/fortran/resolve.c | |
parent | 959c1e20455870ffb01ec67d50b88918a74e9e85 (diff) | |
download | gcc-f8da53e09357859d707925e770348636b19206a7.zip gcc-f8da53e09357859d707925e770348636b19206a7.tar.gz gcc-f8da53e09357859d707925e770348636b19206a7.tar.bz2 |
Fix initialization of UNIONs with -finit-derived.
gcc/fortran/
* expr.c (generate_union_initializer, get_union_initializer): New.
* expr.c (component_initializer): Consider BT_UNION specially.
* resolve.c (resolve_structure_cons): Hack for BT_UNION.
* trans-expr.c (gfc_trans_subcomponent_assign): Ditto.
* trans-expr.c (gfc_conv_union_initializer): New.
* trans-expr.c (gfc_conv_structure): Replace UNION handling code with
new function gfc_conv_union_initializer.
gcc/testsuite/gfortran.dg/
* dec_init_1.f90, dec_init_2.f90: Remove -fdump-tree-original.
* dec_init_3.f90, dec_init_4.f90: New tests.
From-SVN: r241626
Diffstat (limited to 'gcc/fortran/resolve.c')
-rw-r--r-- | gcc/fortran/resolve.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c index fe966aa..f9d11be 100644 --- a/gcc/fortran/resolve.c +++ b/gcc/fortran/resolve.c @@ -1158,6 +1158,12 @@ resolve_structure_cons (gfc_expr *expr, int init) if (!cons->expr) continue; + /* Unions use an EXPR_NULL contrived expression to tell the translation + phase to generate an initializer of the appropriate length. + Ignore it here. */ + if (cons->expr->ts.type == BT_UNION && cons->expr->expr_type == EXPR_NULL) + continue; + if (!gfc_resolve_expr (cons->expr)) { t = false; |