diff options
author | Jialun Hu <jialun_hu@apple.com> | 2022-10-18 21:56:13 +0800 |
---|---|---|
committer | YingChi Long <me@inclyc.cn> | 2022-10-18 21:57:32 +0800 |
commit | 94e8bd002c81ace308ddac9b66385ef932655fd3 (patch) | |
tree | 57fd317bff019b18d14ebb2b16e4c6c81d70f260 /clang/lib/Parse/ParseDecl.cpp | |
parent | b0ded70ebf5ac3f24ebcbf7c72eea93400ec7754 (diff) | |
download | llvm-94e8bd002c81ace308ddac9b66385ef932655fd3.zip llvm-94e8bd002c81ace308ddac9b66385ef932655fd3.tar.gz llvm-94e8bd002c81ace308ddac9b66385ef932655fd3.tar.bz2 |
[clang] Fix crash upon stray coloncolon token in C2x mode
The parser assumes that the lexer never emits coloncolon token for C code, but this assumption no longer holds in C2x attribute namespaces. As a result, stray coloncolon tokens out of attributes cause assertion failures and hangs in release build, which this patch tries to handle.
Crash input minimal example: `T n::v`
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D133248
Diffstat (limited to 'clang/lib/Parse/ParseDecl.cpp')
-rw-r--r-- | clang/lib/Parse/ParseDecl.cpp | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index ddb83a8..e15a6ff 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -5411,6 +5411,8 @@ bool Parser::isDeclarationSpecifier( return isDeclarationSpecifier(AllowImplicitTypename); case tok::coloncolon: // ::foo::bar + if (!getLangOpts().CPlusPlus) + return false; if (NextToken().is(tok::kw_new) || // ::new NextToken().is(tok::kw_delete)) // ::delete return false; |