aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorCorentin Jabot <corentinjabot@gmail.com>2023-03-23 14:26:45 +0100
committerCorentin Jabot <corentinjabot@gmail.com>2023-03-30 16:30:23 +0200
commitabf4a8cb15d4faf04ee0da14e37d7349d3bde9a1 (patch)
tree0e153899e0b010eeac281facbca646a8c54a4d6f /clang/lib/Parse/ParseDecl.cpp
parent5114843983b6d3ec866877308073d3821759a747 (diff)
downloadllvm-abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1.zip
llvm-abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1.tar.gz
llvm-abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1.tar.bz2
[Clang] Improve diagnostics when using a concept as template argument
When using the name of a template variable or concept in places where an expression was expected, Clang would drop the cxxscope token preceeding it, if any. This leads to subpar diagnostics - complaining about the identifier being undeclared as clang would not know to look into a non-global scope. We make sure the scope is preserved. When encountering `ns::Concept foo x;`, Clang would also fail to provide the same quality as it does at global scope. Reviewed By: aaron.ballman, erichkeane Differential Revision: https://reviews.llvm.org/D146719
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 2b5829b..91376cf 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3448,12 +3448,12 @@ void Parser::ParseDeclarationSpecifiers(
continue;
}
- if (TemplateId && TemplateId->Kind == TNK_Concept_template &&
- GetLookAheadToken(2).isOneOf(tok::kw_auto, tok::kw_decltype)) {
+ if (TemplateId && TemplateId->Kind == TNK_Concept_template) {
DS.getTypeSpecScope() = SS;
- // This is a qualified placeholder-specifier, e.g., ::C<int> auto ...
- // Consume the scope annotation and continue to consume the template-id
- // as a placeholder-specifier.
+ // This is probably a qualified placeholder-specifier, e.g., ::C<int>
+ // auto ... Consume the scope annotation and continue to consume the
+ // template-id as a placeholder-specifier. Let the next iteration
+ // diagnose a missing auto.
ConsumeAnnotationToken();
continue;
}