From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11779 invoked by alias); 10 Jan 2013 20:40:31 -0000 Received: (qmail 9434 invoked by uid 48); 10 Jan 2013 20:40:00 -0000 From: "janus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/49213] [OOP] gfortran rejects structure constructor expression Date: Thu, 10 Jan 2013 20:40:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: major X-Bugzilla-Who: janus at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2013-01/txt/msg00981.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49213 --- Comment #10 from janus at gcc dot gnu.org 2013-01-10 20:39:58 UTC --- The following patch makes comment 8 and 9 compile, but I'm not sure if the generated code is correct: Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (revision 194927) +++ gcc/fortran/trans-expr.c (working copy) @@ -5990,23 +5990,11 @@ gfc_trans_subcomponent_assign (tree dest, gfc_comp gfc_add_expr_to_block (&block, tmp); } } - else if (expr->ts.type == BT_DERIVED) + else if (expr->ts.type == BT_DERIVED && expr->expr_type == EXPR_STRUCTURE) { - if (expr->expr_type != EXPR_STRUCTURE) - { - gfc_init_se (&se, NULL); - gfc_conv_expr (&se, expr); - gfc_add_block_to_block (&block, &se.pre); - gfc_add_modify (&block, dest, - fold_convert (TREE_TYPE (dest), se.expr)); - gfc_add_block_to_block (&block, &se.post); - } - else - { - /* Nested constructors. */ - tmp = gfc_trans_structure_assign (dest, expr); - gfc_add_expr_to_block (&block, tmp); - } + /* Nested constructors. */ + tmp = gfc_trans_structure_assign (dest, expr); + gfc_add_expr_to_block (&block, tmp); } else {