From 676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 Mon Sep 17 00:00:00 2001 From: Dimitry Andric Date: Sat, 19 Jan 2019 10:04:05 +0000 Subject: Vendor import of clang trunk r351319 (just before the release_80 branch point): https://llvm.org/svn/llvm-project/cfe/trunk@351319 --- test/CodeGenCXX/dllimport.cpp | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'test/CodeGenCXX/dllimport.cpp') diff --git a/test/CodeGenCXX/dllimport.cpp b/test/CodeGenCXX/dllimport.cpp index 74f58cc3b171..e9f0e4795f79 100644 --- a/test/CodeGenCXX/dllimport.cpp +++ b/test/CodeGenCXX/dllimport.cpp @@ -78,7 +78,7 @@ USEVAR(GlobalRedecl2c) // NB: MSC issues a warning and makes GlobalRedecl3 dllexport. We follow GCC // and drop the dllimport with a warning. // MSC-DAG: @"?GlobalRedecl3@@3HA" = external dso_local global i32 -// GNU-DAG: @GlobalRedecl3 = external dso_local global i32 +// GNU-DAG: @GlobalRedecl3 = external global i32 __declspec(dllimport) extern int GlobalRedecl3; extern int GlobalRedecl3; // dllimport ignored USEVAR(GlobalRedecl3) @@ -137,7 +137,7 @@ template __declspec(dllimport) int VarTmplRedecl2; USEVAR(VarTmplRedecl2) // MSC-DAG: @"??$VarTmplRedecl3@UImplicitInst_Imported@@@@3HA" = external dso_local global i32 -// GNU-DAG: @_Z14VarTmplRedecl3I21ImplicitInst_ImportedE = external dso_local global i32 +// GNU-DAG: @_Z14VarTmplRedecl3I21ImplicitInst_ImportedE = external global i32 template __declspec(dllimport) extern int VarTmplRedecl3; template extern int VarTmplRedecl3; // dllimport ignored USEVAR(VarTmplRedecl3) @@ -996,3 +996,26 @@ template struct __declspec(dllexport) ExplicitInstantiationDeclTemplateBase2, func) // M32-DAG: declare dllimport x86_thiscallcc void @"?func@?$ExplicitInstantiationDeclTemplateBase2@H@@QAEXXZ" // G32-DAG: define weak_odr dso_local x86_thiscallcc void @_ZN38ExplicitInstantiationDeclTemplateBase2IiE4funcEv + +namespace pr39496 { +// Make sure dll attribute are inherited by static locals also in template +// specializations. +template struct __declspec(dllimport) S { int foo() { static int x; return x++; } }; +int foo() { S s; return s.foo(); } +// MO1-DAG: @"?x@?{{1|2}}??foo@?$S@H@pr39496@@Q{{[A-Z]*}}HXZ@4HA" = available_externally dllimport global i32 0, align 4 + +template struct T { int foo() { static int x; return x++; } }; +extern template struct __declspec(dllimport) T; +int bar() { T t; return t.foo(); } +// MO1-DAG: @"?x@?{{1|2}}??foo@?$T@H@pr39496@@Q{{[A-Z]*}}HXZ@4HA" = available_externally dllimport global i32 0, align 4 + +template struct __declspec(dllimport) U { + void foo() { + // Don't inherit dllimport to src before attaching the initializer. + static constexpr char src[] = {"hello"}; + T arr[sizeof(src)]; + } +}; +void baz() { U u; u.foo(); } // No diagnostic. + +} -- cgit v1.3