Issue 61563
Summary Availability attribute triggers from a non-template inline function marked as unavailable
Labels new issue
Assignees
Reporter ldionne
    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()`.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to