Clang Project

clang_source_code/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp
1// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s
2
3// Check that PR17480 is fixed: __attribute__((used)) ignored in templated
4// classes
5namespace InstantiateUsedMemberDefinition {
6template <typename T>
7struct S {
8  int __attribute__((used)) f() {
9    return 0;
10  }
11};
12
13void test() {
14  // Check that InstantiateUsedMemberDefinition::S<int>::f() is defined
15  // as a result of the S class template implicit instantiation
16  // CHECK: define linkonce_odr i32 @_ZN31InstantiateUsedMemberDefinition1SIiE1fEv
17  S<int> inst;
18}
19} // namespace InstantiateUsedMemberDefinition
20