Issue 144264
Summary Clang frontend crashes on invalid usage of `[[deprecated]]` inside `constexpr` function
Labels clang
Assignees
Reporter Rush10233
    Generated by fuzzer that randomly inserts `[[deprecated]]` specifier before function and struct declarations.

Probably starts from clang-6: https://godbolt.org/z/c34Y65Tjn.

Simplified test:

```c++
constexpr void Test6() 
{ 
    using TT = struct [[deprecated]] T[deprecated{}; 
}
```

Stack Dump:

```
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++ -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.	<eof> parser at end of file
2.	<source>:2:1: parsing function body 'Test6'
 #0 0x0000000003c31b88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c31b88)
 #1 0x0000000003c2fccc llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3c2fccc)
 #2 0x0000000003b80358 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
 #3 0x00007ca24c642520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
 #4 0x00000000066354f4 CheckConstexprFunctionStmt(clang::Sema&, clang::FunctionDecl const*, clang::Stmt*, llvm::SmallVectorImpl<clang::SourceLocation>&, clang::SourceLocation&, clang::SourceLocation&, clang::SourceLocation&, clang::Sema::CheckConstexprKind) SemaDeclCXX.cpp:0:0
 #5 0x0000000006636422 clang::Sema::CheckConstexprFunctionDefinition(clang::FunctionDecl const*, clang::Sema::CheckConstexprKind) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x6636422)
 #6 0x00000000065c4598 clang::Sema::ActOnFinishFunctionBody(clang::Decl*, clang::Stmt*, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x65c4598)
 #7 0x000000000630dcbf clang::Parser::ParseFunctionStatementBody(clang::Decl*, clang::Parser::ParseScope&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x630dcbf)
 #8 0x00000000061e7c06 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61e7c06)
 #9 0x000000000623424f clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x623424f)
#10 0x00000000061dffa7 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61dffa7)
#11 0x00000000061e0dbe clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61e0dbe)
#12 0x00000000061ea92f clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61ea92f)
#13 0x00000000061ec188 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61ec188)
#14 0x00000000061ec6d0 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61ec6d0)
#15 0x00000000061da563 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x61da563)
#16 0x000000000457ae7d clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x457ae7d)
#17 0x000000000488ca8a clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+++0x488ca8a)
#18 0x00000000048082db clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x48082db)
#19 0x0000000004981033 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x4981033)
#20 0x0000000000d95745 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd95745)
#21 0x0000000000d8d58d ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#22 0x00000000045ec9b9 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
#23 0x0000000003b80773 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x3b80773)
#24 0x00000000045ecbd9 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
#25 0x00000000045af77d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45af77d)
#26 0x00000000045b0741 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+++0x45b0741)
#27 0x00000000045bb06c clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0x45bb06c)
#28 0x0000000000d91ed1 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd91ed1)
#29 0x0000000000c4c4f4 main (/opt/compiler-explorer/clang-trunk/bin/clang+++0xc4c4f4)
#30 0x00007ca24c629d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#31 0x00007ca24c629e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#32 0x0000000000d8d025 _start (/opt/compiler-explorer/clang-trunk/bin/clang+++0xd8d025)
clang++: error: clang frontend command failed with exit code 139 (use -v to see invocation)

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

Reply via email to