Issue 126940
Summary #embed assertion fail if a known parameter comes after an unknown
Labels c23, crash-on-invalid, embed
Assignees
Reporter Fznamznon
    Reproducer
```
int a[] = {
#embed __FILE__ bla(2) limit(2)
};
```

Backtrace
```
clang: /root/llvm-project/clang/lib/Lex/PPDirectives.cpp:3980: void clang::Preprocessor::HandleEmbedDirective(clang::SourceLocation, clang::Token&, const clang::FileEntry*): Assertion `(Params || CurTok.is(tok::eod)) && "expected success or to be at the end of the directive"' 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 -fverbose-asm -S --gcc-toolchain=/opt/compiler-explorer/gcc-snapshot -fcolor-diagnostics -fno-crash-diagnostics -std=c23 -E <source>
 #0 0x0000000003e753a8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e753a8)
 #1 0x0000000003e73064 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e73064)
 #2 0x0000000003dbf538 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x000073e5d9842520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x000073e5d98969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
 #5 0x000073e5d9842476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
 #6 0x000073e5d98287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
 #7 0x000073e5d982871b (/lib/x86_64-linux-gnu/libc.so.6+0x2871b)
 #8 0x000073e5d9839e96 (/lib/x86_64-linux-gnu/libc.so.6+0x39e96)
 #9 0x0000000007c0a06b clang::Preprocessor::HandleEmbedDirective(clang::SourceLocation, clang::Token&, clang::FileEntry const*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c0a06b)
#10 0x0000000007c17f97 clang::Preprocessor::HandleDirective(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c17f97)
#11 0x0000000007bc818a clang::Lexer::LexTokenInternal(clang::Token&, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7bc818a)
#12 0x0000000007bca34f clang::Lexer::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7bca34f)
#13 0x0000000007c5b96c clang::Preprocessor::Lex(clang::Token&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7c5b96c)
#14 0x0000000004b1baf1 clang::DoPrintPreprocessedInput(clang::Preprocessor&, llvm::raw_ostream*, clang::PreprocessorOutputOptions const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4b1baf1)
#15 0x0000000004aeddee clang::PrintPreprocessedAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4aeddee)
#16 0x0000000004ad37a5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4ad37a5)
#17 0x0000000004a5715e clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a5715e)
#18 0x0000000004bc205e clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4bc205e)
#19 0x0000000000d4c48f cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4c48f)
#20 0x0000000000d43f0a ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#21 0x0000000004853569 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
#22 0x0000000003dbf9e4 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dbf9e4)
#23 0x0000000004853b5f 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
#24 0x0000000004816cdd clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4816cdd)
#25 0x0000000004817d5e 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+0x4817d5e)
#26 0x000000000481fd15 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x481fd15)
#27 0x0000000000d49283 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd49283)
#28 0x0000000000c122c4 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc122c4)
#29 0x000073e5d9829d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#30 0x000073e5d9829e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#31 0x0000000000d439b5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd439b5)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```

The diagnostic also points to the next parameter after wrong one
```
<source>:2:24: error: unknown embed preprocessor parameter 'bla'
    2 | #embed __FILE__ bla(2) clang::offset(3) limit(2)
      |   
```
Godbolt https://godbolt.org/z/8oWh41vb6

_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to