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

    <tr>
        <th>Summary</th>
        <td>
            [WebAssembly] `__builtin_wasm_table_size` example code in `clang/docs/LanguageExtensions.rst` doesn't compile
        </td>
    </tr>

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

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

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

<pre>
    source code:
```
spacetanuki% cat x.c
// dumb copy-and-paste from clang/docs/LanguageExtensions.rst

typedef void (*__funcref funcref_t)();
static __funcref table[0];

size_t
getSize()
{
        return __builtin_wasm_table_size(table);
}
```

clang version:
```
spacetanuki% /Volumes/PortableSSD/llvm/build/bin/clang --version
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 22043643c64f748cb00ae92476f2085b3c0903c9)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /Volumes/PortableSSD/llvm/build/bin
spacetanuki% 
```

error:
```
spacetanuki% /Volumes/PortableSSD/llvm/build/bin/clang -Xclang -target-feature -Xclang +reference-types -c x.c
x.c:4:18: error: type specifier missing, defaults to 'int'; ISO C99 and later do not support implicit int [-Wimplicit-int]
 4 | static __funcref table[0];
      | ~~~~~~           ^
      | int
Assertion failed: (!isNull() && "Cannot retrieve a NULL type pointer"), function getCommonPtr, file Type.h, line 752.
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: /Volumes/PortableSSD/llvm/build/bin/clang -Xclang -target-feature -Xclang +reference-types -c x.c
1.      x.c:4:26: current parser token ';'
 #0 0x000000011106552d llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10348252d)
 #1 0x0000000111065b2b PrintStackTraceSignalHandler(void*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x103482b2b)
 #2 0x00000001110634f6 llvm::sys::RunSignalHandlers() (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1034804f6)
 #3 0x0000000111064dae llvm::sys::CleanupOnSignal(unsigned long) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x103481dae)
 #4 0x0000000110ec4557 (anonymous namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1032e1557)
 #5 0x0000000110ec499b CrashRecoverySignalHandler(int) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1032e199b)
 #6 0x00007ff81b5aadfd (/usr/lib/system/libsystem_platform.dylib+0x7ff800337dfd)
 #7 0x0000000100000068 (/Volumes/PortableSSD/llvm/build/bin/clang-17+0xf241d068)
 #8 0x00007ff81b4e0d24 (/usr/lib/system/libsystem_c.dylib+0x7ff80026dd24)
 #9 0x00007ff81b4e00cb (/usr/lib/system/libsystem_c.dylib+0x7ff80026d0cb)
#10 0x00000001123c2b64 clang::QualType::getCommonPtr() const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1047dfb64)
#11 0x0000000117a00e99 clang::QualType::getQualifiers() const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x109e1de99)
#12 0x0000000117a07d25 clang::QualType::hasAddressSpace() const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x109e24d25)
#13 0x0000000117a07bcf clang::ASTContext::removeAddrSpaceQualType(clang::QualType) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x109e24bcf)
#14 0x000000011748ccc6 HandleWebAssemblyFuncrefAttr((anonymous namespace)::TypeProcessingState&, clang::QualType&, clang::ParsedAttr&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1098a9cc6)
#15 0x0000000117485ee8 processTypeAttrs((anonymous namespace)::TypeProcessingState&, clang::QualType&, TypeAttrLocation, clang::ParsedAttributesView const&, clang::Sema::CUDAFunctionTarget) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1098a2ee8)
#16 0x0000000117484d68 ConvertDeclSpecToType((anonymous namespace)::TypeProcessingState&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1098a1d68)
#17 0x000000011747118c GetDeclSpecTypeForDeclarator((anonymous namespace)::TypeProcessingState&, clang::TypeSourceInfo*&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10988e18c)
#18 0x0000000117470fed clang::Sema::GetTypeForDeclarator(clang::Declarator&, clang::Scope*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10988dfed)
#19 0x0000000116216a1f clang::Sema::HandleDeclarator(clang::Scope*, clang::Declarator&, llvm::MutableArrayRef<clang::TemplateParameterList*>) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x108633a1f)
#20 0x000000011621613e clang::Sema::ActOnDeclarator(clang::Scope*, clang::Declarator&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10863313e)
#21 0x0000000115ab1c8b clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107ecec8b)
#22 0x0000000115ab0192 clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, clang::DeclaratorContext, clang::ParsedAttributes&, clang::SourceLocation*, clang::Parser::ForRangeInit*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107ecd192)
#23 0x0000000115bd6ec3 clang::Parser::ParseDeclOrFunctionDefInternal(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec&, clang::AccessSpecifier) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107ff3ec3)
#24 0x0000000115bd62ca clang::Parser::ParseDeclarationOrFunctionDefinition(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*, clang::AccessSpecifier) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107ff32ca)
#25 0x0000000115bd524d clang::Parser::ParseExternalDeclaration(clang::ParsedAttributes&, clang::ParsedAttributes&, clang::ParsingDeclSpec*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107ff224d)
#26 0x0000000115bd2c59 clang::Parser::ParseTopLevelDecl(clang::OpaquePtr<clang::DeclGroupRef>&, clang::Sema::ModuleImportState&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107fefc59)
#27 0x0000000115a99157 clang::ParseAST(clang::Sema&, bool, bool) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x107eb6157)
#28 0x0000000112a4eaa1 clang::ASTFrontendAction::ExecuteAction() (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x104e6baa1)
#29 0x0000000112130670 clang::CodeGenAction::ExecuteAction() (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10454d670)
#30 0x0000000112a4e14c clang::FrontendAction::Execute() (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x104e6b14c)
#31 0x0000000112922719 clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x104d3f719)
#32 0x0000000112bb23b8 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x104fcf3b8)
#33 0x000000010dbf7995 cc1_main(llvm::ArrayRef<char const*>, char const*, void*) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x100014995)
#34 0x000000010dbe7308 ExecuteCC1Tool(llvm::SmallVectorImpl<char const*>&, llvm::ToolContext const&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x100004308)
#35 0x000000010dbf621d clang_main(int, char**, llvm::ToolContext const&)::$_0::operator()(llvm::SmallVectorImpl<char const*>&) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10001321d)
#36 0x000000010dbf61ed int llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::callback_fn<clang_main(int, char**, llvm::ToolContext const&)::$_0>(long, llvm::SmallVectorImpl<char const*>&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1000131ed)
#37 0x00000001125acf29 llvm::function_ref<int (llvm::SmallVectorImpl<char const*>&)>::operator()(llvm::SmallVectorImpl<char const*>&) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1049c9f29)
#38 0x00000001125aced8 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_1::operator()() const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1049c9ed8)
#39 0x00000001125acea5 void llvm::function_ref<void ()>::callback_fn<clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>*, bool*) const::$_1>(long) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1049c9ea5)
#40 0x0000000110ec43f9 llvm::function_ref<void ()>::operator()() const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1032e13f9)
#41 0x0000000110ec439c llvm::CrashRecoveryContext::RunSafely(llvm::function_ref<void ()>) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1032e139c)
#42 0x00000001125a4a38 clang::driver::CC1Command::Execute(llvm::ArrayRef<std::__1::optional<llvm::StringRef>>, std::__1::basic_string<char, std::__1::char_trait
s<char>, std::__1::allocator<char>>*, bool*) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1049c1a38)
#43 0x000000011252c6df clang::driver::Compilation::ExecuteCommand(clang::driver::Command const&, clang::driver::Command const*&, bool) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1049496df)
#44 0x000000011252cae7 clang::driver::Compilation::ExecuteJobs(clang::driver::JobList const&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&, bool) const (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x104949ae7)
#45 0x000000011254f4f2 clang::driver::Driver::ExecuteCompilation(clang::driver::Compilation&, llvm::SmallVectorImpl<std::__1::pair<int, clang::driver::Command const*>>&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10496c4f2)
#46 0x000000010dbe69cf clang_main(int, char**, llvm::ToolContext const&) (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x1000039cf)
#47 0x000000010dc2316d main (/Volumes/PortableSSD/llvm/build/bin/clang-17+0x10004016d)
#48 0x000000014152552e
clang: error: clang frontend command failed with exit code 134 (use -v to see invocation)
clang version 18.0.0 (https://github.com/llvm/llvm-project.git 22043643c64f748cb00ae92476f2085b3c0903c9)
Target: wasm32-unknown-wasi
Thread model: posix
InstalledDir: /Volumes/PortableSSD/llvm/build/bin
clang: note: diagnostic msg:
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/x-119863.c
clang: note: diagnostic msg: /var/folders/74/hw1sphgx0lv63q6pq_n5grw00000gn/T/x-119863.sh
clang: note: diagnostic msg: Crash backtrace is located in
clang: note: diagnostic msg: /Users/yamamoto/Library/Logs/DiagnosticReports/clang-17_<YYYY-MM-DD-HHMMSS>_<hostname>.crash
clang: note: diagnostic msg: (choose the .crash file that corresponds to your crash)
clang: note: diagnostic msg:

********************
spacetanuki% 
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJzsW11zoziX_jXkRuUUiO-LXDhO3J230pNsOzOzc-US0sHRNiBGEun4vdjfviWBY4vYmXQ3Pbu1Na5UjOEgPec5HzoSgijFNw3AhRdfevHVGen0o5AXW1Lrs0Kw7YUSnaSAqGDghXPPv_L8uZf4w5_9qVpCQZOm-8I9HCNKNHo-p4MoXnp4iVhXF4iKdjsjDZu1RGlApRQ1ohVpNh5eMkGVh5e3pNl0ZAPXzxoaxUWjzqXSQ1P2v962wKBET4Iz5OHMw_P1uuwaKqFEw_daezi313IvvBx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