Issue 86849
Summary Attributes on a function template definition (but not declaration) ignored if instantiation occurs before definition
Labels new issue
Assignees
Reporter dwblaikie
    Given:
```
void f();
template <bool>
#ifdef ATTR_DECL
__attribute__((noinline))
#endif
void f1();
int main() {
    f1<false>();
}
template <bool>
__attribute__((noinline)) void f1() { f(); }
```
https://godbolt.org/z/MG4qsxvj1
`f1` does not have the `noinline` attribute in the IR/from Clang's CodeGen - but if `ATTR_DECL` is defined or `main` is moved to after `f1`'s definition, the attribute is emitted.

GCC does have the same behavior, so one could argue this is intentional/consistent/correct - but seems a bit off? Curious to get some opinions at least


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to