shafik created this revision. shafik added reviewers: rsmith, aaron.ballman, erichkeane. Herald added a subscriber: inglorion. Herald added a project: All. shafik requested review of this revision.
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 https://reviews.llvm.org/D147495 Files: clang/include/clang/Basic/Attr.td clang/test/SemaCXX/attr-unavailable.cpp Index: clang/test/SemaCXX/attr-unavailable.cpp =================================================================== --- clang/test/SemaCXX/attr-unavailable.cpp +++ clang/test/SemaCXX/attr-unavailable.cpp @@ -172,3 +172,13 @@ 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}} +} +} Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -2848,6 +2848,7 @@ "IR_ARCInitReturnsUnrelated", "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>]; let Documentation = [Undocumented]; + let MeaningfulToClassTemplateDefinition = 1; } def DiagnoseIf : InheritableAttr {
Index: clang/test/SemaCXX/attr-unavailable.cpp =================================================================== --- clang/test/SemaCXX/attr-unavailable.cpp +++ clang/test/SemaCXX/attr-unavailable.cpp @@ -172,3 +172,13 @@ 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}} +} +} Index: clang/include/clang/Basic/Attr.td =================================================================== --- clang/include/clang/Basic/Attr.td +++ clang/include/clang/Basic/Attr.td @@ -2848,6 +2848,7 @@ "IR_ARCInitReturnsUnrelated", "IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>]; let Documentation = [Undocumented]; + let MeaningfulToClassTemplateDefinition = 1; } def DiagnoseIf : InheritableAttr {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits