<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/118233>118233</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Clang: __funcref induced ICE.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
moonheart08
</td>
</tr>
</table>
<pre>
```c
int hsGetFuncRefForGlobal( __funcref function );
```
This is sufficient to cause the Clang frontend to crash for WebAssembly. Godbolt demonstration: https://godbolt.org/z/T1TWd3qon
Backtrace:
```
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 -g -o /app/output.s -fno-verbose-asm -S -target wasm32 -fcolor-diagnostics -fno-crash-diagnostics -std=c23 <source>
1. <source>:1:47: current parser token ')'
#0 0x00000000039af2d8 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39af2d8)
#1 0x00000000039ad424 llvm::sys::CleanupOnSignal(unsigned long) (/opt/compiler-explorer/clang-trunk/bin/clang+0x39ad424)
#2 0x00000000038fdd58 CrashRecoverySignalHandler(int) CrashRecoveryContext.cpp:0:0
#3 0x00007e7769442520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x0000000006fdf3a3 clang::ASTContext::removeAddrSpaceQualType(clang::QualType) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x6fdf3a3)
#5 0x0000000006d9011d processTypeAttrs((anonymous namespace)::TypeProcessingState&, clang::QualType&, TypeAttrLocation, clang::ParsedAttributesView const&, clang::CUDAFunctionTarget) SemaType.cpp:0:0
#6 0x0000000006d9369c GetDeclSpecTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::TypeSourceInfo*&) (.constprop.0) SemaType.cpp:0:0
#7 0x0000000006da2c4c clang::Sema::GetTypeForDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x6da2c4c)
#8 0x0000000006529c39 clang::Sema::ActOnParamDeclarator(clang::Scope*, clang::Declarator&, clang::SourceLocation) (/opt/compiler-explorer/clang-trunk/bin/clang+0x6529c39)
#9 0x00000000061fb8c0 clang::Parser::ParseParameterDeclarationClause(clang::DeclaratorContext, clang::ParsedAttributes&, llvm::SmallVectorImpl<clang::DeclaratorChunk::ParamInfo>&, clang::SourceLocation&, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61fb8c0)
#10 0x00000000061fd79b clang::Parser::ParseFunctionDeclarator(clang::Declarator&, clang::ParsedAttributes&, clang::BalancedDelimiterTracker&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61fd79b)
#11 0x00000000061ff352 clang::Parser::ParseDirectDeclarator(clang::Declarator&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61ff352)
#12 0x00000000061f7adc clang::Parser::ParseDeclaratorInternal(clang::Declarator&, void (clang::Parser::*)(clang::Declarator&)) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61f7adc)
#13 0x0000000007838951 clang::StackExhaustionHandler::runWithSufficientStackSpace(clang::SourceLocation, llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x7838951)
#14 0x00000000061f3e24 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::Parser::ParsedTemplateInfo&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61f3e24)
#15 0x00000000061a2c87 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61a2c87)
#16 0x00000000061a3aa3 clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61a3aa3)
#17 0x00000000061ad392 clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61ad392)
#18 0x00000000061aec28 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61aec28)
#19 0x00000000061af170 clang::Parser::ParseFirstTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x61af170)
#20 0x000000000619d2c2 clang::ParseAST(clang::Sema&, bool, bool) (/opt/compiler-explorer/clang-trunk/bin/clang+0x619d2c2)
#21 0x00000000042fe835 clang::CodeGenAction::ExecuteAction() (/opt/compiler-explorer/clang-trunk/bin/clang+0x42fe835)
#22 0x00000000045c8761 clang::FrontendAction::Execute() (/opt/compiler-explorer/clang-trunk/bin/clang+0x45c8761)
#23 0x000000000454832b clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x454832b)
#24 0x00000000046b10c3 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/opt/compiler-explorer/clang-trunk/bin/clang+0x46b10c3)
#25 0x0000000000ccb66c cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/opt/compiler-explorer/clang-trunk/bin/clang+0xccb66c)
#26 0x0000000000cc3fad ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) driver.cpp:0:0
#27 0x00000000043467c9 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
#28 0x00000000038fe183 llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/opt/compiler-explorer/clang-trunk/bin/clang+0x38fe183)
#29 0x00000000043469e9 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
#30 0x000000000430e21d clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/opt/compiler-explorer/clang-trunk/bin/clang+0x430e21d)
#31 0x000000000430f21d 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+0x430f21d)
#32 0x00000000043187cc clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::pair<int, clang::driver::Command const*>>&) (/opt/compiler-explorer/clang-trunk/bin/clang+0x43187cc)
#33 0x0000000000cc8301 clang_main(int, char**, llvm::ToolContext const&) (/opt/compiler-explorer/clang-trunk/bin/clang+0xcc8301)
#34 0x0000000000b96244 main (/opt/compiler-explorer/clang-trunk/bin/clang+0xb96244)
#35 0x00007e7769429d90 (/lib/x86_64-linux-gnu/libc.so.6+0x29d90)
#36 0x00007e7769429e40 __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x29e40)
#37 0x0000000000cc3a4e _start (/opt/compiler-explorer/clang-trunk/bin/clang+0xcc3a4e)
clang: error: clang frontend command failed with exit code 139 (use -v to see invocation)
Compiler returned: 139```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzkWl1zmzoa_jXkRmMPSBjDhS-oE2dzpjvN1tlzLj1CerG1BYkjidTZX78jwMYQx-k27pnZ2U4zcYQ-nud5P_RKhhojthJg4c0-ebPbG1rbndKLUim5A6qtH99kir8svMhv_zPPT4W0aGfuwa5qyb5CvlL6vlAZ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