| Issue |
165246
|
| Summary |
[Clang][Regression] Crash on invalid `int decltype {}`
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
MagentaTreehouse
|
This invalid code crashes Clang trunk:
```c++
int decltype {}
```
See https://compiler-explorer.com/z/T9583bx8c.
Output:
```console
<source>:1:13: error: expected '(' after 'decltype'
1 | int decltype {}
| ^
| (
```
Assertion:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Lex/PPCaching.cpp:151:
void clang::Preprocessor::AnnotatePreviousCachedTokens(const clang::Token&):
Assertion `CachedTokens[CachedLexPos-1].getLastLoc() == Tok.getAnnotationEndLoc() && "The annotation should be until the most recent cached token"' failed.
```
<details>
<summary>Stack dump</summary>
```console
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -g -o /app/output.s -mllvm --x86-asm-syntax=intel -fno-verbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics <source>
1. <source>:1:5: at annotation token
#0 0x00000000042227b8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x42227b8)
#1 0x000000000421fbe4 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x421fbe4)
#2 0x0000000004163e38 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000701a98642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000701a986969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000701a98642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x0000701a986287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000701a9862871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x0000701a98639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x0000000008199dcd clang::Preprocessor::AnnotatePreviousCachedTokens(clang::Token const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8199dcd)
#10 0x00000000069bbfa6 clang::Parser::ParseOptionalCXXScopeSpecifier(clang::CXXScopeSpec&, clang::OpaquePtr<clang::QualType>, bool, bool, bool*, bool, clang::IdentifierInfo const**, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69bbfa6)
#11 0x0000000006967dad clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6967dad)
#12 0x000000000826f281 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x826f281)
#13 0x000000000696ab5f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x696ab5f)
#14 0x0000000006928ffe clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6928ffe)
#15 0x000000000692979f clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x692979f)
#16 0x0000000006931053 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6931053)
#17 0x0000000006931f65 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6931f65)
#18 0x0000000006932410 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6932410)
#19 0x00000000069135b3 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x69135b3)
#20 0x0000000004b6d258 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b6d258)
#21 0x0000000004e5a6a5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4e5a6a5)
#22 0x0000000004ddb67e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ddb67e)
#23 0x0000000004f516dd clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4f516dd)
#24 0x0000000000dcf360 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdcf360)
#25 0x0000000000dc5eca ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#26 0x0000000000dc604d int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::'lambda'(llvm::SmallVectorImpl<char const*>&)>(long, llvm::SmallVectorImpl<char const*>&) driver.cpp:0:0
#27 0x0000000004bd6619 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#28 0x00000000041642d4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x41642d4)
#29 0x0000000004bd6c2f clang::driver::CC1Command::Execute(llvm::ArrayRef<std::optional<llvm::StringRef>>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>*, bool*) const (.part.0) Job.cpp:0:0
#30 0x0000000004b97d42 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b97d42)
#31 0x0000000004b98cee clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4b98cee)
#32 0x0000000004ba0425 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4ba0425)
#33 0x0000000000dcb889 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdcb889)
#34 0x0000000000c7a524 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xc7a524)
#35 0x0000701a98629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x0000701a98629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000dc5965 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xdc5965)
```
</details>
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs