aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorKadir Cetinkaya <kadircet@google.com>2021-11-25 20:11:46 +0100
committerKadir Cetinkaya <kadircet@google.com>2021-11-26 10:56:54 +0100
commitd026f2f7c688b326eae429286a06bf4080c8b527 (patch)
tree43b4449bd317e7af0a98a8871badd37a603f0ad0 /clang/lib/Parse/ParseDecl.cpp
parent40e7d4cd3b6f4931131731295d42022f6240531f (diff)
downloadllvm-d026f2f7c688b326eae429286a06bf4080c8b527.zip
llvm-d026f2f7c688b326eae429286a06bf4080c8b527.tar.gz
llvm-d026f2f7c688b326eae429286a06bf4080c8b527.tar.bz2
[clang] Fix crash on broken parameter declarators
Differential Revision: https://reviews.llvm.org/D114609
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index a087106..1bdeccc 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -6978,13 +6978,13 @@ void Parser::ParseParameterDeclarationClause(
//
// We care about case 1) where the declarator type should be known, and
// the identifier should be null.
- if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName()) {
- if (Tok.getIdentifierInfo() &&
- Tok.getIdentifierInfo()->isKeyword(getLangOpts())) {
- Diag(Tok, diag::err_keyword_as_parameter) << PP.getSpelling(Tok);
- // Consume the keyword.
- ConsumeToken();
- }
+ if (!ParmDeclarator.isInvalidType() && !ParmDeclarator.hasName() &&
+ Tok.isNot(tok::raw_identifier) && !Tok.isAnnotation() &&
+ Tok.getIdentifierInfo() &&
+ Tok.getIdentifierInfo()->isKeyword(getLangOpts())) {
+ Diag(Tok, diag::err_keyword_as_parameter) << PP.getSpelling(Tok);
+ // Consume the keyword.
+ ConsumeToken();
}
// Inform the actions module about the parameter declarator, so it gets
// added to the current scope.