[clang] Fix crash upon stray coloncolon token in C2x mode
authorJialun Hu <jialun_hu@apple.com>
Tue, 18 Oct 2022 13:56:13 +0000 (21:56 +0800)
committerYingChi Long <me@inclyc.cn>
Tue, 18 Oct 2022 13:57:32 +0000 (21:57 +0800)
commit94e8bd002c81ace308ddac9b66385ef932655fd3
tree57fd317bff019b18d14ebb2b16e4c6c81d70f260
parentb0ded70ebf5ac3f24ebcbf7c72eea93400ec7754
[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
clang/docs/ReleaseNotes.rst
clang/include/clang/Parse/Parser.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/Parser.cpp
clang/test/Parser/c2x-attributes.c