[clang] b206cde - [Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute

Shafik Yaghmour via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 6 14:42:43 PDT 2023


Author: Shafik Yaghmour
Date: 2023-04-06T14:40:39-07:00
New Revision: b206cde3504c0078469f02bd74aeb5eb5ab875f5

URL: https://github.com/llvm/llvm-project/commit/b206cde3504c0078469f02bd74aeb5eb5ab875f5
DIFF: https://github.com/llvm/llvm-project/commit/b206cde3504c0078469f02bd74aeb5eb5ab875f5.diff

LOG: [Clang][Attributes] Add MeaningfulToClassTemplateDefinition to unavailable attribute

There may be cases in which we want to diagnose a type as unavailable but it may
not be complete at the time. Setting MeaningfulToClassTemplateDefinition fixes
this issue.

This fixes: https://github.com/llvm/llvm-project/issues/61815

Differential Revision: https://reviews.llvm.org/D147495

Added: 
    

Modified: 
    clang/docs/ReleaseNotes.rst
    clang/include/clang/Basic/Attr.td
    clang/test/SemaCXX/attr-unavailable.cpp

Removed: 
    


################################################################################
diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 21bf0ce8acf1..5de436f94a6b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -210,6 +210,9 @@ Improvements to Clang's diagnostics
 - Clang now checks for completeness of the second and third arguments in the
   conditional operator.
   (`#59718 <https://github.com/llvm/llvm-project/issues/59718>`_)
+- There were some cases in which the diagnostic for the unavailable attribute
+  might not be issued, this fixes those cases.
+  (`61815 <https://github.com/llvm/llvm-project/issues/61815>`_)
 
 Bug Fixes in This Version
 -------------------------

diff  --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 7b883566f3ae..c8f364faecab 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2848,6 +2848,7 @@ def Unavailable : InheritableAttr {
                  "IR_ARCInitReturnsUnrelated",
                  "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
   let Documentation = [Undocumented];
+  let MeaningfulToClassTemplateDefinition = 1;
 }
 
 def DiagnoseIf : InheritableAttr {

diff  --git a/clang/test/SemaCXX/attr-unavailable.cpp b/clang/test/SemaCXX/attr-unavailable.cpp
index 0094cde1ff18..e95c06cfc61a 100644
--- a/clang/test/SemaCXX/attr-unavailable.cpp
+++ b/clang/test/SemaCXX/attr-unavailable.cpp
@@ -172,3 +172,13 @@ int phase_one_unavailable(int x = unavailable_int()) {}
 
 template <class T>
 int phase_one_unavailable2(int x = unavailable_int()) __attribute__((unavailable)) {}
+
+namespace GH61815 {
+template <class _ValueType = int>
+class __attribute__((unavailable)) polymorphic_allocator {}; // expected-note 2 {{'polymorphic_allocator<void>' has been explicitly marked unavailable here}}
+
+void f() {
+  polymorphic_allocator<void> a; // expected-error {{'polymorphic_allocator<void>' is unavailable}}
+  polymorphic_allocator<void> b; // expected-error {{'polymorphic_allocator<void>' is unavailable}}
+}
+}


        


More information about the cfe-commits mailing list