mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-11-30 17:21:10 +00:00
[clang][sema] Provide better diagnostic for missing template arguments
Instead of just complaining that "x is not a class, namespace or enumeration", mention that using x requires template arguments. Differential Revision: https://reviews.llvm.org/D127638 Fixes https://github.com/llvm/llvm-project/issues/55962
This commit is contained in:
parent
bce55d0690
commit
c149fa1f5f
@ -264,7 +264,9 @@ Improvements to Clang's diagnostics
|
||||
- ``-Wshift-overflow`` will not warn for signed left shifts in C++20 mode
|
||||
(and newer), as it will always wrap and never overflow. This fixes
|
||||
`Issue 52873 <https://github.com/llvm/llvm-project/issues/52873>`_.
|
||||
|
||||
- When using class templates without arguments, clang now tells developers
|
||||
that template arguments are missing in certain contexts.
|
||||
This fixes `Issue 55962 <https://github.com/llvm/llvm-project/issues/55962>`_.
|
||||
|
||||
Non-comprehensive list of changes in this release
|
||||
-------------------------------------------------
|
||||
|
@ -828,10 +828,14 @@ bool Sema::BuildCXXNestedNameSpecifier(Scope *S, NestedNameSpecInfo &IdInfo,
|
||||
}
|
||||
|
||||
if (!Found.empty()) {
|
||||
if (TypeDecl *TD = Found.getAsSingle<TypeDecl>())
|
||||
if (TypeDecl *TD = Found.getAsSingle<TypeDecl>()) {
|
||||
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
|
||||
<< Context.getTypeDeclType(TD) << getLangOpts().CPlusPlus;
|
||||
else {
|
||||
} else if (Found.getAsSingle<TemplateDecl>()) {
|
||||
ParsedType SuggestedType;
|
||||
DiagnoseUnknownTypeName(IdInfo.Identifier, IdInfo.IdentifierLoc, S, &SS,
|
||||
SuggestedType);
|
||||
} else {
|
||||
Diag(IdInfo.IdentifierLoc, diag::err_expected_class_or_namespace)
|
||||
<< IdInfo.Identifier << getLangOpts().CPlusPlus;
|
||||
if (NamedDecl *ND = Found.getAsSingle<NamedDecl>())
|
||||
|
@ -473,3 +473,10 @@ namespace DependentTemplateInTrivialNNSLoc {
|
||||
x: goto x;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
struct x; // expected-note {{template is declared here}}
|
||||
|
||||
template <typename T>
|
||||
int issue55962 = x::a; // expected-error {{use of class template 'x' requires template arguments}} \
|
||||
// expected-warning {{variable templates are a C++14 extension}}
|
||||
|
Loading…
Reference in New Issue
Block a user