summaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
authorRoman Divacky <rdivacky@FreeBSD.org>2010-01-15 15:39:40 +0000
committerRoman Divacky <rdivacky@FreeBSD.org>2010-01-15 15:39:40 +0000
commitee791dde723a2089c681d2ab6a9d4f96379d5f49 (patch)
treea6082d4d1d1e9ddaea09a6a04bb4a47da95d642d /test/SemaTemplate
parentabe15e553e58165e7692c0d0842865c488ed7b45 (diff)
Notes
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/ambiguous-ovl-print.cpp2
-rw-r--r--test/SemaTemplate/constructor-template.cpp8
-rw-r--r--test/SemaTemplate/default-expr-arguments.cpp2
-rw-r--r--test/SemaTemplate/dependent-base-classes.cpp84
-rw-r--r--test/SemaTemplate/explicit-instantiation.cpp4
-rw-r--r--test/SemaTemplate/fun-template-def.cpp2
-rw-r--r--test/SemaTemplate/function-template-specialization.cpp8
-rw-r--r--test/SemaTemplate/injected-class-name.cpp6
-rw-r--r--test/SemaTemplate/instantiate-expr-4.cpp4
-rw-r--r--test/SemaTemplate/instantiate-member-class.cpp4
-rw-r--r--test/SemaTemplate/instantiate-member-expr.cpp24
-rw-r--r--test/SemaTemplate/instantiate-static-var.cpp2
-rw-r--r--test/SemaTemplate/instantiate-subscript.cpp2
-rw-r--r--test/SemaTemplate/temp_class_spec.cpp18
-rw-r--r--test/SemaTemplate/typo-dependent-name.cpp17
-rw-r--r--test/SemaTemplate/virtual-member-functions.cpp35
16 files changed, 201 insertions, 21 deletions
diff --git a/test/SemaTemplate/ambiguous-ovl-print.cpp b/test/SemaTemplate/ambiguous-ovl-print.cpp
index 17f412f6716d6..7e3fa24197eb2 100644
--- a/test/SemaTemplate/ambiguous-ovl-print.cpp
+++ b/test/SemaTemplate/ambiguous-ovl-print.cpp
@@ -2,7 +2,7 @@
void f(void*, int); // expected-note{{candidate function}}
template<typename T>
- void f(T*, long); // expected-note{{candidate function template}}
+ void f(T*, long); // expected-note{{candidate function}}
void test_f(int *ip, int i) {
f(ip, i); // expected-error{{ambiguous}}
diff --git a/test/SemaTemplate/constructor-template.cpp b/test/SemaTemplate/constructor-template.cpp
index 139de9d68605f..82c2aa4cc3e79 100644
--- a/test/SemaTemplate/constructor-template.cpp
+++ b/test/SemaTemplate/constructor-template.cpp
@@ -52,8 +52,8 @@ template <> struct A<int>{A(const A<int>&);};
struct B { A<int> x; B(B& a) : x(a.x) {} };
struct X2 {
- X2(); // expected-note{{candidate function}}
- X2(X2&); // expected-note {{candidate function}}
+ X2(); // expected-note{{candidate constructor}}
+ X2(X2&); // expected-note {{candidate constructor}}
template<typename T> X2(T);
};
@@ -71,9 +71,9 @@ struct X3 {
template<> X3::X3(X3); // expected-error{{must pass its first argument by reference}}
struct X4 {
- X4(); // expected-note{{candidate function}}
+ X4(); // expected-note{{candidate constructor}}
~X4();
- X4(X4&); // expected-note {{candidate function}}
+ X4(X4&); // expected-note {{candidate constructor}}
template<typename T> X4(const T&, int = 17);
};
diff --git a/test/SemaTemplate/default-expr-arguments.cpp b/test/SemaTemplate/default-expr-arguments.cpp
index 0edc504ea0a37..131b80cb1f36e 100644
--- a/test/SemaTemplate/default-expr-arguments.cpp
+++ b/test/SemaTemplate/default-expr-arguments.cpp
@@ -5,7 +5,7 @@ class C { C(int a0 = 0); };
template<>
C<char>::C(int a0);
-struct S { }; // expected-note 3 {{candidate function}}
+struct S { }; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
template<typename T> void f1(T a, T b = 10) { } // expected-error{{no viable conversion}}
diff --git a/test/SemaTemplate/dependent-base-classes.cpp b/test/SemaTemplate/dependent-base-classes.cpp
new file mode 100644
index 0000000000000..79b28c2239fe1
--- /dev/null
+++ b/test/SemaTemplate/dependent-base-classes.cpp
@@ -0,0 +1,84 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T, typename U>
+struct X0 : T::template apply<U> {
+ X0(U u) : T::template apply<U>(u) { }
+};
+
+template<typename T, typename U>
+struct X1 : T::apply<U> { }; // expected-error{{missing 'template' keyword prior to dependent template name 'T::apply'}}
+
+template<typename T>
+struct X2 : vector<T> { }; // expected-error{{unknown template name 'vector'}}
+
+namespace PR6031 {
+ template<typename T>
+ struct A;
+
+ template <class X>
+ struct C { };
+
+ template <class TT>
+ struct II {
+ typedef typename A<TT>::type type;
+ };
+
+ template <class TT>
+ struct FI : II<TT>
+ {
+ C<typename FI::type> a;
+ };
+
+ template <class TT>
+ struct FI2
+ {
+ C<typename FI2::type> a; // expected-error{{no type named 'type' in 'struct PR6031::FI2'}} \
+ // expected-error{{C++ requires a type specifier for all declarations}}
+ };
+
+ template<typename T>
+ struct Base {
+ class Nested { };
+ template<typename U> struct MemberTemplate { };
+ int a;
+ };
+
+ template<typename T>
+ struct HasDepBase : Base<T> {
+ int foo() {
+ class HasDepBase::Nested nested;
+ typedef typename HasDepBase::template MemberTemplate<T>::type type;
+ return HasDepBase::a;
+ }
+ };
+
+ template<typename T>
+ struct NoDepBase {
+ int foo() {
+ class NoDepBase::Nested nested; // expected-error{{'Nested' does not name a tag member in the specified scope}}
+ typedef typename NoDepBase::template MemberTemplate<T>::type type; // expected-error{{'MemberTemplate' following the 'template' keyword does not refer to a template}} \
+ // FIXME: expected-error{{expected an identifier or template-id after '::'}} \
+ // FIXME: expected-error{{unqualified-id}}
+ return NoDepBase::a; // expected-error{{no member named 'a' in 'struct PR6031::NoDepBase'}}
+ }
+ };
+}
+
+namespace Ambig {
+ template<typename T>
+ struct Base1 {
+ typedef int type; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ struct Base2 {
+ typedef float type; // expected-note{{member found by ambiguous name lookup}}
+ };
+
+ template<typename T>
+ struct Derived : Base1<T>, Base2 {
+ typedef typename Derived::type type; // expected-error{{member 'type' found in multiple base classes of different types}}
+ type *foo(float *fp) { return fp; }
+ };
+
+ Derived<int> di; // expected-note{{instantiation of}}
+}
diff --git a/test/SemaTemplate/explicit-instantiation.cpp b/test/SemaTemplate/explicit-instantiation.cpp
index fbb5edbefd6c2..227856f1a8e22 100644
--- a/test/SemaTemplate/explicit-instantiation.cpp
+++ b/test/SemaTemplate/explicit-instantiation.cpp
@@ -25,8 +25,8 @@ T X0<T>::value; // expected-error{{no matching constructor}}
template int X0<int>::value;
-struct NotDefaultConstructible { // expected-note{{candidate function}}
- NotDefaultConstructible(int); // expected-note{{candidate function}}
+struct NotDefaultConstructible { // expected-note{{candidate constructor (the implicit copy constructor)}}
+ NotDefaultConstructible(int); // expected-note{{candidate constructor}}
};
template NotDefaultConstructible X0<NotDefaultConstructible>::value; // expected-note{{instantiation}}
diff --git a/test/SemaTemplate/fun-template-def.cpp b/test/SemaTemplate/fun-template-def.cpp
index 0c2cf9c4f2e63..1c9b232f6d360 100644
--- a/test/SemaTemplate/fun-template-def.cpp
+++ b/test/SemaTemplate/fun-template-def.cpp
@@ -8,7 +8,7 @@
// Fake typeid, lacking a typeinfo header.
namespace std { class type_info {}; }
-struct dummy {}; // expected-note 3 {{candidate function}}
+struct dummy {}; // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
template<typename T>
int f0(T x) {
diff --git a/test/SemaTemplate/function-template-specialization.cpp b/test/SemaTemplate/function-template-specialization.cpp
index 91989b1ccae07..9afc99fe7d5e8 100644
--- a/test/SemaTemplate/function-template-specialization.cpp
+++ b/test/SemaTemplate/function-template-specialization.cpp
@@ -33,3 +33,11 @@ template<> void f2<double>(double (&array)[42]);
template<> void f2<42>(double (&array)[42]);
void f2<25>(double (&array)[25]); // expected-error{{specialization}}
+
+// PR5833
+namespace PR5833 {
+ template <typename T> bool f0(T &t1);
+ template <> bool f0<float>(float &t1);
+}
+template <> bool PR5833::f0<float>(float &t1) {}
+
diff --git a/test/SemaTemplate/injected-class-name.cpp b/test/SemaTemplate/injected-class-name.cpp
index 1a65aeb3d6cb5..482eae14ba596 100644
--- a/test/SemaTemplate/injected-class-name.cpp
+++ b/test/SemaTemplate/injected-class-name.cpp
@@ -11,11 +11,7 @@ struct X<int***> {
typedef X<int***> *ptr;
};
-// FIXME: EDG rejects this in their strict-conformance mode, but I
-// don't see any wording making this ill-formed. Actually,
-// [temp.local]p2 might make it ill-formed. Are we "in the scope of
-// the class template specialization?"
-X<float>::X<int> xi = x;
+X<float>::X<int> xi = x; // expected-error{{qualified reference to 'X' is a constructor name rather than a template name wherever a constructor can be declared}}
// [temp.local]p1:
diff --git a/test/SemaTemplate/instantiate-expr-4.cpp b/test/SemaTemplate/instantiate-expr-4.cpp
index c524e958f8a77..428ef1ba87366 100644
--- a/test/SemaTemplate/instantiate-expr-4.cpp
+++ b/test/SemaTemplate/instantiate-expr-4.cpp
@@ -21,8 +21,8 @@ struct FunctionalCast0 {
template struct FunctionalCast0<5>;
-struct X { // expected-note 3 {{candidate function}}
- X(int, int); // expected-note 3 {{candidate function}}
+struct X { // expected-note 3 {{candidate constructor (the implicit copy constructor)}}
+ X(int, int); // expected-note 3 {{candidate constructor}}
};
template<int N, int M>
diff --git a/test/SemaTemplate/instantiate-member-class.cpp b/test/SemaTemplate/instantiate-member-class.cpp
index 8a19d74cdde4a..742abcc569c2b 100644
--- a/test/SemaTemplate/instantiate-member-class.cpp
+++ b/test/SemaTemplate/instantiate-member-class.cpp
@@ -14,8 +14,8 @@ public:
X<int>::C *c1;
X<float>::C *c2;
-X<int>::X *xi;
-X<float>::X *xf;
+X<int>::X *xi; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
+X<float>::X *xf; // expected-error{{qualified reference to 'X' is a constructor name rather than a type wherever a constructor can be declared}}
void test_naming() {
c1 = c2; // expected-error{{incompatible type assigning 'X<float>::C *', expected 'X<int>::C *'}}
diff --git a/test/SemaTemplate/instantiate-member-expr.cpp b/test/SemaTemplate/instantiate-member-expr.cpp
index db13624d44267..324363ce96dca 100644
--- a/test/SemaTemplate/instantiate-member-expr.cpp
+++ b/test/SemaTemplate/instantiate-member-expr.cpp
@@ -25,3 +25,27 @@ class RetainReleaseChecker { };
void f(GRExprEngine& Eng) {
Eng.registerCheck(new RetainReleaseChecker); // expected-note {{in instantiation of function template specialization 'GRExprEngine::registerCheck<class RetainReleaseChecker>' requested here}}
}
+
+// PR 5838
+namespace test1 {
+ template<typename T> struct A {
+ int a;
+ };
+
+ template<typename T> struct B : A<float>, A<T> {
+ void f() {
+ a = 0; // should not be ambiguous
+ }
+ };
+ template struct B<int>;
+
+ struct O {
+ int a;
+ template<typename T> struct B : A<T> {
+ void f() {
+ a = 0; // expected-error {{type 'struct test1::O' is not a direct or virtual base of ''B<int>''}}
+ }
+ };
+ };
+ template struct O::B<int>; // expected-note {{in instantiation}}
+}
diff --git a/test/SemaTemplate/instantiate-static-var.cpp b/test/SemaTemplate/instantiate-static-var.cpp
index 8a2f34d475a76..789fe3db872ee 100644
--- a/test/SemaTemplate/instantiate-static-var.cpp
+++ b/test/SemaTemplate/instantiate-static-var.cpp
@@ -30,7 +30,7 @@ T Z<T>::value; // expected-error{{no matching constructor}}
struct DefCon {};
struct NoDefCon {
- NoDefCon(const NoDefCon&); // expected-note{{candidate function}}
+ NoDefCon(const NoDefCon&); // expected-note{{candidate constructor}}
};
void test() {
diff --git a/test/SemaTemplate/instantiate-subscript.cpp b/test/SemaTemplate/instantiate-subscript.cpp
index a7187516da398..8c119ec8c6de8 100644
--- a/test/SemaTemplate/instantiate-subscript.cpp
+++ b/test/SemaTemplate/instantiate-subscript.cpp
@@ -16,7 +16,7 @@ struct ConvertibleToInt {
template<typename T, typename U, typename Result>
struct Subscript0 {
void test(T t, U u) {
- Result &result = t[u]; // expected-error{{subscripted value is not}}
+ Result &result = t[u]; // expected-error{{no viable overloaded operator[] for type}}
}
};
diff --git a/test/SemaTemplate/temp_class_spec.cpp b/test/SemaTemplate/temp_class_spec.cpp
index 48026f913178f..e86f07a02ffe9 100644
--- a/test/SemaTemplate/temp_class_spec.cpp
+++ b/test/SemaTemplate/temp_class_spec.cpp
@@ -330,3 +330,21 @@ template<typename T, T N, typename U> class A0;
template<typename T, T N> class A0<T, N, int> { }; // expected-note{{here}}
template<typename T, T N> class A0<T, N, int>;
template<typename T, T N> class A0<T, N, int> { }; // expected-error{{redef}}
+
+namespace PR6025 {
+ template< int N > struct A;
+
+ namespace N
+ {
+ template< typename F >
+ struct B;
+ }
+
+ template< typename Protect, typename Second >
+ struct C;
+
+ template <class T>
+ struct C< T, A< N::B<T>::value > >
+ {
+ };
+}
diff --git a/test/SemaTemplate/typo-dependent-name.cpp b/test/SemaTemplate/typo-dependent-name.cpp
new file mode 100644
index 0000000000000..96554e9dcf4a4
--- /dev/null
+++ b/test/SemaTemplate/typo-dependent-name.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+template<typename T>
+struct Base {
+ T inner;
+};
+
+template<typename T>
+struct X {
+ template<typename U>
+ struct Inner {
+ };
+
+ bool f(T other) {
+ return this->inner < other;
+ }
+};
diff --git a/test/SemaTemplate/virtual-member-functions.cpp b/test/SemaTemplate/virtual-member-functions.cpp
index 69ae0807b4c5b..db243130bb3dd 100644
--- a/test/SemaTemplate/virtual-member-functions.cpp
+++ b/test/SemaTemplate/virtual-member-functions.cpp
@@ -3,14 +3,19 @@
namespace PR5557 {
template <class T> struct A {
A();
+ virtual void anchor(); // expected-note{{instantiation}}
virtual int a(T x);
};
template<class T> A<T>::A() {}
+template<class T> void A<T>::anchor() { }
+
template<class T> int A<T>::a(T x) {
return *x; // expected-error{{requires pointer operand}}
}
-A<int> x; // expected-note{{instantiation}}
+void f(A<int> x) {
+ x.anchor();
+}
template<typename T>
struct X {
@@ -20,3 +25,31 @@ struct X {
template<>
void X<int>::f() { }
}
+
+template<typename T>
+struct Base {
+ virtual ~Base() {
+ int *ptr = 0;
+ T t = ptr; // expected-error{{cannot initialize}}
+ }
+};
+
+template<typename T>
+struct Derived : Base<T> {
+ virtual void foo() { }
+};
+
+template struct Derived<int>; // expected-note{{instantiation}}
+
+template<typename T>
+struct HasOutOfLineKey {
+ HasOutOfLineKey() { } // expected-note{{in instantiation of member function 'HasOutOfLineKey<int>::f' requested here}}
+ virtual T *f(float *fp);
+};
+
+template<typename T>
+T *HasOutOfLineKey<T>::f(float *fp) {
+ return fp; // expected-error{{cannot initialize return object of type 'int *' with an lvalue of type 'float *'}}
+}
+
+HasOutOfLineKey<int> out_of_line;