Issue |
130682
|
Summary |
Assertion failure in clang::ASTContext::mergeTypes triggered by invalid function parameter declarations
|
Labels |
clang
|
Assignees |
|
Reporter |
bi6c
|
Compiler Explorer: https://godbolt.org/z/vWMbdejbK
generated by fuzzer
```console
<source>:3:20: error: too few arguments to function call, expected 2, have 0
3 | void fn4(int[][fn3()]);
| ~~~ ^
<source>:1:5: note: 'fn3' declared here
1 | int fn3 (long long a, long long b);
| ^ ~~~~~~~~~~~~~~~~~~~~~~~~
<source>:4:18: error: call to undeclared function 'fn1'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
4 | void fn4(int x[][fn1()()]) {}
| ^
<source>:4:23: error: called object type 'int' is not a function or function pointer
4 | void fn4(int x[][fn1()()]) {}
| ~~~~~^
Non-canonical and dependent types shouldn't get here
UNREACHABLE executed at /root/llvm-project/clang/lib/AST/ASTContext.cpp:11536!
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>:4:28: current parser token '{'
#0 0x0000000003e6c598 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6c598)
#1 0x0000000003e6a254 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3e6a254)
#2 0x0000000003db6b68 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x0000760764242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007607642969fc pthread_kill (/lib/x86_64-linux-gnu/libc.so.6+0x969fc)
#5 0x0000760764242476 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x42476)
#6 0x00007607642287f3 abort (/lib/x86_64-linux-gnu/libc.so.6+0x287f3)
#7 0x0000000003dc24ca (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3dc24ca)
#8 0x0000000007354b00 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7354b00)
#9 0x00000000073542c0 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x73542c0)
#10 0x0000000007355411 clang::ASTContext::mergeFunctionParameterTypes(clang::QualType, clang::QualType, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7355411)
#11 0x0000000007355ee8 clang::ASTContext::mergeFunctionTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7355ee8)
#12 0x0000000007354a14 clang::ASTContext::mergeTypes(clang::QualType, clang::QualType, bool, bool, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7354a14)
#13 0x0000000007356ff4 clang::ASTContext::typesAreCompatible(clang::QualType, clang::QualType, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x7356ff4)
#14 0x00000000067e16ee clang::Sema::MergeFunctionDecl(clang::FunctionDecl*, clang::NamedDecl*&, clang::Scope*, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67e16ee)
#15 0x00000000067e97dc clang::Sema::CheckFunctionDeclaration(clang::Scope*, clang::FunctionDecl*, clang::LookupResult&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67e97dc)
#16 0x00000000067ef6f3 clang::Sema::ActOnFunctionDeclarator(clang::Scope*, clang::Declarator&, clang::DeclContext*, clang::TypeSourceInfo*, clang::LookupResult&, llvm::MutableArrayRef<clang::TemplateParameterList*>, bool&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67ef6f3)
#17 0x00000000067f4640 clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67f4640)
#18 0x00000000067f4ff0 clang::Sema::ActOnStartOfFunctionDef(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>, clang::SkipBodyInfo*, clang::Sema::FnBodyKind) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x67f4ff0)
#19 0x0000000006438aa0 clang::Parser::ParseFunctionDefinition(clang::ParsingDeclarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::LateParsedAttrList*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6438aa0)
#20 0x000000000646e0fd clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x646e0fd)
#21 0x000000000642d07e clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642d07e)
#22 0x000000000642d839 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642d839)
#23 0x0000000006435013 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6435013)
#24 0x0000000006435eed clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x6435eed)
#25 0x000000000642837a clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x642837a)
#26 0x00000000048300a8 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x48300a8)
#27 0x0000000004af89e5 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4af89e5)
#28 0x0000000004a7c1be clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4a7c1be)
#29 0x0000000004be76ae clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4be76ae)
#30 0x0000000000d52de7 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd52de7)
#31 0x0000000000d49baa ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#32 0x00000000048784a9 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
#33 0x0000000003db7014 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x3db7014)
#34 0x0000000004878a9f 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
#35 0x000000000483b27d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x483b27d)
#36 0x000000000483c2fe 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+0x483c2fe)
#37 0x0000000004844215 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0x4844215)
#38 0x0000000000d4f083 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd4f083)
#39 0x0000000000c16c64 main (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xc16c64)
#40 0x0000760764229d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#41 0x0000760764229e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#42 0x0000000000d49655 _start (/opt/compiler-explorer/clang-assertions-trunk/bin/clang+0xd49655)
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
Compiler returned: 134
```
Code:
```c
int fn3 (long long a, long long b);
void fn4(int[][fn3()]);
void fn4(int x[][fn1()()]) {}
void fn1() {
void fn2(int[][fn3()]);
int a[10][fn3()];
fn4(a);
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs