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

    <tr>
        <th>Summary</th>
        <td>
            Clang complains about ambiguous functions with #pragma weak
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    In a variant of bug #35478, we can fix the compiler crash by declaring the functions involved with prototypes.  This works fine when no parameters are involved.  However, once a parameter enters the game, we get a weird compiler error.  This is all C code.

```
int test2(int), test1(int);
#pragma weak test2 = test1
int test1(int i) { return 0; }
int main() { return test2(0); return 0; }
```

When compiling with clang 14.0.6, I get the following error message:

```
a.c:4:21: error: call to 'test2' is ambiguous
int main() { return test2(0); return 0; }
                    ^~~~~
a.c:1:5: note: candidate function
int test2(int), test1(int);
    ^
a.c:2:14: note: candidate function
#pragma weak test2 = test1
             ^
1 error generated.
```

This is very unexpected.  Gcc processes this code just fine.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVEtvozAQ_jVwGS0C8woHDm2zj95X2rMxE3BL7Mg2ofn3O3ZIk-5WVbXayIGx_c3MNy863Z_aRwUcjtxIrhzoHXTzABHL87KoNxF7gAVBcAU7-QJuJFnvD3JCA8JwO0J3gh7FROpqCPe7WQkntbIg1VFPR-xhkW6Eg9FOu9MBbQLwc5QWFm2eLdlVCMuICpSGAzd8jw6NBW7w1QJp_NALHtF4QloJJMqvWEAVNLz3gY5W0gM6Qi0oTX8ljcZocyFAi08TPNB1j0mUbqP0bn1W6brCVlJmHFrHIrYhOWKN9-FPsutJfr_qsvxg-LD3vvnzWQ-ifLvi3xhc1UGSAYjqezDoZqMgJWu0317Rey4Vgf_AXUilZwLvq_8RzPn5y2f8nBZfuVAiKiOJWZGkSeUDfAw5DEXV06QXDwwJhD1ayweM8rsPssYTQYCC_iyjx1nVC8Jn3WnqsnoNoA612HdymPVs_0vU8M4vKr9G9c26oekZlp6c0g7PJFUve-6uHf0PvXBxeuOIeWfFZzx9ppH-Ci-cZmuZBlRoyHCffNAJl1Gg6TrBrPDlgMKFmfsuhB9bQcVGP14E8pMCT7N1YW6TGNusKjdNmeaMxX2b903e8NhJN2H7ENrJ99hEZaT6dnp21yrffClC970NN57N1I7OHaxvMvaN1kCouUvIIG2m6Xh5fSGOT8SZttLaGS0JZVVXaTy2GRZds6myTOSbqsqzIsN6I1gusOhZIfJ44h1Oto3K-4gxhQsEEyRH5TaWLUsZS2tWZ03O0jTZsXxT13XalKJpdl0WFSlSj06J55FoM8SmDZToI2rpcpLW2eslt1YOCjG4I_t8dqM2Lc3dbFE8o4mD9zaw_w2pDrQa">