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

    <tr>
        <th>Summary</th>
        <td>
            Availability attribute triggers from a non-template inline function marked as unavailable
        </td>
    </tr>

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

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

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

<pre>
    The following code snippet fails to compile:

```
cat <<EOF | clang++ -xc++ - -fsyntax-only
__attribute__((unavailable))
void f(char*) { }

template <class T>
void call_it(T* p) {
  f(p);
}

// template <class = void>
inline __attribute__((unavailable))
void top_level(char* p) {
  call_it(p);
}
EOF
```

The compiler issues the following error:

```
<stdin>:6:3: error: 'f' is unavailable
  f(p);
  ^
<stdin>:12:3: note: in instantiation of function template specialization 'call_it<char>' requested here
 call_it(p);
  ^
<stdin>:2:6: note: 'f' has been explicitly marked unavailable here
void f(char*) { }
     ^
1 error generated.
```

This is annoying because `top_level` is an inline function that never gets called and is marked as `unavailable`, yet the availability attribute on the leaf function `f()` still triggers an error. This means that we need to poison all the functions in the stack from `top_level()` to `f()` with the availability attribute, which could be many many functions. Instead, it seems that `inline` functions should have their availability attribute treated a bit more lazily.

Basically, `__availability__` should be an attribute on symbols required from a TU. If there is no dependency of the program on the `f` symbol (in this case aka if there was no codegen for `top_level()`), there should be no diagnostic because the program doesn't actually depend on `f()`.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVc1y4jgQfhpx6QplZDD4wIGQUDWnuWTPVCO1be3IkleSYTxPvyXZ_EwmydamKAdcUvf31xJ6r2pDtGWrZ7Z6mWEfGuu2WiprDM1OVg7bt4agslrbizI1CCsJvFFdRwEqVNpDsCBs2ylNLN-x7IVl12eRTZ_0U2AAlu9Zvn_9fgC23oPQaGrGnxl_hqef4voNnio_mIA_n6zRw7j5eMQQn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