<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/130682>130682</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Assertion failure in clang::ASTContext::mergeTypes triggered by invalid function parameter declarations
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          bi6c
      </td>
    </tr>
</table>

<pre>
    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);
}
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzkWl132zbS_jXwDQ59SPBTF76gFbtNmzZ547zbSx0QHEqoKYALgI7ci_z2PQAp8cOSY7fy7p6uTmJJJDB4nmcGg6EAqjVfC4ArFF-j-N0Fbc1GqquCJ-yikOXj1VJuG16Dwje7ppYKFApzvDGm0SjMEblF5HYty0LW5lKqNSK3fyBy-_DbL0UJvxc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