aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Parse/ParseDecl.cpp
diff options
context:
space:
mode:
authorShafik Yaghmour <shafik.yaghmour@intel.com>2023-09-12 11:04:03 -0700
committerShafik Yaghmour <shafik.yaghmour@intel.com>2023-09-12 11:06:06 -0700
commit6eadc8f16e03f6aa3b1b1c178c308ac452eabeac (patch)
treecf8828c49e4c9902091e2da26bb6887c40291e9d /clang/lib/Parse/ParseDecl.cpp
parent063cd5545b6a4eb2b37bfb55b16a2391be221fe4 (diff)
downloadllvm-6eadc8f16e03f6aa3b1b1c178c308ac452eabeac.zip
llvm-6eadc8f16e03f6aa3b1b1c178c308ac452eabeac.tar.gz
llvm-6eadc8f16e03f6aa3b1b1c178c308ac452eabeac.tar.bz2
[Clang] Fix crash in Parser::ParseDirectDeclarator by adding check that token is not an annotation token
In Parser::ParseDirectDeclarator(...) in some cases ill-formed code can cause an annotation token to end up where it was not expected. The fix is to add a !Tok.isAnnotation() guard before attempting to access identifier info. This fixes: https://github.com/llvm/llvm-project/issues/64836 Differential Revision: https://reviews.llvm.org/D158804
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r--clang/lib/Parse/ParseDecl.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index 7c27a02..748b9d5 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -6667,7 +6667,7 @@ void Parser::ParseDirectDeclarator(Declarator &D) {
// Objective-C++: Detect C++ keywords and try to prevent further errors by
// treating these keyword as valid member names.
if (getLangOpts().ObjC && getLangOpts().CPlusPlus &&
- Tok.getIdentifierInfo() &&
+ !Tok.isAnnotation() && Tok.getIdentifierInfo() &&
Tok.getIdentifierInfo()->isCPlusPlusKeyword(getLangOpts())) {
Diag(getMissingDeclaratorIdLoc(D, Tok.getLocation()),
diag::err_expected_member_name_or_semi_objcxx_keyword)