From patchwork Sat Sep 4 23:18:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 63812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id A1CC8B713F for ; Sun, 5 Sep 2010 09:18:54 +1000 (EST) Received: (qmail 2705 invoked by alias); 4 Sep 2010 23:18:52 -0000 Received: (qmail 2694 invoked by uid 22791); 4 Sep 2010 23:18:51 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, TW_CF, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from nikam-dmz.ms.mff.cuni.cz (HELO nikam.ms.mff.cuni.cz) (195.113.20.16) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 04 Sep 2010 23:18:46 +0000 Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 298C79ACB1B; Sun, 5 Sep 2010 01:18:44 +0200 (CEST) Date: Sun, 5 Sep 2010 01:18:44 +0200 From: Jan Hubicka To: gcc-patches@gcc.gnu.org, rguenther@suse.de Subject: [fortran] Set TREE_STATIC flag on static initializers Message-ID: <20100904231844.GF31380@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.18 (2008-05-17) Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi, fortran, unlike all other frontends, does not set TREE_STATIC flag on static initializers. This prevents us from folding till the cfgexpand time. To be honest, I am not quite sure why we insist on the flag (I guess we should assert that all statics are initializerd with static initializer or ignore it), but this patch brings gfortran into sync with others. Bootstrapped/regtested x86_64-linux, OK? Honza * trans-expr.c (gfc_conv_initializer): Set TREE_STATIC on static ctors. Index: fortran/trans-expr.c =================================================================== --- fortran/trans-expr.c (revision 163862) +++ fortran/trans-expr.c (working copy) @@ -3992,19 +3992,23 @@ gfc_conv_initializer (gfc_expr * expr, g gfc_init_se (&se, NULL); gfc_conv_constant (&se, expr); + gcc_assert (TREE_CODE (se.expr) != CONSTRUCTOR); return se.expr; } if (array && !procptr) { + tree ctor; /* Arrays need special handling. */ if (pointer) - return gfc_build_null_descriptor (type); + ctor = gfc_build_null_descriptor (type); /* Special case assigning an array to zero. */ else if (is_zero_initializer_p (expr)) - return build_constructor (type, NULL); + ctor = build_constructor (type, NULL); else - return gfc_conv_array_initializer (type, expr); + ctor = gfc_conv_array_initializer (type, expr); + TREE_STATIC (ctor) = 1; + return ctor; } else if (pointer || procptr) { @@ -4015,6 +4019,7 @@ gfc_conv_initializer (gfc_expr * expr, g gfc_init_se (&se, NULL); se.want_pointer = 1; gfc_conv_expr (&se, expr); + gcc_assert (TREE_CODE (se.expr) != CONSTRUCTOR); return se.expr; } } @@ -4029,14 +4034,21 @@ gfc_conv_initializer (gfc_expr * expr, g gfc_conv_structure (&se, gfc_class_null_initializer(ts), 1); else gfc_conv_structure (&se, expr, 1); + gcc_assert (TREE_CODE (se.expr) == CONSTRUCTOR); + TREE_STATIC (se.expr) = 1; return se.expr; case BT_CHARACTER: - return gfc_conv_string_init (ts->u.cl->backend_decl,expr); + { + tree ctor = gfc_conv_string_init (ts->u.cl->backend_decl,expr); + TREE_STATIC (ctor) = 1; + return ctor; + } default: gfc_init_se (&se, NULL); gfc_conv_constant (&se, expr); + gcc_assert (TREE_CODE (se.expr) != CONSTRUCTOR); return se.expr; } }