<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/59164>59164</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Bad diagnostic when trying to use ifunc from C++
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang:diagnostics
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
arsenm
</td>
</tr>
</table>
<pre>
Trying to compile this sample ifunc program produces an unhelpful error:
```
int foo(int x, int y) {
return x + y + 1;
}
int bar(int x, int y) {
return x + y + 2;
}
extern bool use_bar;
static void (*resolver (void)) (void) {
return use_bar ? (void(*)()) use_bar : (void(*)())foo;
}
__attribute__((ifunc("resolver")))
int call_ifunc(int x, int y);
```
$ clang++ ifunc.cpp
ifunc.cpp:15:16: error: ifunc must point to a defined function
__attribute__((ifunc("resolver")))
^
1 error generated.
This is apparently due to this expecting the mangled name of the function. It compiles if I trade static for extern "C". It would be better if it noticed you were trying to call a function with mangling and inform how to fix it.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVMFynDAM_Rq4aMqAybLsgcMmaWZyz33HYAHuGJuxTXb37yt7Idu0zaVljJBs-elJlmmNuDZv9ir1AN5AZ6ZZKgQ_SgeOTzPpsl90B7M1g-VT-IqlQwdcw6JHVHO_KEBrjU3KY5I_J_kxqfJ1RFNqD70xCauDdknYEwTlmrADJPvHmxPQY9EvVsMFEvYI1yiLpFwdkv3zqnyAttz-Eyj7ChQvHsm3NUbB4vAUAny4Ruk897KDdyMFQdUJO1p0Rr2jDWaYJgKRw4f1VzorOiTly901wMXt9Qpy9zp-7RVK-0U-pxP33sp28Xg6xQ11PM2oso05qTekMD6K23GlTpv3HzX-rSy_nfgq2QN0iuuBah7KHsGybp5hjbLZlF6xC6IKiW69tDbetDgPswmBqUE5COylRgFh0Uuj_y9T-Pwku--3-eJGAwbUaLlHkX3KLMq3cElo8HnmFrVXVxALBpbx-uBlRmIYLtaIMFEdFNHWfEIwfZzbUsjg1W9XjxB7eAVvuUBYu60nImtrUgZP9MYdZ7MoAS3S8LQYNkoP2tAWCnQ1C5zREp_77aYjpQpuYeEs_XgjFhy4FnS8FGuC0ZyDfy8vhJil2BRVdWAsr1iZiqYUh_LAUy-9wuaRCxCSD9q4QPU8ov4lIjXweoy9NRM83TohXaxqRu9nF34Z7IXGQFSWNqMikKHU-_b5Rv-bH1RGMqVzCzpSdoeiekjHBncc2R7LskMsuq4qWM2w3ucVdiXv8n2qeIvKNcmOgrJbJ5bHO1kX2mH3nMqG5YwVBSsLSrCsMsHauq05CsSq7fo-echx4lJlgVFm7JDaJpJrl8HRopLOu_sid04OGjEGJny--NHYhluHekpjGk3M4Sevuqvs">