public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-7546] c++: Attribute deprecated/unavailable divergence
@ 2022-03-08 21:16 Marek Polacek
  0 siblings, 0 replies; only message in thread
From: Marek Polacek @ 2022-03-08 21:16 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:6f748bc1e7fbae876ff47e3abe477253a0e70c09

commit r12-7546-g6f748bc1e7fbae876ff47e3abe477253a0e70c09
Author: Marek Polacek <polacek@redhat.com>
Date:   Wed Mar 2 10:48:26 2022 -0500

    c++: Attribute deprecated/unavailable divergence
    
    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:
    <https://gcc.gnu.org/pipermail/gcc-patches/2022-February/591007.html>.
    
    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.

Diff:
---
 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 e85bb87c955..c53acf4546d 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 8b5faeed8ea..c350ebb0a79 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<typename T> struct __attribute__ ((unavailable)) S {};
-S<int> s;
+S<int> s;			// { dg-error "unavailable" }
 
 template <template <class> class T> struct A { };
-A<S> a;
+A<S> a;				// { dg-error "unavailable" }
 
 template <class T> void f() __attribute__ ((unavailable));


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-03-08 21:16 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-08 21:16 [gcc r12-7546] c++: Attribute deprecated/unavailable divergence Marek Polacek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).