From abf4a8cb15d4faf04ee0da14e37d7349d3bde9a1 Mon Sep 17 00:00:00 2001 From: Corentin Jabot Date: Thu, 23 Mar 2023 14:26:45 +0100 Subject: [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 --- clang/lib/Parse/ParseDecl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'clang/lib/Parse/ParseDecl.cpp') 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 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 + // 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; } -- cgit v1.1