[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
This commit is contained in:
Shafik Yaghmour 2023-04-06 14:40:39 -07:00
parent a58eefa115
commit b206cde350
3 changed files with 14 additions and 0 deletions

View File

@ -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
-------------------------

View File

@ -2848,6 +2848,7 @@ def Unavailable : InheritableAttr {
"IR_ARCInitReturnsUnrelated",
"IR_ARCFieldWithOwnership"], 1, /*fake*/ 1>];
let Documentation = [Undocumented];
let MeaningfulToClassTemplateDefinition = 1;
}
def DiagnoseIf : InheritableAttr {

View File

@ -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}}
}
}