From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 BA25C3858D37 for ; Wed, 2 Mar 2022 18:31:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BA25C3858D37 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-301-hW1a2ODvNjCM5IliG4ch_w-1; Wed, 02 Mar 2022 13:31:10 -0500 X-MC-Unique: hW1a2ODvNjCM5IliG4ch_w-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 743671019985 for ; Wed, 2 Mar 2022 18:31:09 +0000 (UTC) Received: from pdp-11.redhat.com (unknown [10.22.17.160]) by smtp.corp.redhat.com (Postfix) with ESMTP id 144668395D; Wed, 2 Mar 2022 18:31:08 +0000 (UTC) From: Marek Polacek To: GCC Patches , Jason Merrill Subject: [PATCH] c++: Attribute deprecated/unavailable divergence Date: Wed, 2 Mar 2022 13:31:06 -0500 Message-Id: <20220302183106.355982-1-polacek@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE 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-List-Received-Date: Wed, 02 Mar 2022 18:31:18 -0000 Attributes deprecated and unavailable are largely the same, except that the former produces a warning whereas the latter produces an error. So is_late_template_attribute should treat them the same. Confirmed by Iain that this divergence is not intentional: . Bootstrapped/regtested on x86_64-pc-linux-gnu, ok for trunk or defer to GCC 13? gcc/cp/ChangeLog: * decl2.cc (is_late_template_attribute): Do not defer attribute unavailable. * pt.cc (tsubst_enum): Set TREE_UNAVAILABLE. gcc/testsuite/ChangeLog: * g++.dg/ext/attr-unavailable-9.C: Add dg-error. --- gcc/cp/decl2.cc | 1 + gcc/cp/pt.cc | 4 +--- gcc/testsuite/g++.dg/ext/attr-unavailable-9.C | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/gcc/cp/decl2.cc b/gcc/cp/decl2.cc index 22edc2ba7f9..2752426546c 100644 --- a/gcc/cp/decl2.cc +++ b/gcc/cp/decl2.cc @@ -1314,6 +1314,7 @@ is_late_template_attribute (tree attr, tree decl) /* But some attributes specifically apply to templates. */ && !is_attribute_p ("abi_tag", name) && !is_attribute_p ("deprecated", name) + && !is_attribute_p ("unavailable", name) && !is_attribute_p ("visibility", name)) return true; else diff --git a/gcc/cp/pt.cc b/gcc/cp/pt.cc index 8fb17349ee1..853738410be 100644 --- a/gcc/cp/pt.cc +++ b/gcc/cp/pt.cc @@ -26976,9 +26976,7 @@ tsubst_enum (tree tag, tree newtag, tree args) DECL_SOURCE_LOCATION (TYPE_NAME (newtag)) = DECL_SOURCE_LOCATION (TYPE_NAME (tag)); TREE_DEPRECATED (newtag) = TREE_DEPRECATED (tag); - /* We don't need to propagate TREE_UNAVAILABLE here, because it is, unlike - deprecated, applied at instantiation time rather than template - definition time. */ + TREE_UNAVAILABLE (newtag) = TREE_UNAVAILABLE (tag); } /* DECL is a FUNCTION_DECL that is a template specialization. Return diff --git a/gcc/testsuite/g++.dg/ext/attr-unavailable-9.C b/gcc/testsuite/g++.dg/ext/attr-unavailable-9.C index 44161336e78..6df55d534f8 100644 --- a/gcc/testsuite/g++.dg/ext/attr-unavailable-9.C +++ b/gcc/testsuite/g++.dg/ext/attr-unavailable-9.C @@ -3,10 +3,10 @@ /* { dg-options "" } */ template struct __attribute__ ((unavailable)) S {}; -S s; +S s; // { dg-error "unavailable" } template