aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorSaar Raz <saar@raz.email>2020-03-17 01:43:29 +0200
committerSaar Raz <saar@raz.email>2020-03-17 01:49:42 +0200
commit19fccc52ff2c1da1f93d9317c34769bd9bab8ac8 (patch)
tree16b376fa2baf3fc63b553bddacc0a8e2b0239246 /clang/lib/Parse/ParseDecl.cpp
parent2a3723ef114d467179d463539dd73974b87ccf85 (diff)
downloadllvm-19fccc52ff2c1da1f93d9317c34769bd9bab8ac8.zip
llvm-19fccc52ff2c1da1f93d9317c34769bd9bab8ac8.tar.gz
llvm-19fccc52ff2c1da1f93d9317c34769bd9bab8ac8.tar.bz2
[Concepts] Fix incorrect control flow when TryAnnotateTypeConstraint annotates an invalid template-id
TryAnnotateTypeConstraint could annotate a template-id which doesn't end up being a type-constraint, in which case control flow would incorrectly flow into ParseImplicitInt. Reenter the loop in this case. Enable relevant tests for C++20. This required disabling typo-correction during TryAnnotateTypeConstraint and changing a test case which is broken due to a separate bug (will be reported and handled separately).
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 6356d82..09d1732 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -3253,6 +3253,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
goto DoneWithDeclSpec;
if (isTypeConstraintAnnotation())
continue;
+ if (NextToken().is(tok::annot_template_id))
+ // Might have been annotated by TryAnnotateTypeConstraint.
+ continue;
// Eat the scope spec so the identifier is current.
ConsumeAnnotationToken();
ParsedAttributesWithRange Attrs(AttrFactory);
@@ -3406,6 +3409,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS,
goto DoneWithDeclSpec;
if (isTypeConstraintAnnotation())
continue;
+ if (Tok.is(tok::annot_template_id))
+ // Might have been annotated by TryAnnotateTypeConstraint.
+ continue;
ParsedAttributesWithRange Attrs(AttrFactory);
if (ParseImplicitInt(DS, nullptr, TemplateInfo, AS, DSContext, Attrs)) {
if (!Attrs.empty()) {