1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-passes %s -o - | FileCheck %s -check-prefix=CHECKA -check-prefix=CHECK
2 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-passes -fcxx-exceptions %s -o - | FileCheck %s -check-prefix=CHECKB -check-prefix=CHECK
3 // expected-no-diagnostics
5 // The variable template specialization x<Foo> generated in each file
6 // should be 'internal global' and not 'linkonce_odr global'.
8 template <typename T
> int x
= 42;
9 // CHECK-DAG: @_Z1xIiE = linkonce_odr global
10 // CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global
12 // 'static' affects the linkage of the global
13 template <typename T
> static int y
= 42;
14 // CHECK-DAG: @_ZL1yIiE = internal global
15 // CHECK-DAG: @_ZL1yIZL3foovE3FooE = internal global
18 template <typename T
> const int z
= 42;
19 // CHECK-DAG: @_Z1zIiE = linkonce_odr constant
20 // CHECK-DAG: @_Z1zIZL3foovE3FooE = internal constant
22 template <typename T
> T t
= 42;
23 // CHECK-DAG: @_Z1tIiE = linkonce_odr global
24 // CHECK-DAG: @_Z1tIKiE = linkonce_odr constant
28 // CHECK-DAG: define internal noundef nonnull align 4 dereferenceable(4) ptr @_ZL3foov(
29 static const int &foo() {
34 // CHECK-DAG: @_Z1xIiE
37 // CHECK-DAG: @_Z1xIZL3foovE3FooE
40 // CHECK-DAG: @_ZL1yIiE
43 // CHECK-DAG: @_ZL1yIZL3foovE3FooE
46 // CHECK-DAG: @_Z1zIiE
49 // CHECK-DAG: @_Z1zIZL3foovE3FooE
52 // CHECK-DAG: @_Z1tIiE
55 // CHECK-DAG: @_Z1tIKiE
61 #if !__has_feature(cxx_exceptions) // File A
62 // CHECKA-DAG: define{{.*}} nonnull align 4 dereferenceable(4) ptr @_Z3barv(
64 // CHECKA-DAG: call noundef nonnull align 4 dereferenceable(4) ptr @_ZL3foov()
70 // CHECKB-DAG: declare noundef nonnull align 4 dereferenceable(4) ptr @_Z3barv(
74 // CHECKB-DAG: call noundef nonnull align 4 dereferenceable(4) ptr @_Z3barv()
75 // CHECKB-DAG: call noundef nonnull align 4 dereferenceable(4) ptr @_ZL3foov()
76 &bar() == &foo() ? throw 0 : (void)0; // Should not throw exception at runtime.
79 #endif // end of Files A and B