From patchwork Mon Nov 11 10:55:58 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 290241 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BAF882C009E for ; Mon, 11 Nov 2013 21:59:03 +1100 (EST) 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=FsQwusN3OyO1lxsf utlG6NbFQ1b7Y2XLRE75PHzvoCHdJcBxO+QcJ7yp7rjLBNE4kL8nssbSMQmqFGXn HDu6UWca7GOR63XV4tW2+RrzNXOAsWV5HxAqEs/flxc4kgKsCq3K+8LHLDU8BL8p qx3Eo08akIGZ69QPvK/E5U1JQ04= 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:subject:date:message-id:mime-version:content-type :content-transfer-encoding; s=default; bh=EW1mt+gaeSPUanV7Xx5dzu 1I508=; b=r1vup6oSrGEpY6Q/0mE76RXyzi1a18q3MICdwOIYiZJcsZUwam5OFC KtujSz3tf6wKAK1rlN80kEEHmTLW2siqI2FxjqUz77kdZG6aZAK+aWyC3Vztowvd OKHuahUDaHAKtAA0YaLkAU6jFjGaLxg1qmgLRREj/GWNDqTiQg+Mw= Received: (qmail 18831 invoked by alias); 11 Nov 2013 10:58:52 -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 18816 invoked by uid 89); 11 Nov 2013 10:58:52 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL, BAYES_50, RDNS_NONE, URIBL_BLOCKED autolearn=no version=3.3.2 X-HELO: smtp.eu.adacore.com Received: from Unknown (HELO smtp.eu.adacore.com) (194.98.77.210) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Mon, 11 Nov 2013 10:57:30 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 2AA7C26A0A75 for ; Mon, 11 Nov 2013 11:57:22 +0100 (CET) Received: from smtp.eu.adacore.com ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Otia-pTZCFJ6 for ; Mon, 11 Nov 2013 11:57:22 +0100 (CET) Received: from polaris.localnet (bon31-6-88-161-99-133.fbx.proxad.net [88.161.99.133]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.eu.adacore.com (Postfix) with ESMTPSA id 0796326A008D for ; Mon, 11 Nov 2013 11:57:22 +0100 (CET) From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [patch] Add CONSTRUCTOR_NO_CLEARING flag Date: Mon, 11 Nov 2013 11:55:58 +0100 Message-ID: <1396974.au2QbtdziC@polaris> User-Agent: KMail/4.7.2 (Linux/3.1.10-1.29-desktop; KDE/4.7.2; x86_64; ; ) MIME-Version: 1.0 Hi, in Ada 2012 it is allowed to omit components of aggregates (the equivalent of initializers/constructors); in this case, the contents of the corresponding fields in the record become undefined. Now the gimplifier implements the C semantics of clearing the missing components, so this patch introduces a new flag on constructors to modify that. Tested on x86_64-suse-linux, OK for the mainline? 2013-11-11 Tristan Gingold Eric Botcazou * tree.h (CONSTRUCTOR_NO_CLEARING): Define. * tree-core.h (CONSTRUCTOR_NO_CLEARING): Document it. * tree.def (CONSTRUCTOR): Likewise. * gimplify.c (gimplify_init_constructor): Do not clear the object when the constructor is incomplete and CONSTRUCTOR_NO_CLEARING is set. ada/ * gcc-interface/utils2.c (gnat_build_constructor): Also set the flag CONSTRUCTOR_NO_CLEARING on the constructor. Index: tree-core.h =================================================================== --- tree-core.h (revision 204444) +++ tree-core.h (working copy) @@ -823,6 +823,9 @@ struct GTY(()) tree_base { VAR_DECL, FUNCTION_DECL IDENTIFIER_NODE + CONSTRUCTOR_NO_CLEARING in + CONSTRUCTOR + ASM_VOLATILE_P in ASM_EXPR Index: tree.h =================================================================== --- tree.h (revision 204444) +++ tree.h (working copy) @@ -957,6 +957,8 @@ extern void omp_clause_range_check_faile (&(*CONSTRUCTOR_ELTS (NODE))[IDX]) #define CONSTRUCTOR_NELTS(NODE) \ (vec_safe_length (CONSTRUCTOR_ELTS (NODE))) +#define CONSTRUCTOR_NO_CLEARING(NODE) \ + (CONSTRUCTOR_CHECK (NODE)->base.public_flag) /* Iterate through the vector V of CONSTRUCTOR_ELT elements, yielding the value of each element (stored within VAL). IX must be a scratch variable Index: tree.def =================================================================== --- tree.def (revision 204444) +++ tree.def (working copy) @@ -458,7 +458,10 @@ DEFTREECODE (OBJ_TYPE_REF, "obj_type_ref value in a SAVE_EXPR if you want to evaluate side effects only once.) For RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE: - The field INDEX of each node is a FIELD_DECL. */ + The field INDEX of each node is a FIELD_DECL. + Components that aren't present are cleared as per the C semantics, + unless the CONSTRUCTOR_NO_CLEARING flag is set, in which case they + become undefined. */ DEFTREECODE (CONSTRUCTOR, "constructor", tcc_exceptional, 0) /* The expression types are mostly straightforward, with the fourth argument Index: gimplify.c =================================================================== --- gimplify.c (revision 204444) +++ gimplify.c (working copy) @@ -4052,7 +4052,7 @@ gimplify_init_constructor (tree *expr_p, objects. Initializers for such objects must explicitly set every field that needs to be set. */ cleared = false; - else if (!complete_p) + else if (!complete_p && !CONSTRUCTOR_NO_CLEARING (ctor)) /* If the constructor isn't complete, clear the whole object beforehand. Index: ada/gcc-interface/utils2.c =================================================================== --- ada/gcc-interface/utils2.c (revision 204444) +++ ada/gcc-interface/utils2.c (working copy) @@ -1874,6 +1874,7 @@ gnat_build_constructor (tree type, vecqsort (compare_elmt_bitpos); result = build_constructor (type, v); + CONSTRUCTOR_NO_CLEARING (result) = 1; TREE_CONSTANT (result) = TREE_STATIC (result) = allconstant; TREE_SIDE_EFFECTS (result) = side_effects; TREE_READONLY (result) = TYPE_READONLY (type) || allconstant;