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

    <tr>
        <th>Summary</th>
        <td>
            Unhelpful diagnostics when a multi-versioned `target_version("default")` definition comes first
        </td>
    </tr>

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

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

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

<pre>
    The error message you get when specifying a `target_version("default")` as the first definition is really unhelpful. We should either:
  *  explicitly forbid that and improve the diagnostics such that they explain exactly what went wrong
  *   or (preferably) fix Sema and allow these to come in any order.

AFAICT, the ACLE doesn't place restrictions on the order that these may occur in: https://github.com/ARM-software/acle/blob/main/main/acle.md#function-multi-versioning

```
__attribute__((target_version("default")))
int callee() {
  return 0;
}

__attribute__((target_version("simd")))
int callee() {
  return 1;
}
```

```
example.c:6:16: warning: attribute declaration must precede definition [-Wignored-attributes]
    6 | __attribute__((target_version("simd")))
      | ^
example.c:2:5: note: previous definition is here
    2 | int callee() {
      |     ^
example.c:7:5: error: redefinition of 'callee'
    7 | int callee() {
      |     ^
example.c:2:5: note: previous definition is here
    2 | int callee() {
      |     ^
1 warning and 1 error generated.
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VVGPozYQ_jXmZZQITIDwwAO7e5EqtS_tVfcYGXsAn4yNxmaz-fcVTrKbva6up550EfIEbH_fzHj8jfBeDxaxYcUDK54SsYTRUfOVHBrX-6Rz6tx8HhGQyBFM6L0YEM5ugQEDnEa04GeUuj9rO4AAVqZB0IDh-IzktbOM7xnnCnuxmMA4Z7xmZQrCQxgRek0-gMJeWx20s6A9EApjzrDYEc3cL2YLXxD86BajAHUYkVjesvSJpS0A4y0AvsxGSx3MGXpHnVYQRhFAWAV6msk9YyRTWgzW-aClB7_I8bIqjHiOCEJbwBchV5jTOn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