From patchwork Thu Dec 31 15:40:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Palka X-Patchwork-Id: 561899 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D61DF140BA5 for ; Fri, 1 Jan 2016 02:40:50 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=hchLy//q; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=wBIV6NebqlV1QpYk4BqnX278FYrDu5G5gVG3SD9mFDdNHqhcn2jbk B7MBiDSGkS/UfgnsSMMX5/mGKdjwIX/EN1MKx6ksKFMP74XluSjfECg2SWXUUyG+ gXf/yF/uf7Vmf69fcjRjW3Z1g/w8KdO1xBdURQjXuYlloUf/BY7haY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=5gFc16fpZyzvnMjlBqkQxaeaJms=; b=hchLy//qaurc6YSVDafS eUg/RW1ZOnCcA4QV+Ig60AC59q/PHFwvvJqKk25mScbDnwElWnBAogrtU2yXXQxf azIdS+Qw/i0AqfuC7l+vS+UykrDI09GFBVwRnNvIJJ/lFBMMBn6aulZ+ZjD73SAk 27ABDiiT7TURM69LxPvWDhg= Received: (qmail 18164 invoked by alias); 31 Dec 2015 15:40:31 -0000 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 Received: (qmail 18056 invoked by uid 89); 31 Dec 2015 15:40:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=upper, init.c, initc, UD:init.c X-HELO: mail-qg0-f44.google.com Received: from mail-qg0-f44.google.com (HELO mail-qg0-f44.google.com) (209.85.192.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 31 Dec 2015 15:40:30 +0000 Received: by mail-qg0-f44.google.com with SMTP id e32so112331390qgf.3 for ; Thu, 31 Dec 2015 07:40:29 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bXbvKjTgtHr+EhtjRYctqh3OBzT6Z0Kivxc5VCgj55E=; b=SGSuZxLJAsIzNWiGc2hIXvIMRVdr+8ZioH2z3KPLfkZEW95wC7esfwvJH7ESmB8hc4 CcqljEl3Ht9APacFDN5V8PtRu2249TbslmW0GlK9Ms/I5VBG54F0CnXiCTuPuaN1LVBZ mCggaj149xsf+SqH3hVT3B1UZdSLFdhLcaM9i1jD5T+TaasC64CeYY7r4CDGrjxKmNfH q+/2i3oivfk1ejCdq0EDa9M2ESjVfuuoRrs+Oa0L8rBYM/eN7uwdjLsOZB15wr7jyEst rNAqTA3A9D32FSgGnmubNFxwHvV8ZUUTyuCPUEb00CYYRbA1lwkNB/i/VnFRew6OLS4c XCrQ== X-Gm-Message-State: ALoCoQkGRVQAz23KiGP3gG34Q+73FS47wYDt5g2pD4PEQhmhwl3Y4zJG7tqw8zUqBWhfmKt4JzfljojdPXDhWT1NP9qk5IglvA== X-Received: by 10.140.86.38 with SMTP id o35mr93279606qgd.56.1451576427979; Thu, 31 Dec 2015 07:40:27 -0800 (PST) Received: from localhost.localdomain (ool-4353a98f.dyn.optonline.net. [67.83.169.143]) by smtp.gmail.com with ESMTPSA id i136sm10861236qhc.42.2015.12.31.07.40.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Dec 2015 07:40:27 -0800 (PST) From: Patrick Palka To: gcc-patches@gcc.gnu.org Cc: jakub@redhat.com, jason@redhat.com, Patrick Palka Subject: [PATCH 2/3] Avoid creating an initializer for a flexible array member Date: Thu, 31 Dec 2015 10:40:16 -0500 Message-Id: <1451576417-8710-2-git-send-email-patrick@parcs.ath.cx> In-Reply-To: <1451576417-8710-1-git-send-email-patrick@parcs.ath.cx> References: <1451576417-8710-1-git-send-email-patrick@parcs.ath.cx> If we do create such an initializer, we end up with an error_mark_node during gimplification, because in cp-gimplify.c we pass this VEC_INIT_EXPR of the flexible array member to build_vec_init, for which it spits on an error_mark_node. This happens in e.g. the test case g++.dg/ext/array1.C. This patch makes it so that we avoid generating an initializer for a flexible array member, thus avoiding to end up with an error_mark_node during gimplification. The same kind of thing is done ~90 lines down from the code I changed. gcc/cp/ChangeLog: * init.c (perform_member_init): Avoid creating an initializer for a flexible array member. --- gcc/cp/init.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/gcc/cp/init.c b/gcc/cp/init.c index 09c1183..0011178 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -645,9 +645,14 @@ perform_member_init (tree member, tree init) /* mem() means value-initialization. */ if (TREE_CODE (type) == ARRAY_TYPE) { - init = build_vec_init_expr (type, init, tf_warning_or_error); - init = build2 (INIT_EXPR, type, decl, init); - finish_expr_stmt (init); + /* Initialize the array only if it's not a flexible + array member (i.e., if it has an upper bound). */ + if (TYPE_DOMAIN (type) && TYPE_MAX_VALUE (TYPE_DOMAIN (type))) + { + init = build_vec_init_expr (type, init, tf_warning_or_error); + init = build2 (INIT_EXPR, type, decl, init); + finish_expr_stmt (init); + } } else {