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

    <tr>
        <th>Summary</th>
        <td>
            [clang] `error: alias must point to a defined variable or function` false negative when optimizations are enabled
        </td>
    </tr>

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

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

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

<pre>
    https://godbolt.org/z/TrGeazYc5

```c
extern inline __attribute__((gnu_inline))
void bar (void) {}

void foo [[gnu::alias("_Z3barv")]] (void);
void foo2 (void) __attribute__((alias("_Z3barv")));
void foo3 (void) asm("_Z3barv");
```

```
<source>:4:12: error: alias must point to a defined variable or function
    4 | void foo [[gnu::alias("_Z3barv")]] (void);
      |            ^
<source>:4:12: note: the function or variable specified in an alias must refer to its mangled name
<source>:5:33: error: alias must point to a defined variable or function
    5 | void foo2 (void) __attribute__((alias("_Z3barv")));
      | ^
<source>:5:33: note: the function or variable specified in an alias must refer to its mangled name
```
via #60481
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VMFu4zYQ_ZrRZRBDIkVLOuggx3F_oJf2YlDiSGZLkQZJud18_YJyNnECB3vYLDEQSYjvzZuHwcgQ9GSJWhA7EPtMLvHkfGv18K-iIBdjNfmQ9U59a08xngPwDtgB2GFyqncmbpyfgB2egR3-9H-QfP5rEJDvIe9evtv8GsP1Tv9H8ha1NdoSHo8yRq_7JdLxCKwGVk92OV7_AmtSrLCL0wp76RFYnc7AGoRqB9X-Ntn6anQO12p2k12SXN5Jo2VY6dnxb95LfwHGErfYg9jfcALfvWditwnvqP2U-Rof6fgtnQzzPeQPzKtzd-18ufLH4BY_EPAn4F0JvCsY8A7Je-fTYRWI8xIinp22EaNDiYpGbUnhRXote0PoPI6LHaJ29sqMiFgiVI_4dabiuhLnzQLx9JNarIuU9niiV5FJ8Kv4cKZBj5oUaovS3tbsaSSfatYx4CztZEihlTPdzSmAd5x_mX_inX9f1EpvJn7m3FsVv9O594140RKB8W1e1kWmWq4a3siM2qIquKjyqm6yU8tUUW4LWeWlLJt-GLeVKERBVSHqUVUNZbplOSvzsmgYFzxvNvkoOC-ZUPWW6qLOocxpltpsjLnMafRkOoSF2ropqzIzsicT1lHG2GCknYB3SsvJuhD1EJKfYp_5NqEf-mUKUOZGhxje-KKOZp2GV3xq5G3-K92wzXGUJhBammTUF8L_TmTRnaOe9bNMbwJKT0g2YVW2ePNx1Op4WvrN4GZgh6T0ZXs4e_cPDRHYYbUhADusTnwPAAD___2Qv8I">