diff options
author | Hans Wennborg <hans@hanshq.net> | 2016-05-26 19:42:56 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2016-05-26 19:42:56 +0000 |
commit | 0cbd9c038bb8e45179007c0dc0196659bb478c76 (patch) | |
tree | 29b838af00fdcda9392a1ca75ee7d551d95566fc /test/CodeGenCXX/explicit-instantiation.cpp | |
parent | 687d95f5fbef7af7e0a5b5b6b0aa0ff3c31de13f (diff) |
Re-commit r270748 "clang-cl: Treat dllimport explicit template instantiation definitions as declarations (PR27810, PR27811)"
Also make explicit instantiation decls not apply to nested classes when
targeting MSVC. That dll attributes are not inherited by inner classes
might be the explanation for MSVC's behaviour here.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270897 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGenCXX/explicit-instantiation.cpp')
-rw-r--r-- | test/CodeGenCXX/explicit-instantiation.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/test/CodeGenCXX/explicit-instantiation.cpp b/test/CodeGenCXX/explicit-instantiation.cpp index 6076444c25..7e00d78e48 100644 --- a/test/CodeGenCXX/explicit-instantiation.cpp +++ b/test/CodeGenCXX/explicit-instantiation.cpp @@ -1,5 +1,6 @@ // RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -std=c++1y -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NO-OPT // RUN: %clang_cc1 -emit-llvm -triple i686-pc-linux-gnu -std=c++1y -O3 -disable-llvm-optzns -o - %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-OPT +// RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -std=c++1y -o - %s | FileCheck %s --check-prefix=CHECK-MS // This check logically is attached to 'template int S<int>::i;' below. // CHECK: @_ZN1SIiE1iE = weak_odr global i32 @@ -103,6 +104,28 @@ int g() { return S<int>().f(); } template struct S<int>; } +namespace NestedClasses { + // Check how explicit instantiation of an outer class affects the inner class. + template <typename T> struct Outer { + struct Inner { + void f() {} + }; + }; + + // Explicit instantiation definition of Outer causes explicit instantiation + // definition of Inner. + template struct Outer<int>; + // CHECK: define weak_odr void @_ZN13NestedClasses5OuterIiE5Inner1fEv + // CHECK-MS: define weak_odr x86_thiscallcc void @"\01?f@Inner@?$Outer@H@NestedClasses@@QAEXXZ" + + // Explicit instantiation declaration of Outer causes explicit instantiation + // declaration of Inner, but not in MSVC mode. + extern template struct Outer<char>; + auto use = &Outer<char>::Inner::f; + // CHECK: {{declare|define available_externally}} void @_ZN13NestedClasses5OuterIcE5Inner1fEv + // CHECK-MS: define linkonce_odr x86_thiscallcc void @"\01?f@Inner@?$Outer@D@NestedClasses@@QAEXXZ" +} + // Check that we emit definitions from explicit instantiations even when they // occur prior to the definition itself. template <typename T> struct S { |