| Issue |
170081
|
| Summary |
Crash when using pragma on valid code since clang 3
|
| Labels |
clang
|
| Assignees |
|
| Reporter |
mariete1223
|
It happens only in clang, in GCC it is valid code:
## Assertion
```
None
```
## Stackcode
```
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-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 -x c++ <source>
1. <source>:2:2: current parser token 'pragma'
#0 0x0000000003cdab88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cdab88)
#1 0x0000000003cd855c llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3cd855c)
#2 0x0000000003c1e468 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007e5e9ee42520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000000c6f35a (anonymous namespace)::PragmaDebugHandler::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (.cold) Pragma.cpp:0:0
#5 0x00000000079e5e4a clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79e5e4a)
#6 0x00000000079e5e4a clang::PragmaNamespace::HandlePragma(clang::Preprocessor&, clang::PragmaIntroducer, clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79e5e4a)
#7 0x00000000079e2c6c clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79e2c6c)
#8 0x00000000079bad65 clang::Preprocessor::HandleDirective(clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79bad65)
#9 0x0000000007953ef9 clang::Lexer::LexTokenInternal(clang::Token&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x7953ef9)
#10 0x00000000079ff3bc clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79ff3bc)
#11 0x00000000079a01a8 clang::Preprocessor::CLK_CachingLexer(clang::Preprocessor&, clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79a01a8)
#12 0x00000000079ff3bc clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x79ff3bc)
#13 0x00000000061e1ccd clang::Parser::ConsumeAnyToken(bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61e1ccd)
#14 0x00000000061e5b17 clang::Parser::ExpectAndConsume(clang::tok::TokenKind, unsigned int, llvm::StringRef) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61e5b17)
#15 0x0000000006254d4b clang::Parser::ParseUsingDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation, clang::SourceLocation&, clang::ParsedAttributes&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6254d4b)
#16 0x000000000625ea55 clang::Parser::ParseUsingDirectiveOrDeclaration(clang::DeclaratorContext, clang::Parser::ParsedTemplateInfo const&, clang::SourceLocation&, clang::ParsedAttributes&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x625ea55)
#17 0x0000000006238524 clang::Parser::ParseDeclaration(clang::DeclaratorContext, clang::SourceLocation&, clang::ParsedAttributes&, clang::ParsedAttributes&, clang::SourceLocation*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6238524)
#18 0x00000000061eb5a1 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61eb5a1)
#19 0x00000000061ecd77 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61ecd77)
#20 0x00000000061c5c4a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61c5c4a)
#21 0x0000000004599785 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4599785)
#22 0x000000000489ae2a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x489ae2a)
#23 0x0000000004819d0b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4819d0b)
#24 0x000000000498f96b clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x498f96b)
#25 0x0000000000dcda95 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdcda95)
#26 0x0000000000dc594b ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem>) driver.cpp:0:0
#27 0x0000000000dc59ed 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
#28 0x0000000004606ab9 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
#29 0x0000000003c1e883 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c1e883)
#30 0x0000000004606cd9 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
#31 0x00000000045c9662 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45c9662)
#32 0x00000000045ca541 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45ca541)
#33 0x00000000045d312c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45d312c)
#34 0x0000000000dca419 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdca419)
#35 0x0000000000c74c74 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc74c74)
#36 0x00007e5e9ee29d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#37 0x00007e5e9ee29e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#38 0x0000000000dc53e5 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xdc53e5)
```
## Code
```
#pragma clang __debug crash
int main(){
return 0;
}
```
## To quickly reproduce:
https://godbolt.org/z/zd4896j37
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs