diff options
author | Hans Wennborg <hans@hanshq.net> | 2014-06-04 21:09:46 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2014-06-04 21:09:46 +0000 |
commit | 7546b5a26229417222909d8c4c6e12d50c27e985 (patch) | |
tree | d0754231f862cd6429248a84a6a71980abea4e1d /test/CodeGenCXX | |
parent | e88163d87fc058590b6f0af25a2b5f2057723945 (diff) | |
download | clang-7546b5a26229417222909d8c4c6e12d50c27e985.tar.gz clang-7546b5a26229417222909d8c4c6e12d50c27e985.tar.bz2 clang-7546b5a26229417222909d8c4c6e12d50c27e985.tar.xz |
Don't dynamically initialize dllimport vars (PR19933)
They should be initialized when they're exported.
Differential Revision: http://reviews.llvm.org/D4020
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210217 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX')
-rw-r--r-- | test/CodeGenCXX/dllimport.cpp | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/test/CodeGenCXX/dllimport.cpp b/test/CodeGenCXX/dllimport.cpp index 70661a9426..004c07e9f6 100644 --- a/test/CodeGenCXX/dllimport.cpp +++ b/test/CodeGenCXX/dllimport.cpp @@ -5,6 +5,10 @@ // RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O1 -o - %s -DMSABI | FileCheck --check-prefix=MO1 %s // RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -emit-llvm -std=c++1y -O1 -o - %s | FileCheck --check-prefix=GO1 %s +// CHECK-NOT doesn't play nice with CHECK-DAG, so use separate run lines. +// RUN: %clang_cc1 -triple i686-windows-msvc -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s -DMSABI | FileCheck --check-prefix=MSC2 %s +// RUN: %clang_cc1 -triple i686-windows-gnu -fno-rtti -emit-llvm -std=c++1y -O0 -o - %s | FileCheck --check-prefix=GNU2 %s + // Helper structs to make templates more expressive. struct ImplicitInst_Imported {}; struct ImplicitInst_NotImported {}; @@ -219,6 +223,11 @@ USE(inlineDef) __declspec(dllimport) __attribute__((noinline)) inline void noinline() {} USE(noinline) +// MSC2-NOT: @"\01?alwaysInline@@YAXXZ"() +// GNU2-NOT: @_Z12alwaysInlinev() +__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {} +USE(alwaysInline) + // Redeclarations // MSC-DAG: declare dllimport void @"\01?redecl1@@YAXXZ"() // GNU-DAG: declare dllimport void @_Z7redecl1v() @@ -580,13 +589,26 @@ namespace ClassTemplateStaticDef { int f() { return S<int>::x; } } -//===----------------------------------------------------------------------===// -// Negative checks -//===----------------------------------------------------------------------===// - -// These checks are at the end to avoid interference with the DAG checks. - -// MSC-NOT: @"\01?alwaysInline@@YAXXZ"() -// GNU-NOT: @_Z12alwaysInlinev() -__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {} -USE(alwaysInline) +namespace PR19933 { +// Don't dynamically initialize dllimport vars. +// MSC2-NOT: @llvm.global_ctors +// GNU2-NOT: @llvm.global_ctors + + struct NonPOD { NonPOD(); }; + template <typename T> struct A { static NonPOD x; }; + template <typename T> NonPOD A<T>::x; + template struct __declspec(dllimport) A<int>; + // MSC-DAG: @"\01?x@?$A@H@PR19933@@2UNonPOD@2@A" = available_externally dllimport global %"struct.PR19933::NonPOD" zeroinitializer + + int f(); + template <typename T> struct B { static int x; }; + template <typename T> int B<T>::x = f(); + template struct __declspec(dllimport) B<int>; + // MSC-DAG: @"\01?x@?$B@H@PR19933@@2HA" = available_externally dllimport global i32 0 + + constexpr int g() { return 42; } + template <typename T> struct C { static int x; }; + template <typename T> int C<T>::x = g(); + template struct __declspec(dllimport) C<int>; + // MSC-DAG: @"\01?x@?$C@H@PR19933@@2HA" = available_externally dllimport global i32 42 +} |