1 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -std=c++1y -O1 -disable-llvm-optzns %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-optzns -fcxx-exceptions %s -o - | FileCheck %s -check-prefix=CHECKB -check-prefix=CHECK 3 // expected-no-diagnostics 4 5 // The variable template specialization x<Foo> generated in each file 6 // should be 'internal global' and not 'linkonce_odr global'. 7 8 template <typename T> int x = 42; 9 10 // CHECK-DAG: @_Z1xIZL3foovE3FooE = internal global 11 12 // CHECK-DAG: define internal dereferenceable(4) i32* @_ZL3foov( 13 static int &foo() { 14 struct Foo { }; 15 16 // CHECK-DAG: ret i32* @_Z1xIZL3foovE3FooE 17 return x<Foo>; 18 } 19 20 21 #if !__has_feature(cxx_exceptions) // File A 22 // CHECKA-DAG: define dereferenceable(4) i32* @_Z3barv( 23 int &bar() { 24 // CHECKA-DAG: call dereferenceable(4) i32* @_ZL3foov() 25 return foo(); 26 } 27 28 #else // File B 29 30 // CHECKB-DAG: declare dereferenceable(4) i32* @_Z3barv( 31 int &bar(); 32 33 int main() { 34 // CHECKB-DAG: call dereferenceable(4) i32* @_Z3barv() 35 // CHECKB-DAG: call dereferenceable(4) i32* @_ZL3foov() 36 &bar() == &foo() ? throw 0 : (void)0; // Should not throw exception at runtime. 37 } 38 39 #endif // end of Files A and B 40 41