<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/113722>113722</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Assertion `!isTokenSpecial() && "Should consume special tokens with Consume*Token"' failed.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:frontend,
crash-on-invalid,
clang:frontend:fuzzer
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
yijan4845
</td>
</tr>
</table>
<pre>
**This testcase is generated by a fuzzer.**
Compiler Explorer: [https://godbolt.org/z/9EEEefGbT](https://godbolt.org/z/9EEEefGbT)
This invalid code will crash on Clang Assertion Trunk:
```cpp
struct S {
void m(int x = 0,
#pragma message "Any message") {
int z = 0;
#pragma unused(x)
}
};
```
It seems that this goes back to clang-5.
Stack dump:
```
clang++: /root/llvm-project/clang/include/clang/Parse/Parser.h:549: clang::SourceLocation clang::Parser::ConsumeToken(): Assertion `!isTokenSpecial() && "Should consume special tokens with Consume*Token"' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0. Program arguments: /opt/compiler-explorer/clang-assertions-trunk/bin/clang++ -gdwarf-4 -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>:5:13: at annotation token
2. <source>:1:1: parsing struct/union/class body 'S'
#0 0x0000000003bcced8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bcced8)
#1 0x0000000003bcab9c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3bcab9c)
#2 0x0000000003b18248 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x000072f27a642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x000072f27a6969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x000072f27a642476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x000072f27a6287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x000072f27a62871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
#8 0x000072f27a639e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
#9 0x00000000066bb12f clang::Parser::ConsumeAndStoreInitializer(llvm::SmallVector<clang::Token, 4u>&, clang::Parser::CachedInitKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66bb12f)
#10 0x00000000066e7c3a clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e7c3a)
#11 0x00000000066e8598 clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e8598)
#12 0x00000000066ed6af clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66ed6af)
#13 0x00000000066da6e6 clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66da6e6)
#14 0x000000000816c711 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x816c711)
#15 0x00000000066c9d0f clang::Parser::ParseDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66c9d0f)
#16 0x00000000066fe8a5 clang::Parser::ParseCXXMemberDeclaratorBeforeInitializer(clang::Declarator&, clang::VirtSpecifiers&, clang::ActionResult<clang::Expr*, true>&, clang::Parser::LateParsedAttrList&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66fe8a5)
#17 0x0000000006705920 clang::Parser::ParseCXXClassMemberDeclaration(clang::AccessSpecifier, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::ParsingDeclRAIIObject*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6705920)
#18 0x0000000006707611 clang::Parser::ParseCXXClassMemberDeclarationWithPragmas(clang::AccessSpecifier&, clang::ParsedAttributes&, clang::TypeSpecifierType, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6707611)
#19 0x0000000006709157 clang::Parser::ParseCXXMemberSpecification(clang::SourceLocation, clang::SourceLocation, clang::ParsedAttributes&, unsigned int, clang::Decl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6709157)
#20 0x000000000670b903 clang::Parser::ParseClassSpecifier(clang::tok::TokenKind, clang::SourceLocation, clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, bool, clang::Parser::DeclSpecContext, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x670b903)
#21 0x00000000066e0100 clang::Parser::ParseDeclarationSpecifiers(clang::DeclSpec&, clang::Parser::ParsedTemplateInfo&, clang::AccessSpecifier, clang::Parser::DeclSpecContext, clang::Parser::LateParsedAttrList*, clang::ImplicitTypenameContext) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66e0100)
#22 0x000000000669dc34 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669dc34)
#23 0x000000000669e69e clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x669e69e)
#24 0x00000000066a5e33 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a5e33)
#25 0x00000000066a6d1d clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a6d1d)
#26 0x00000000066a71c0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x66a71c0)
#27 0x0000000006699202 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6699202)
#28 0x0000000004542c48 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4542c48)
#29 0x00000000047fe239 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x47fe239)
#30 0x000000000477cbde clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x477cbde)
#31 0x00000000048e3a0e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x48e3a0e)
#32 0x0000000000ce1c8f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xce1c8f)
#33 0x0000000000cd998a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#34 0x0000000004586969 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
#35 0x0000000003b186f4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x3b186f4)
#36 0x0000000004586f5f 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
#37 0x000000000454c85d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x454c85d)
#38 0x000000000454d94d 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+++0x454d94d)
#39 0x0000000004555275 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4555275)
#40 0x0000000000cdeb4f clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcdeb4f)
#41 0x0000000000badae4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xbadae4)
#42 0x000072f27a629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#43 0x000072f27a629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#44 0x0000000000cd943e _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xcd943e)
clang++: error: clang frontend command failed with exit code 134 (use -v to see invocation)
ASM generation compiler returned: 134
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkmt1y27iSgJ-GvkFJRYIUfy58ocj2rGczlVTkmp07FQg2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