summaryrefslogtreecommitdiffstats
path: root/test/SemaTemplate
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/deduction.cpp12
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp7
-rw-r--r--test/SemaTemplate/explicit-instantiation.cpp7
-rw-r--r--test/SemaTemplate/instantiate-decl-init.cpp24
-rw-r--r--test/SemaTemplate/instantiate-declref-ice.cpp2
-rw-r--r--test/SemaTemplate/instantiate-declref.cpp8
-rw-r--r--test/SemaTemplate/instantiate-expr-1.cpp25
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp6
-rw-r--r--test/SemaTemplate/instantiate-local-class.cpp18
-rw-r--r--test/SemaTemplate/instantiate-member-initializers.cpp2
-rw-r--r--test/SemaTemplate/instantiate-member-template.cpp25
-rw-r--r--test/SemaTemplate/member-function-template.cpp12
-rw-r--r--test/SemaTemplate/qualified-id.cpp15
-rw-r--r--test/SemaTemplate/recursive-template-instantiation.cpp2
-rw-r--r--test/SemaTemplate/temp_arg_nontype.cpp21
-rw-r--r--test/SemaTemplate/temp_class_spec.cpp13
-rw-r--r--test/SemaTemplate/template-id-expr.cpp17
-rw-r--r--test/SemaTemplate/typename-specifier-4.cpp31
18 files changed, 230 insertions, 17 deletions
diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp
index 375d199..8d00bb7 100644
--- a/test/SemaTemplate/deduction.cpp
+++ b/test/SemaTemplate/deduction.cpp
@@ -86,3 +86,15 @@ int array4[is_same<Replace<vector<int, _2>, double, float>::type, vector<int, fl
template <typename T, int N> void f(const T (&a)[N]);
int iarr[] = { 1 };
void test_PR5911() { f(iarr); }
+
+// Must not examine base classes of incomplete type during template argument
+// deduction.
+namespace PR6257 {
+ template <typename T> struct X {
+ template <typename U> X(const X<U>& u);
+ };
+ struct A;
+ void f(A& a);
+ void f(const X<A>& a);
+ void test(A& a) { (void)f(a); }
+}
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index 131b80c..3da43fa 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -177,3 +177,10 @@ namespace PR5810 {
X<float> x; // expected-note{{member function}}
}
}
+
+template<typename T> void f4(T, int = 17);
+template<> void f4<int>(int, int);
+
+void f4_test(int i) {
+ f4(i);
+}
diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp
index 227856f..de51f09 100644
--- a/test/SemaTemplate/explicit-instantiation.cpp
+++ b/test/SemaTemplate/explicit-instantiation.cpp
@@ -76,3 +76,10 @@ template void print_type<double>(double*);
// PR5069
template<int I> void foo0 (int (&)[I + 1]) { }
template void foo0<2> (int (&)[3]);
+
+namespace explicit_instantiation_after_implicit_instantiation {
+ template <int I> struct X0 { static int x; };
+ template <int I> int X0<I>::x;
+ void test1() { (void)&X0<1>::x; }
+ template struct X0<1>;
+}
diff --git a/test/SemaTemplate/instantiate-decl-init.cpp b/test/SemaTemplate/instantiate-decl-init.cpp
index b0c2aa8..6b76d72 100644
--- a/test/SemaTemplate/instantiate-decl-init.cpp
+++ b/test/SemaTemplate/instantiate-decl-init.cpp
@@ -20,3 +20,27 @@ void fn(T t, const arg& arg) {
void test() {
fn(1, arg());
}
+
+struct X0 { };
+
+struct X1 {
+ explicit X1(const X0 &x0 = X0());
+};
+
+template<typename T>
+void f0() {
+ X1 x1;
+}
+
+template void f0<int>();
+template void f0<float>();
+
+struct NonTrivial {
+ NonTrivial();
+ ~NonTrivial();
+};
+
+template<int N> void f1() {
+ NonTrivial array[N];
+}
+template<> void f1<2>();
diff --git a/test/SemaTemplate/instantiate-declref-ice.cpp b/test/SemaTemplate/instantiate-declref-ice.cpp
index e4e071d..e88b494 100644
--- a/test/SemaTemplate/instantiate-declref-ice.cpp
+++ b/test/SemaTemplate/instantiate-declref-ice.cpp
@@ -1,5 +1,4 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-
template<int i> struct x {
static const int j = i;
x<j>* y;
@@ -10,7 +9,6 @@ const int x<i>::j;
int array0[x<2>::j];
-
template<typename T>
struct X0 {
static const unsigned value = sizeof(T);
diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp
index da8b263..f883b93 100644
--- a/test/SemaTemplate/instantiate-declref.cpp
+++ b/test/SemaTemplate/instantiate-declref.cpp
@@ -87,3 +87,11 @@ struct smart_ptr {
void test_smart_ptr(smart_ptr<int> p) {
if (p) { }
}
+
+// PR5517
+namespace test0 {
+ template <int K> struct X {
+ X() { extern void x(); }
+ };
+ void g() { X<2>(); }
+}
diff --git a/test/SemaTemplate/instantiate-expr-1.cpp b/test/SemaTemplate/instantiate-expr-1.cpp
index 663749d..d1b05f6 100644
--- a/test/SemaTemplate/instantiate-expr-1.cpp
+++ b/test/SemaTemplate/instantiate-expr-1.cpp
@@ -87,6 +87,18 @@ void add(const T &x) {
(void)(x + x);
}
+namespace PR6237 {
+ template <typename T>
+ void f(T t) {
+ t++;
+ }
+
+ struct B { };
+ B operator++(B &, int);
+
+ template void f(B);
+}
+
struct Addable {
Addable operator+(const Addable&) const;
};
@@ -112,3 +124,16 @@ void test_call_operator(CallOperator call_op, int i, double d) {
int &ir = test_call_operator<int&>(call_op, i);
double &dr = test_call_operator<double&>(call_op, d);
}
+
+template<typename T>
+void test_asm(T t) {
+ asm ("nop" : "=a"(*t) : "r"(*t)); // expected-error {{indirection requires pointer operand ('int' invalid)}}
+}
+
+void test_asm() {
+ int* a;
+ test_asm(a);
+
+ int b;
+ test_asm(b); // expected-note {{in instantiation of function template specialization 'test_asm<int>' requested here}}
+}
diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp
index 428ef1b..c5eb3cc 100644
--- a/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/test/SemaTemplate/instantiate-expr-4.cpp
@@ -173,8 +173,8 @@ struct is_pod {
static const bool value = __is_pod(T);
};
-static const int is_pod0[is_pod<X>::value? -1 : 1];
-static const int is_pod1[is_pod<Y>::value? 1 : -1];
+static int is_pod0[is_pod<X>::value? -1 : 1];
+static int is_pod1[is_pod<Y>::value? 1 : -1];
// ---------------------------------------------------------------------
// initializer lists
@@ -197,7 +197,7 @@ template struct InitList1<APair, int*>;
template<typename T, typename Val1, typename Val2>
struct InitList2 {
void f(Val1 val1, Val2 val2) {
- T x = { val1, val2 }; // expected-error{{incompatible}}
+ T x = { val1, val2 }; // expected-error{{cannot initialize}}
}
};
diff --git a/test/SemaTemplate/instantiate-local-class.cpp b/test/SemaTemplate/instantiate-local-class.cpp
index 768eb21..72ad90a 100644
--- a/test/SemaTemplate/instantiate-local-class.cpp
+++ b/test/SemaTemplate/instantiate-local-class.cpp
@@ -32,3 +32,21 @@ namespace PR5764 {
}
}
+// Instantiation of local classes with virtual functions.
+namespace local_class_with_virtual_functions {
+ template <typename T> struct X { };
+ template <typename T> struct Y { };
+
+ template <typename T>
+ void f() {
+ struct Z : public X<Y<T>*> {
+ virtual void g(Y<T>* y) { }
+ void g2(int x) {(void)x;}
+ };
+ Z z;
+ (void)z;
+ }
+
+ struct S { };
+ void test() { f<S>(); }
+}
diff --git a/test/SemaTemplate/instantiate-member-initializers.cpp b/test/SemaTemplate/instantiate-member-initializers.cpp
index f7b7e47..eecb445 100644
--- a/test/SemaTemplate/instantiate-member-initializers.cpp
+++ b/test/SemaTemplate/instantiate-member-initializers.cpp
@@ -1,7 +1,7 @@
// RUN: %clang_cc1 -fsyntax-only -Wall -verify %s
template<typename T> struct A {
- A() : a(1) { } // expected-error{{incompatible type passing 'int', expected 'void *'}}
+ A() : a(1) { } // expected-error{{cannot initialize a member subobject of type 'void *' with an rvalue of type 'int'}}
T a;
};
diff --git a/test/SemaTemplate/instantiate-member-template.cpp b/test/SemaTemplate/instantiate-member-template.cpp
index b4f0a9c..c1260cf 100644
--- a/test/SemaTemplate/instantiate-member-template.cpp
+++ b/test/SemaTemplate/instantiate-member-template.cpp
@@ -131,3 +131,28 @@ namespace N0 {
x1.f(x0l);
}
}
+
+namespace PR6239 {
+ template <typename T>
+ struct X0 {
+ class type {
+ typedef T E;
+ template <E e> // subsitute T for E and bug goes away
+ struct sfinae { };
+
+ template <class U>
+ typename sfinae<&U::operator=>::type test(int);
+ };
+ };
+
+ template <typename T>
+ struct X1 {
+ typedef T E;
+ template <E e> // subsitute T for E and bug goes away
+ struct sfinae { };
+
+ template <class U>
+ typename sfinae<&U::operator=>::type test(int);
+ };
+
+}
diff --git a/test/SemaTemplate/member-function-template.cpp b/test/SemaTemplate/member-function-template.cpp
index 5ea8c101..aea6285 100644
--- a/test/SemaTemplate/member-function-template.cpp
+++ b/test/SemaTemplate/member-function-template.cpp
@@ -73,3 +73,15 @@ void test_incomplete_access(X1<int> *x1, X2<int> *x2) {
float &fr = x1->get<float>();
(void)x2->get<float>(); // expected-error{{implicit instantiation of undefined template}}
}
+
+// Instantiation of template template parameters in a member function
+// template.
+namespace TTP {
+ template<int Dim> struct X {
+ template<template<class> class M, class T> void f(const M<T>&);
+ };
+
+ template<typename T> struct Y { };
+
+ void test_f(X<3> x, Y<int> y) { x.f(y); }
+}
diff --git a/test/SemaTemplate/qualified-id.cpp b/test/SemaTemplate/qualified-id.cpp
index 655a80e..2e3a826 100644
--- a/test/SemaTemplate/qualified-id.cpp
+++ b/test/SemaTemplate/qualified-id.cpp
@@ -29,3 +29,18 @@ namespace test2 {
}
};
}
+
+namespace PR6063 {
+ template <typename T> void f(T, T);
+
+ namespace detail
+ {
+ using PR6063::f;
+ }
+
+ template <typename T>
+ void g(T a, T b)
+ {
+ detail::f(a, b);
+ }
+}
diff --git a/test/SemaTemplate/recursive-template-instantiation.cpp b/test/SemaTemplate/recursive-template-instantiation.cpp
index 0ddedaf..d6a0b24 100644
--- a/test/SemaTemplate/recursive-template-instantiation.cpp
+++ b/test/SemaTemplate/recursive-template-instantiation.cpp
@@ -1,6 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
-template<typename T> void f(T* t) { // expected-note{{candidate function}}
+template<typename T> void f(T* t) { // expected-note{{failed template argument deduction}}
f(*t); // expected-error{{no matching function}}\
// expected-note 3{{requested here}}
}
diff --git a/test/SemaTemplate/temp_arg_nontype.cpp b/test/SemaTemplate/temp_arg_nontype.cpp
index 133b8db..fdfd4e4 100644
--- a/test/SemaTemplate/temp_arg_nontype.cpp
+++ b/test/SemaTemplate/temp_arg_nontype.cpp
@@ -34,16 +34,6 @@ public:
};
A<X(17, 42)> *a11; // expected-error{{non-type template argument of type 'class X' must have an integral or enumeration type}}
-template<X const *Ptr> struct A2;
-
-X *X_ptr;
-X an_X;
-X array_of_Xs[10];
-A2<X_ptr> *a12;
-A2<array_of_Xs> *a13;
-A2<&an_X> *a13_2;
-A2<(&an_X)> *a13_3; // expected-error{{non-type template argument cannot be surrounded by parentheses}}
-
float f(float);
float g(float);
@@ -67,6 +57,7 @@ struct Y { } y;
volatile X * X_volatile_ptr;
template<X const &AnX> struct A4; // expected-note 2{{template parameter is declared here}}
+X an_X;
A4<an_X> *a15_1; // okay
A4<*X_volatile_ptr> *a15_2; // expected-error{{reference binding of non-type template parameter of type 'class X const &' to template argument of type 'class X volatile' ignores qualifiers}}
A4<y> *15_3; // expected-error{{non-type template parameter of reference type 'class X const &' cannot bind to template argument of type 'struct Y'}} \
@@ -170,3 +161,13 @@ struct X1 {
void test_X0_X1() {
X0<X1::pfunc> x01;
}
+
+// PR6249
+namespace pr6249 {
+ template<typename T, T (*func)()> T f() {
+ return func();
+ }
+
+ int h();
+ template int f<int, h>();
+}
diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp
index e86f07a..8a07fd7 100644
--- a/test/SemaTemplate/temp_class_spec.cpp
+++ b/test/SemaTemplate/temp_class_spec.cpp
@@ -348,3 +348,16 @@ namespace PR6025 {
{
};
}
+
+namespace PR6181 {
+ template <class T>
+ class a;
+
+ class s;
+
+ template <class U>
+ class a<s> // expected-error{{partial specialization of 'a' does not use any of its template parameters}}
+ {
+ };
+
+}
diff --git a/test/SemaTemplate/template-id-expr.cpp b/test/SemaTemplate/template-id-expr.cpp
index 70a1062..b3f41be 100644
--- a/test/SemaTemplate/template-id-expr.cpp
+++ b/test/SemaTemplate/template-id-expr.cpp
@@ -27,3 +27,20 @@ struct X0 {
void test_X0_int(X0<int> xi, float f) {
xi.f2(f);
}
+
+// Not template-id expressions, but they almost look like it.
+template<typename F>
+struct Y {
+ Y(const F&);
+};
+
+template<int I>
+struct X {
+ X(int, int);
+ void f() {
+ Y<X<I> >(X<I>(0, 0));
+ Y<X<I> >(::X<I>(0, 0));
+ }
+};
+
+template struct X<3>;
diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp
index 7fd88f13..0a6fef7 100644
--- a/test/SemaTemplate/typename-specifier-4.cpp
+++ b/test/SemaTemplate/typename-specifier-4.cpp
@@ -68,3 +68,34 @@ struct X0 {
void f2(typename X0<T>::Inner<T*, T&>::type); // expected-note{{here}}
void f2(typename X0<T>::template Inner<T*, T&>::type); // expected-error{{redecl}}
};
+
+namespace PR6236 {
+ template<typename T, typename U> struct S { };
+
+ template<typename T> struct S<T, T> {
+ template<typename U> struct K { };
+
+ void f() {
+ typedef typename S<T, T>::template K<T> Foo;
+ }
+ };
+}
+
+namespace PR6268 {
+ template <typename T>
+ struct Outer {
+ template <typename U>
+ struct Inner {};
+
+ template <typename U>
+ typename Outer<T>::template Inner<U>
+ foo(typename Outer<T>::template Inner<U>);
+ };
+
+ template <typename T>
+ template <typename U>
+ typename Outer<T>::template Inner<U>
+ Outer<T>::foo(typename Outer<T>::template Inner<U>) {
+ return Inner<U>();
+ }
+}
OpenPOWER on IntegriCloud