From ecb7e5c8afe929ee38155db94de6b084ec32a645 Mon Sep 17 00:00:00 2001 From: Roman Divacky Date: Tue, 16 Feb 2010 09:31:36 +0000 Subject: Update clang to r96341. --- test/SemaTemplate/deduction.cpp | 12 +++++++++ test/SemaTemplate/default-expr-arguments.cpp | 7 +++++ test/SemaTemplate/explicit-instantiation.cpp | 7 +++++ test/SemaTemplate/instantiate-decl-init.cpp | 24 +++++++++++++++++ test/SemaTemplate/instantiate-declref-ice.cpp | 2 -- test/SemaTemplate/instantiate-declref.cpp | 8 ++++++ test/SemaTemplate/instantiate-expr-1.cpp | 25 +++++++++++++++++ test/SemaTemplate/instantiate-expr-4.cpp | 6 ++--- test/SemaTemplate/instantiate-local-class.cpp | 18 +++++++++++++ .../instantiate-member-initializers.cpp | 2 +- test/SemaTemplate/instantiate-member-template.cpp | 25 +++++++++++++++++ test/SemaTemplate/member-function-template.cpp | 12 +++++++++ test/SemaTemplate/qualified-id.cpp | 15 +++++++++++ .../recursive-template-instantiation.cpp | 2 +- test/SemaTemplate/temp_arg_nontype.cpp | 21 ++++++++------- test/SemaTemplate/temp_class_spec.cpp | 13 +++++++++ test/SemaTemplate/template-id-expr.cpp | 17 ++++++++++++ test/SemaTemplate/typename-specifier-4.cpp | 31 ++++++++++++++++++++++ 18 files changed, 230 insertions(+), 17 deletions(-) (limited to 'test/SemaTemplate') diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 375d199f5899..8d00bb796e94 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -86,3 +86,15 @@ int array4[is_same, double, float>::type, vector 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 struct X { + template X(const X& u); + }; + struct A; + void f(A& a); + void f(const X& 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 131b80cb1f36..3da43fa67502 100644 --- a/test/SemaTemplate/default-expr-arguments.cpp +++ b/test/SemaTemplate/default-expr-arguments.cpp @@ -177,3 +177,10 @@ namespace PR5810 { X x; // expected-note{{member function}} } } + +template void f4(T, int = 17); +template<> void f4(int, int); + +void f4_test(int i) { + f4(i); +} diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp index 227856f1a8e2..de51f0992baa 100644 --- a/test/SemaTemplate/explicit-instantiation.cpp +++ b/test/SemaTemplate/explicit-instantiation.cpp @@ -76,3 +76,10 @@ template void print_type(double*); // PR5069 template void foo0 (int (&)[I + 1]) { } template void foo0<2> (int (&)[3]); + +namespace explicit_instantiation_after_implicit_instantiation { + template struct X0 { static int x; }; + template int X0::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 b0c2aa8afa91..6b76d72e3261 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 +void f0() { + X1 x1; +} + +template void f0(); +template void f0(); + +struct NonTrivial { + NonTrivial(); + ~NonTrivial(); +}; + +template 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 e4e071dd20d7..e88b49447cb9 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 struct x { static const int j = i; x* y; @@ -10,7 +9,6 @@ const int x::j; int array0[x<2>::j]; - template struct X0 { static const unsigned value = sizeof(T); diff --git a/test/SemaTemplate/instantiate-declref.cpp b/test/SemaTemplate/instantiate-declref.cpp index da8b263ab3ab..f883b9361b66 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 p) { if (p) { } } + +// PR5517 +namespace test0 { + template 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 663749ddce5b..d1b05f66a586 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 + 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(call_op, i); double &dr = test_call_operator(call_op, d); } + +template +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' requested here}} +} diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp index 428ef1ba8736..c5eb3cc53e7a 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::value? -1 : 1]; -static const int is_pod1[is_pod::value? 1 : -1]; +static int is_pod0[is_pod::value? -1 : 1]; +static int is_pod1[is_pod::value? 1 : -1]; // --------------------------------------------------------------------- // initializer lists @@ -197,7 +197,7 @@ template struct InitList1; template 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 768eb2170a15..72ad90a04f20 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 struct X { }; + template struct Y { }; + + template + void f() { + struct Z : public X*> { + virtual void g(Y* y) { } + void g2(int x) {(void)x;} + }; + Z z; + (void)z; + } + + struct S { }; + void test() { f(); } +} diff --git a/test/SemaTemplate/instantiate-member-initializers.cpp b/test/SemaTemplate/instantiate-member-initializers.cpp index f7b7e47e1e9b..eecb445ea923 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 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 b4f0a9c6509d..c1260cf6a81e 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 + struct X0 { + class type { + typedef T E; + template // subsitute T for E and bug goes away + struct sfinae { }; + + template + typename sfinae<&U::operator=>::type test(int); + }; + }; + + template + struct X1 { + typedef T E; + template // subsitute T for E and bug goes away + struct sfinae { }; + + template + typename sfinae<&U::operator=>::type test(int); + }; + +} diff --git a/test/SemaTemplate/member-function-template.cpp b/test/SemaTemplate/member-function-template.cpp index 5ea8c1010e5c..aea62855c225 100644 --- a/test/SemaTemplate/member-function-template.cpp +++ b/test/SemaTemplate/member-function-template.cpp @@ -73,3 +73,15 @@ void test_incomplete_access(X1 *x1, X2 *x2) { float &fr = x1->get(); (void)x2->get(); // expected-error{{implicit instantiation of undefined template}} } + +// Instantiation of template template parameters in a member function +// template. +namespace TTP { + template struct X { + template class M, class T> void f(const M&); + }; + + template struct Y { }; + + void test_f(X<3> x, Y y) { x.f(y); } +} diff --git a/test/SemaTemplate/qualified-id.cpp b/test/SemaTemplate/qualified-id.cpp index 655a80e2bfbf..2e3a826ce894 100644 --- a/test/SemaTemplate/qualified-id.cpp +++ b/test/SemaTemplate/qualified-id.cpp @@ -29,3 +29,18 @@ namespace test2 { } }; } + +namespace PR6063 { + template void f(T, T); + + namespace detail + { + using PR6063::f; + } + + template + 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 0ddedaf2354a..d6a0b247dd45 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 void f(T* t) { // expected-note{{candidate function}} +template 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 133b8db9491a..fdfd4e47b240 100644 --- a/test/SemaTemplate/temp_arg_nontype.cpp +++ b/test/SemaTemplate/temp_arg_nontype.cpp @@ -34,16 +34,6 @@ public: }; A *a11; // expected-error{{non-type template argument of type 'class X' must have an integral or enumeration type}} -template struct A2; - -X *X_ptr; -X an_X; -X array_of_Xs[10]; -A2 *a12; -A2 *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 struct A4; // expected-note 2{{template parameter is declared here}} +X an_X; A4 *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 *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 x01; } + +// PR6249 +namespace pr6249 { + template T f() { + return func(); + } + + int h(); + template int f(); +} diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp index e86f07a02ffe..8a07fd7292c2 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 a; + + class s; + + template + class a // 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 70a1062c2287..b3f41be7bfad 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 xi, float f) { xi.f2(f); } + +// Not template-id expressions, but they almost look like it. +template +struct Y { + Y(const F&); +}; + +template +struct X { + X(int, int); + void f() { + Y >(X(0, 0)); + Y >(::X(0, 0)); + } +}; + +template struct X<3>; diff --git a/test/SemaTemplate/typename-specifier-4.cpp b/test/SemaTemplate/typename-specifier-4.cpp index 7fd88f130fa6..0a6fef74c340 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::Inner::type); // expected-note{{here}} void f2(typename X0::template Inner::type); // expected-error{{redecl}} }; + +namespace PR6236 { + template struct S { }; + + template struct S { + template struct K { }; + + void f() { + typedef typename S::template K Foo; + } + }; +} + +namespace PR6268 { + template + struct Outer { + template + struct Inner {}; + + template + typename Outer::template Inner + foo(typename Outer::template Inner); + }; + + template + template + typename Outer::template Inner + Outer::foo(typename Outer::template Inner) { + return Inner(); + } +} -- cgit v1.3