diff options
author | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-06-12 15:46:16 +0000 |
commit | c49018d9cce52d8c9f34b44865ec3ba8e89a1488 (patch) | |
tree | c5e9e10bc189de0058aa763c47b9920a8351b7df /test/CodeGenCXX/template-instantiation.cpp | |
parent | 110eaaceddcec790f7e6a5e3bf1261c9aa1e73ab (diff) | |
download | FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.zip FreeBSD-src-c49018d9cce52d8c9f34b44865ec3ba8e89a1488.tar.gz |
Vendor import of clang trunk r132879:
http://llvm.org/svn/llvm-project/cfe/trunk@132879
Diffstat (limited to 'test/CodeGenCXX/template-instantiation.cpp')
-rw-r--r-- | test/CodeGenCXX/template-instantiation.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/CodeGenCXX/template-instantiation.cpp b/test/CodeGenCXX/template-instantiation.cpp index 635e1d2..cc30af0 100644 --- a/test/CodeGenCXX/template-instantiation.cpp +++ b/test/CodeGenCXX/template-instantiation.cpp @@ -1,9 +1,15 @@ // RUN: %clang_cc1 %s -O1 -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s +// CHECK: @_ZN7PR100011xE = global +// CHECK-NOT: @_ZN7PR100014kBarE = external global i32 +// // CHECK-NOT: @_ZTVN5test118stdio_sync_filebufIwEE = constant // CHECK-NOT: _ZTVN5test315basic_fstreamXXIcEE // CHECK: @_ZTVN5test018stdio_sync_filebufIwEE = unnamed_addr constant +// CHECK: @_ZN7PR100011SIiE3arrE = weak_odr global [3 x i32] +// CHECK-NOT: @_ZN7PR100011SIiE3arr2E = weak_odr global [3 x i32]A + // CHECK-NOT: _ZTVN5test31SIiEE // CHECK-NOT: _ZTSN5test31SIiEE @@ -122,3 +128,27 @@ class B { // CHECK-NOT: _ZN6PR85051AILi0EE1B1fEv template class A<0>; } + +// Ensure that when instantiating initializers for static data members to +// complete their type in an unevaluated context, we *do* emit initializers with +// side-effects, but *don't* emit initializers and variables which are otherwise +// unused in the program. +namespace PR10001 { + template <typename T> struct S { + static const int arr[]; + static const int arr2[]; + static const int x, y; + static int f(); + }; + + extern int foo(); + extern int kBar; + + template <typename T> const int S<T>::arr[] = { 1, 2, foo() }; // possible side effects + template <typename T> const int S<T>::arr2[] = { 1, 2, kBar }; // no side effects + template <typename T> const int S<T>::x = sizeof(arr) / sizeof(arr[0]); + template <typename T> const int S<T>::y = sizeof(arr2) / sizeof(arr2[0]); + template <typename T> int S<T>::f() { return x + y; } + + int x = S<int>::f(); +} |