From patchwork Thu Jan 27 21:55:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 50502 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 40417385E455 for ; Thu, 27 Jan 2022 21:57:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40417385E455 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1643320628; bh=gy/B2Eqpnw1ZKka/5kNJ8gubpruAle/ZNUcGUcWcYsE=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=jVQTrVbw4HbgqFbFcAyPxcsfFbYhauf0puTXs1pBXgHkZE47/23q68tAAWIrvJ5Si bKpI0sZ6I5zSqS2CTFO1y5vOTzHerBpn+MhJxchgAuumlGvOoP+d45LVNmC6nkweyi yIwyUbp0gmI/3pRmSBHreQ4ZhoARzRPieJcyM3iU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 88E2F3857C72 for ; Thu, 27 Jan 2022 21:55:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 88E2F3857C72 Received: from mail-qk1-f199.google.com (mail-qk1-f199.google.com [209.85.222.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-619-F1LuJdehMiyUxxEwMY2hzg-1; Thu, 27 Jan 2022 16:55:41 -0500 X-MC-Unique: F1LuJdehMiyUxxEwMY2hzg-1 Received: by mail-qk1-f199.google.com with SMTP id j66-20020a375545000000b004e0e071f37eso869655qkb.23 for ; Thu, 27 Jan 2022 13:55:41 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=gy/B2Eqpnw1ZKka/5kNJ8gubpruAle/ZNUcGUcWcYsE=; b=Vm5OCO6eqwIb4rCs7qLRJmQPNhVlbbasidN9mDAzKRQl+Mo3Bqk//uRL1KIFasykLS kB/+COBfTerJohZ27bfY1cK8BHhJhq1zcwerk96g9xZKGu5pCgLKgZujFRJGcunEaNa3 FfFhL5GJmsLHZzz7mTLOsnUgBf+EsijUVL4yDZb/2Zk5unqGys8X3kNB3GQggxdVR+ak Phxf/HRBqjDCdmE5k3OUBARDxx7ok3sMnW08i6bFrz+wRpFCJX5hE7Kbl/kQc7TFxflV P219m98U5h74IxCDg5YzvHXtQeUuWuC6+torrXUoJ9BkY8su2ZvgEmvb+GTOBM7majv5 3ypg== X-Gm-Message-State: AOAM530FQSgc2di1DpsFtTj6Vwlx6Ru/xkYQi56vKnZBIR//Ft8jcKGW FNEkG+Etj1NtwECGt0JAciR+PoQGuTr7kRGZv8kMCQoySwRlCqBipZ1nq8pJa3+LBCSCCjbwbLx ipqVgxO0O7mCTsfCqwUKeIjfjVM6Kq7ep7BikUPdtQI2Wx/koBU9wRjuRjvxaISNhjw== X-Received: by 2002:a05:6214:d0f:: with SMTP id 15mr4624636qvh.58.1643320540478; Thu, 27 Jan 2022 13:55:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/g7PUGDMna8joiIUhgM5bnQdIqC+u/3vn+hqw7y2h0MKh/sRbeeDtZRR62EfKmwRQMZrDSQ== X-Received: by 2002:a05:6214:d0f:: with SMTP id 15mr4624618qvh.58.1643320539995; Thu, 27 Jan 2022 13:55:39 -0800 (PST) Received: from barrymore.redhat.com (130-44-159-43.s15913.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.159.43]) by smtp.gmail.com with ESMTPSA id v12sm2115380qkl.74.2022.01.27.13.55.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 13:55:39 -0800 (PST) To: gcc-patches@gcc.gnu.org Subject: [pushed] c++: dependent and non-dependent attributes [PR104245] Date: Thu, 27 Jan 2022 16:55:37 -0500 Message-Id: <20220127215537.1330482-1-jason@redhat.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" A flaw in my patch for PR51344 was that cplus_decl_attributes calls decl_attributes after save_template_attributes, which messes up the ordering that save_template_attributes set up. Fixed by splitting save_template_attributes around the call to decl_attributes. Tested x86_64-pc-linux-gnu, applying to trunk. PR c++/104245 PR c++/51344 gcc/cp/ChangeLog: * decl2.cc (save_template_attributes): Take late attrs as parm. (cplus_decl_attributes): Call it after decl_attributes, splice_template_attributes before. gcc/testsuite/ChangeLog: * g++.dg/lto/alignas1_0.C: New test. --- gcc/cp/decl2.cc | 17 ++++++++--------- gcc/testsuite/g++.dg/lto/alignas1_0.C | 7 +++++++ 2 files changed, 15 insertions(+), 9 deletions(-) create mode 100644 gcc/testsuite/g++.dg/lto/alignas1_0.C base-commit: ae1b50e2e03aad06408b64c876f5d0511121de0d diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index b68cf96fa81..a2aa5f1de4e 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -1352,18 +1352,14 @@ splice_template_attributes (tree *attr_p, tree decl) return late_attrs; } -/* Remove any late attributes from the list in ATTR_P and attach them to - DECL_P. */ +/* Attach any LATE_ATTRS to DECL_P, after the non-dependent attributes have + been applied by a previous call to decl_attributes. */ static void -save_template_attributes (tree *attr_p, tree *decl_p, int flags) +save_template_attributes (tree late_attrs, tree *decl_p, int flags) { tree *q; - if (attr_p && *attr_p == error_mark_node) - return; - - tree late_attrs = splice_template_attributes (attr_p, *decl_p); if (!late_attrs) return; @@ -1666,12 +1662,12 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags) } } + tree late_attrs = NULL_TREE; if (processing_template_decl) { if (check_for_bare_parameter_packs (attributes)) return; - - save_template_attributes (&attributes, decl, flags); + late_attrs = splice_template_attributes (&attributes, *decl); } cp_check_const_attributes (attributes); @@ -1717,6 +1713,9 @@ cplus_decl_attributes (tree *decl, tree attributes, int flags) decl_attributes (decl, attributes, flags, last_decl); } + if (late_attrs) + save_template_attributes (late_attrs, decl, flags); + /* Propagate deprecation out to the template. */ if (TREE_DEPRECATED (*decl)) if (tree ti = get_template_info (*decl)) diff --git a/gcc/testsuite/g++.dg/lto/alignas1_0.C b/gcc/testsuite/g++.dg/lto/alignas1_0.C new file mode 100644 index 00000000000..a2fc72ad894 --- /dev/null +++ b/gcc/testsuite/g++.dg/lto/alignas1_0.C @@ -0,0 +1,7 @@ +// PR c++/104245 +// { dg-lto-do assemble } +// { dg-require-effective-target c++11 } + +template struct A { alignas(T) alignas(int) int a; }; +struct B { B(const char *, const char *, int, int); A b; }; +B c {"", "", 0, 0};