[clang][OpenMP] Assertion `ParsedType.isUsable()' failed with -fms-compatibility
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
Reproducer:
https://godbolt.org/z/hM47q3KoK
```cpp
struct foo {};
template struct S : T {
virtual void bar() {
#pragma omp declare reduction(foo : baz : omp_out)
}
};
S s;
```
Backtrace:
```console
clang++: /root/llvm-project/llvm/tools/clang/lib/Sema/SemaOpenMP.cpp:24336: clang::QualType clang::SemaOpenMP::ActOnOpenMPDeclareReductionType(clang::SourceLocation, clang::TypeResult): Assertion `ParsedType.isUsable()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace and dumped files.
Stack dump:
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 -fopenmp -fms-compatibility
1. parser at end of file
2. :4:16: instantiating function definition 'S::bar'
#0 0x00000000044bc158 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44bc158)
#1 0x00000000044b93b4 llvm::sys::RunSignalHandlers() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b93b4)
#2 0x00000000044b99ec llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x44b99ec)
#3 0x00000000043f5f48 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#4 0x00007bc076645330 (/lib/x86_64-linux-gnu/libc.so.6+0x45330)
#5 0x00007bc07669ec0c pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x9ec0c)
#6 0x00007bc07664527e raise (/lib/x86_64-linux-gnu/libc.so.6+0x4527e)
#7 0x00007bc0766288ff abort (/lib/x86_64-linux-gnu/libc.so.6+0x288ff)
#8 0x00007bc07662881b (/lib/x86_64-linux-gnu/libc.so.6+0x2881b)
#9 0x00007bc07663b517 (/lib/x86_64-linux-gnu/libc.so.6+0x3b517)
#10 0x000000000765811f clang::SemaOpenMP::ActOnOpenMPDeclareReductionType(clang::SourceLocation, clang::ActionResult, false>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x765811f)
#11 0x0000000007a56c21 clang::TemplateDeclInstantiator::VisitOMPDeclareReductionDecl(clang::OMPDeclareReductionDecl*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a56c21)
#12 0x0000000007ac04d4 void llvm::function_ref::callback_fn(long) SemaTemplateInstantiateDecl.cpp:0:0
#13 0x0000000008955f81 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x8955f81)
#14 0x0000000007a5608a clang::Sema::SubstDecl(clang::Decl*, clang::DeclContext*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a5608a)
#15 0x00000000079bab05 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformDeclStmt(clang::DeclStmt*) SemaTemplateInstantiate.cpp:0:0
#16 0x0000000007a02b35 clang::TreeTransform<(anonymous namespace)::TemplateInstantiator>::TransformCompoundStmt(clang::CompoundStmt*, bool) SemaTemplateInstantiate.cpp:0:0
#17 0x0000000007a0368a clang::Sema::SubstStmt(clang::Stmt*, clang::MultiLevelTemplateArgumentList const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7a0368a)
#18 0x0000000007ab2b9c clang::Sema::InstantiateFunctionDefinition(clang::SourceLocation, clang::FunctionDecl*, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ab2b9c)
#19 0x0000000007ab0e06 clang::Sema::PerformPendingInstantiations(bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x7ab0e06)
#20 0x0000000006fd1792 clang::Sema::ActOnEndOfTranslationUnitFragment(clang::TUFragmentKind) (.part.0) Sema.cpp:0:0
#21 0x0000000006fd1ad2 clang::Sema::ActOnEndOfTranslationUnit() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6fd1ad2)
#22 0x0000000006e31efa clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e31efa)
#23 0x0000000006e0e24a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x6e0e24a)
#24 0x0000000004fd1998 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x4fd1998)
#25 0x00000000052f2678 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x52f2678)
#26 0x000000000528028d clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x528028d)
#27 0x00000000053c6e9d clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x53c6e9d)
#28 0x0000000000d9160c cc1_main(llvm::ArrayRef, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd9160c)
#29 0x0000000000d8831a ExecuteCC1Tool(llvm::SmallVectorImpl&, llvm::ToolContext const&, llvm::IntrusiveRefCntPtr) driver.cpp:0:0
#30 0x0000000000d8849d int llvm::function_ref&)>::callback_fn&)>(long, llvm::SmallVectorImpl&) driver.cpp:0:0
#31 0x0000000005045c69 void llvm::function_ref::callback_fn>, std::__cxx11::basic_string, std::allocator>*, bool*) const::'lambda'()>(long) Job.cpp:0:0
#32 0x00000000043f6344 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x43f6344)
#33 0x00000000050467d5 clang::driver::CC1Command::Execute(llvm::ArrayRef>, std::__cxx11::basic_string, std::allocator>*, bool*) const (.part.0) Job.cpp:0:0
#34 0x0000000005004c02 clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5004c02)
#35 0x0000000005009567 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl>&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5009567)
#36 0x0000000005013ac5 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0x5013ac5)
#37 0x0000000000d8db0a clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd8db0a)
#38 0x0000000000ccb4aa main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xccb4aa)
#39 0x00007bc07662a1ca (/lib/x86_64-linux-gnu/libc.so.6+0x2a1ca)
#40 0x00007bc07662a28b __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a28b)
#41 0x0000000000d87cc5 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+++0xd87cc5)
clang++: error: clang frontend command failed due to signal (use -v to see invocation)
Program terminated with signal SIGABRT (6)
Compiler returned: 134
```
Contributor guide
Research direction
Reproduce the crash with the provided C++ snippet and -fopenmp -fms-compatibility. Start in clang/lib/Sema/SemaOpenMP.cpp at ActOnOpenMPDeclareReductionType, then follow its template-instantiation path through VisitOMPDeclareReductionDecl. Done means this reproducer no longer triggers the ParsedType.isUsable() assertion and the resulting behavior is covered by an appropriate regression test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100