[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGenCXX / static-data-member-single-emission.cpp
blob781f5e4ec5744c7014dbf7551d9a3cc832d95c5b
1 // RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s
3 template <typename T>
4 struct HasStaticInit {
5 static const int index;
6 };
7 extern "C"
8 int the_count = 0;
9 template <typename T>
10 const int HasStaticInit<T>::index = the_count++;
12 template <typename T> int func_tmpl1() { return HasStaticInit<T>::index; }
13 template <typename T> int func_tmpl2() { return HasStaticInit<T>::index; }
14 template <typename T> int func_tmpl3() { return HasStaticInit<T>::index; }
15 void useit() {
16 func_tmpl1<int>();
17 func_tmpl2<int>();
18 func_tmpl3<int>();
21 // Throw in a final explicit instantiation to see that it doesn't screw things
22 // up.
23 template struct HasStaticInit<int>;
25 // There should only be one entry, not 3.
26 // CHECK: @llvm.global_ctors = appending global [1 x { i32, ptr, ptr }]
28 // There should only be one update to @the_count.
29 // CHECK-NOT: store i32 %{{.*}}, ptr @the_count
30 // CHECK: store i32 %{{.*}}, ptr @the_count
31 // CHECK-NOT: store i32 %{{.*}}, ptr @the_count