diff options
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r-- | test/SemaTemplate/class-template-decl.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/deduction.cpp | 12 | ||||
-rw-r--r-- | test/SemaTemplate/default-arguments.cpp | 15 | ||||
-rw-r--r-- | test/SemaTemplate/dependent-names-no-std.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/dependent-names.cpp | 42 | ||||
-rw-r--r-- | test/SemaTemplate/ext-vector-type.cpp | 34 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-call.cpp | 2 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-function-2.cpp | 33 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-member-class.cpp | 14 | ||||
-rw-r--r-- | test/SemaTemplate/instantiate-try-catch.cpp | 17 | ||||
-rw-r--r-- | test/SemaTemplate/member-inclass-init-value-dependent.cpp | 11 | ||||
-rw-r--r-- | test/SemaTemplate/unresolved-construct.cpp | 19 |
12 files changed, 194 insertions, 9 deletions
diff --git a/test/SemaTemplate/class-template-decl.cpp b/test/SemaTemplate/class-template-decl.cpp index e7722123f9c2..2e84e93ead97 100644 --- a/test/SemaTemplate/class-template-decl.cpp +++ b/test/SemaTemplate/class-template-decl.cpp @@ -50,7 +50,7 @@ void f() { template<typename T> class X; // expected-error{{expression}} } -template<typename T> class X1 { } var; // expected-error{{declared as a template}} +template<typename T> class X1 var; // expected-error{{declared as a template}} namespace M { } diff --git a/test/SemaTemplate/deduction.cpp b/test/SemaTemplate/deduction.cpp index 15c061c26198..aecb5ee7c8b3 100644 --- a/test/SemaTemplate/deduction.cpp +++ b/test/SemaTemplate/deduction.cpp @@ -150,3 +150,15 @@ namespace test3 { } }; } + +// Verify that we can deduce enum-typed arguments correctly. +namespace test14 { + enum E { E0, E1 }; + template <E> struct A {}; + template <E e> void foo(const A<e> &a) {} + + void test() { + A<E0> a; + foo(a); + } +} diff --git a/test/SemaTemplate/default-arguments.cpp b/test/SemaTemplate/default-arguments.cpp index 9ea0fc2e4d52..6391369aa5c4 100644 --- a/test/SemaTemplate/default-arguments.cpp +++ b/test/SemaTemplate/default-arguments.cpp @@ -121,3 +121,18 @@ X6<long, X5b> x6c; template<template<class> class X = B<int> > struct X7; // expected-error{{must be a class template}} + +namespace PR9643 { + template<typename T> class allocator {}; + template<typename T, typename U = allocator<T> > class vector {}; + + template<template<typename U, typename = allocator<U> > class container, + typename DT> + container<DT> initializer(const DT& d) { + return container<DT>(); + } + + void f() { + vector<int, allocator<int> > v = initializer<vector>(5); + } +} diff --git a/test/SemaTemplate/dependent-names-no-std.cpp b/test/SemaTemplate/dependent-names-no-std.cpp index e9ac99faf65b..2fb9d9909f75 100644 --- a/test/SemaTemplate/dependent-names-no-std.cpp +++ b/test/SemaTemplate/dependent-names-no-std.cpp @@ -11,7 +11,7 @@ namespace PR10053 { template<typename T> struct A { T t; A() { - f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}} + f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}} } }; diff --git a/test/SemaTemplate/dependent-names.cpp b/test/SemaTemplate/dependent-names.cpp index 2a50df5b7f14..7bab5d18d1ad 100644 --- a/test/SemaTemplate/dependent-names.cpp +++ b/test/SemaTemplate/dependent-names.cpp @@ -148,7 +148,7 @@ namespace PR10053 { template<typename T> struct A { T t; A() { - f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}} + f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}} } }; @@ -160,7 +160,7 @@ namespace PR10053 { namespace N { namespace M { template<typename T> int g(T t) { - f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument dependent lookup}} + f(t); // expected-error {{call to function 'f' that is neither visible in the template definition nor found by argument-dependent lookup}} }; } @@ -187,7 +187,7 @@ namespace PR10053 { // Example from www/compatibility.html namespace my_file { template <typename T> T Squared(T x) { - return Multiply(x, x); // expected-error {{neither visible in the template definition nor found by argument dependent lookup}} + return Multiply(x, x); // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} } int Multiply(int x, int y) { // expected-note {{should be declared prior to the call site}} @@ -203,7 +203,7 @@ namespace PR10053 { namespace my_file2 { template<typename T> void Dump(const T& value) { - std::cout << value << "\n"; // expected-error {{neither visible in the template definition nor found by argument dependent lookup}} + std::cout << value << "\n"; // expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} } namespace ns { @@ -222,7 +222,7 @@ namespace PR10053 { namespace my_file2_a { template<typename T> void Dump(const T &value) { - print(std::cout, value); // expected-error 4{{neither visible in the template definition nor found by argument dependent lookup}} + print(std::cout, value); // expected-error 4{{neither visible in the template definition nor found by argument-dependent lookup}} } namespace ns { @@ -248,7 +248,7 @@ namespace PR10053 { namespace unary { template<typename T> T Negate(const T& value) { - return !value; // expected-error {{call to function 'operator!' that is neither visible in the template definition nor found by argument dependent lookup}} + return !value; // expected-error {{call to function 'operator!' that is neither visible in the template definition nor found by argument-dependent lookup}} } namespace ns { @@ -262,3 +262,33 @@ namespace PR10053 { } } } + +namespace PR10187 { + namespace A { + template<typename T> + struct S { + void f() { + for (auto &a : e) + __range(a); // expected-error {{undeclared identifier '__range'}} + } + int e[10]; + }; + void g() { + S<int>().f(); // expected-note {{here}} + } + } + + namespace B { + template<typename T> void g(); // expected-note {{not viable}} + template<typename T> void f() { + g<int>(T()); // expected-error {{no matching function}} + } + + namespace { + struct S {}; + } + void g(S); + + template void f<S>(); // expected-note {{here}} + } +} diff --git a/test/SemaTemplate/ext-vector-type.cpp b/test/SemaTemplate/ext-vector-type.cpp index 7334e88e9267..f968c13f1023 100644 --- a/test/SemaTemplate/ext-vector-type.cpp +++ b/test/SemaTemplate/ext-vector-type.cpp @@ -58,3 +58,37 @@ int test_make6() { y.x = -1; y.w = -1; // expected-error{{vector component access exceeds type}} } + +namespace Deduction { + template<typename T> struct X0; + + template<typename T, unsigned N> + struct X0<T __attribute__((ext_vector_type(N)))> { + static const unsigned value = 0; + }; + + template<typename T> + struct X0<T __attribute__((ext_vector_type(4)))> { + static const unsigned value = 1; + }; + + template<unsigned N> + struct X0<float __attribute__((ext_vector_type(N)))> { + static const unsigned value = 2; + }; + + template<> + struct X0<float __attribute__((ext_vector_type(4)))> { + static const unsigned value = 3; + }; + + typedef int __attribute__((ext_vector_type(2))) int2; + typedef int __attribute__((ext_vector_type(4))) int4; + typedef float __attribute__((ext_vector_type(2))) float2; + typedef float __attribute__((ext_vector_type(4))) float4; + + int array0[X0<int2>::value == 0? 1 : -1]; + int array1[X0<int4>::value == 1? 1 : -1]; + int array2[X0<float2>::value == 2? 1 : -1]; + int array3[X0<float4>::value == 3? 1 : -1]; +} diff --git a/test/SemaTemplate/instantiate-call.cpp b/test/SemaTemplate/instantiate-call.cpp index a0e48c8dec77..da1eb49eb89e 100644 --- a/test/SemaTemplate/instantiate-call.cpp +++ b/test/SemaTemplate/instantiate-call.cpp @@ -25,7 +25,7 @@ namespace N3 { struct call_f0 { void test_f0(T t) { Result &result = f0(t); // expected-error {{undeclared identifier}} \ - expected-error {{neither visible in the template definition nor found by argument dependent lookup}} + expected-error {{neither visible in the template definition nor found by argument-dependent lookup}} } }; } diff --git a/test/SemaTemplate/instantiate-function-2.cpp b/test/SemaTemplate/instantiate-function-2.cpp index ebc0ef3a9f96..087ede2b89cb 100644 --- a/test/SemaTemplate/instantiate-function-2.cpp +++ b/test/SemaTemplate/instantiate-function-2.cpp @@ -31,3 +31,36 @@ namespace UsedAttr { foo<int>(); // expected-note{{instantiation of}} } } + +namespace PR9654 { + typedef void ftype(int); + + template<typename T> + ftype f; + + void g() { + f<int>(0); + } +} + +namespace AliasTagDef { + template<typename T> + T f() { + using S = struct { // expected-warning {{C++0x}} + T g() { + return T(); + } + }; + return S().g(); + } + + int n = f<int>(); +} + +namespace PR10273 { + template<typename T> void (f)(T t) {} + + void g() { + (f)(17); + } +} diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp index 74c2609dcd0f..1028b45cc0e1 100644 --- a/test/SemaTemplate/instantiate-member-class.cpp +++ b/test/SemaTemplate/instantiate-member-class.cpp @@ -104,3 +104,17 @@ namespace test2 { }; template class C<int>; } + +namespace AliasTagDef { + template<typename T> + struct F { + using S = struct U { // expected-warning {{C++0x}} + T g() { + return T(); + } + }; + }; + + int m = F<int>::S().g(); + int n = F<int>::U().g(); +} diff --git a/test/SemaTemplate/instantiate-try-catch.cpp b/test/SemaTemplate/instantiate-try-catch.cpp index 1c6c26f2586e..f4ce0e173146 100644 --- a/test/SemaTemplate/instantiate-try-catch.cpp +++ b/test/SemaTemplate/instantiate-try-catch.cpp @@ -12,3 +12,20 @@ template struct TryCatch0<int&>; // okay template struct TryCatch0<int&&>; // expected-note{{instantiation}} template struct TryCatch0<int>; // expected-note{{instantiation}} + +namespace PR10232 { + template <typename T> + class Templated { + struct Exception { + private: + Exception(const Exception&); // expected-note{{declared private here}} + }; + void exception() { + try { + } catch(Exception e) { // expected-error{{calling a private constructor of class 'PR10232::Templated<int>::Exception'}} + } + } + }; + + template class Templated<int>; // expected-note{{in instantiation of member function 'PR10232::Templated<int>::exception' requested here}} +} diff --git a/test/SemaTemplate/member-inclass-init-value-dependent.cpp b/test/SemaTemplate/member-inclass-init-value-dependent.cpp new file mode 100644 index 000000000000..d1ae4f2ded5f --- /dev/null +++ b/test/SemaTemplate/member-inclass-init-value-dependent.cpp @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -emit-llvm-only %s +// PR10290 + +template<int Flags> struct foo { + int value = Flags && 0; +}; + +void test() { + foo<4> bar; +} + diff --git a/test/SemaTemplate/unresolved-construct.cpp b/test/SemaTemplate/unresolved-construct.cpp new file mode 100644 index 000000000000..0d1ba17a0179 --- /dev/null +++ b/test/SemaTemplate/unresolved-construct.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -std=c++0x -fsyntax-only -verify %s +class A +{ +public: + A() {} + + template <class _F> + explicit A(_F&& __f); + + A(A&&) {} + A& operator=(A&&) {return *this;} +}; + +template <class T> +void f(T t) +{ + A a; + a = f(t); +} |