From 92d835a86ac334768d0b75936201e4fea3941c1f Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 26 Oct 2010 22:47:47 +0000 Subject: Patch to provide guard when initializing instances of static data member of a class template. Fixes //rdar :// 8562966 and pr8409. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117410 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../specialized-static-data-mem-init.cpp | 29 ++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/CodeGenCXX/specialized-static-data-mem-init.cpp (limited to 'test/CodeGenCXX/specialized-static-data-mem-init.cpp') diff --git a/test/CodeGenCXX/specialized-static-data-mem-init.cpp b/test/CodeGenCXX/specialized-static-data-mem-init.cpp new file mode 100644 index 0000000000..8f5765bcbb --- /dev/null +++ b/test/CodeGenCXX/specialized-static-data-mem-init.cpp @@ -0,0 +1,29 @@ +// RUN: %clang_cc1 %s -emit-llvm -o - | FileCheck %s +// rdar: // 8562966 +// pr8409 + +// CHECK: @_ZN1CIiE11needs_guardE = weak global +// CHECK: @_ZGVN1CIiE11needs_guardE = weak global + +struct K +{ + K(); + K(const K &); + ~K(); + void PrintNumK(); +}; + +template +struct C +{ + void Go() { needs_guard.PrintNumK(); } + static K needs_guard; +}; + +template K C::needs_guard; + +void F() +{ + C().Go(); +} + -- cgit v1.2.3-70-g09d2