diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 21bf0ce8acf15..5de436f94a6be 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 `_) +- There were some cases in which the diagnostic for the unavailable attribute + might not be issued, this fixes those cases. + (`61815 `_) Bug Fixes in This Version ------------------------- diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index 7b883566f3ae1..c8f364faecabd 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 0094cde1ff18c..e95c06cfc61ac 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 int phase_one_unavailable2(int x = unavailable_int()) __attribute__((unavailable)) {} + +namespace GH61815 { +template +class __attribute__((unavailable)) polymorphic_allocator {}; // expected-note 2 {{'polymorphic_allocator' has been explicitly marked unavailable here}} + +void f() { + polymorphic_allocator a; // expected-error {{'polymorphic_allocator' is unavailable}} + polymorphic_allocator b; // expected-error {{'polymorphic_allocator' is unavailable}} +} +}