summaryrefslogtreecommitdiff
path: root/test/SemaTemplate
diff options
context:
space:
mode:
Diffstat (limited to 'test/SemaTemplate')
-rw-r--r--test/SemaTemplate/implicit-instantiation-1.cpp11
-rw-r--r--test/SemaTemplate/operator-template.cpp14
-rw-r--r--test/SemaTemplate/temp_arg_template.cpp4
-rw-r--r--test/SemaTemplate/template-decl-fail.cpp3
4 files changed, 29 insertions, 3 deletions
diff --git a/test/SemaTemplate/implicit-instantiation-1.cpp b/test/SemaTemplate/implicit-instantiation-1.cpp
index eecaf2f6c7999..b8f9622001e11 100644
--- a/test/SemaTemplate/implicit-instantiation-1.cpp
+++ b/test/SemaTemplate/implicit-instantiation-1.cpp
@@ -1,5 +1,4 @@
// RUN: clang-cc -fsyntax-only -verify %s
-
template<typename T, typename U>
struct X {
T f(T x, U y) { return x + y; }
@@ -14,3 +13,13 @@ void test(X<int, int> *xii, X<int*, int> *xpi, X<int, int*> *xip) {
(void)xip->g(2, 0); // okay: does not instantiate
}
+template<typename T, typename U>
+T add(T t, U u) {
+ return t + u; // expected-error{{invalid operands}}
+}
+
+void test_add(char *cp, int i, int *ip) {
+ char* cp2 = add(cp, i);
+ add(cp, cp); // expected-note{{instantiation of}}
+ (void)sizeof(add(ip, ip));
+} \ No newline at end of file
diff --git a/test/SemaTemplate/operator-template.cpp b/test/SemaTemplate/operator-template.cpp
new file mode 100644
index 0000000000000..3d041ec13a329
--- /dev/null
+++ b/test/SemaTemplate/operator-template.cpp
@@ -0,0 +1,14 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+// Make sure we accept this
+template<class X>struct A{typedef X Y;};
+template<class X>bool operator==(A<X>,typename A<X>::Y);
+int a(A<int> x) { return operator==(x,1); }
+
+// FIXME: The diagnostic here is a bit messed up
+template<class X>struct B{typedef X Y;};
+template<class X>bool operator==(B<X>*,typename B<X>::Y); // \
+expected-error{{overloaded 'operator==' must have at least one parameter of class or enumeration type}} \
+expected-note{{in instantiation of default argument for 'operator==<int>' required here}}
+int a(B<int> x) { return operator==(&x,1); }
+
diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp
index a5e9f75fa77a9..f2ee66b3f731a 100644
--- a/test/SemaTemplate/temp_arg_template.cpp
+++ b/test/SemaTemplate/temp_arg_template.cpp
@@ -26,12 +26,12 @@ B<X> *a6; // expected-error{{template template argument has different template p
C<Y> *a7;
C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}}
-template<typename T> void f(int);
+template<typename T> void f(int); // expected-note{{function template}}
// FIXME: we're right to provide an error message, but it should say
// that we need a class template. We won't get this right until name
// lookup of 'f' returns a TemplateDecl.
-A<f> *a9; // expected-error{{template argument for template template parameter must be a template}}
+A<f> *a9; // expected-error{{template argument does not refer to}}
// FIXME: The code below is ill-formed, because of the evil digraph '<:'.
// We should provide a much better error message than we currently do.
diff --git a/test/SemaTemplate/template-decl-fail.cpp b/test/SemaTemplate/template-decl-fail.cpp
new file mode 100644
index 0000000000000..b136f6279d52d
--- /dev/null
+++ b/test/SemaTemplate/template-decl-fail.cpp
@@ -0,0 +1,3 @@
+// RUN: clang-cc -fsyntax-only -verify %s
+
+template<typename T> typedef T X; // expected-error{{typedef cannot be a template}}