[PowerPC] Collect some CallLowering arguments into a struct. [NFC]
[llvm-project.git] / clang / test / SemaTemplate / partial-spec-instantiate.cpp
blob2fc0517ae3d3cfba5bbbfb4f1d53408dfc7744ba
1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
5 // PR4607
6 template <class T> struct X {};
8 template <> struct X<char>
10 static char* g();
13 template <class T> struct X2 {};
15 template <class U>
16 struct X2<U*> {
17 static void f() {
18 X<U>::g();
22 void a(char *a, char *b) {X2<char*>::f();}
24 namespace WonkyAccess {
25 template<typename T>
26 struct X {
27 int m;
30 template<typename U>
31 class Y;
33 template<typename U>
34 struct Y<U*> : X<U> { };
36 template<>
37 struct Y<float*> : X<float> { };
39 int f(Y<int*> y, Y<float*> y2) {
40 return y.m + y2.m;
44 // <rdar://problem/9169404>
45 namespace rdar9169404 {
46 template<typename T, T N> struct X { };
47 template<bool C> struct X<bool, C> {
48 typedef int type;
51 X<bool, -1>::type value;
52 #if __cplusplus >= 201103L
53 // expected-error@-2 {{non-type template argument evaluates to -1, which cannot be narrowed to type 'bool'}}
54 #else
55 // expected-no-diagnostics
56 #endif
59 // rdar://problem/39524996
60 namespace rdar39524996 {
61 template <typename T, typename U>
62 struct enable_if_not_same
64 typedef void type;
66 template <typename T>
67 struct enable_if_not_same<T, T>;
69 template <typename T>
70 struct Wrapper {
71 // Assertion triggered on trying to set twice the same partial specialization
72 // enable_if_not_same<int, int>
73 template <class U>
74 Wrapper(const Wrapper<U>& other,
75 typename enable_if_not_same<U, T>::type* = 0) {}
77 explicit Wrapper(int i) {}
80 template <class T>
81 struct Container {
82 // It is important that the struct has implicit copy and move constructors.
83 Container() : x() {}
85 template <class U>
86 Container(const Container<U>& other) : x(static_cast<T>(other.x)) {}
88 // Implicit constructors are member-wise, so the field triggers instantiation
89 // of T constructors and we instantiate all of them for overloading purposes.
90 T x;
93 void takesWrapperInContainer(const Container< Wrapper<int> >& c);
94 void test() {
95 // Type mismatch triggers initialization with conversion which requires
96 // implicit constructors to be instantiated.
97 Container<int> c;
98 takesWrapperInContainer(c);