Rudimentary checking of template arguments against their corresponding
template parameters when performing semantic analysis of a template-id
naming a class template specialization.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64185 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/temp_arg.cpp b/test/SemaTemplate/temp_arg.cpp
new file mode 100644
index 0000000..d62f681
--- /dev/null
+++ b/test/SemaTemplate/temp_arg.cpp
@@ -0,0 +1,13 @@
+// RUN: clang -fsyntax-only -verify %s
+template<typename T,
+ int I,
+ template<typename> class TT>
+ class A;
+
+template<typename> class X;
+
+A<int, 0, X> * a1;
+
+A<float, 1, X, double> *a2; // expected-error{{too many template arguments for class template 'A'}}
+
+A<float, 1> *a3; // expected-error{{too few template arguments for class template 'A'}}
diff --git a/test/SemaTemplate/temp_arg_type.cpp b/test/SemaTemplate/temp_arg_type.cpp
new file mode 100644
index 0000000..08b1032
--- /dev/null
+++ b/test/SemaTemplate/temp_arg_type.cpp
@@ -0,0 +1,27 @@
+// RUN: clang -fsyntax-only -verify %s
+template<typename T> class A; // expected-error 2 {{template parameter is declared here}}
+
+// [temp.arg.type]p1
+A<0> *a1; // expected-error{{template argument for template type parameter must be a type}}
+
+A<A> *a2; // expected-error{{template argument for template type parameter must be a type}}
+
+A<int> *a3;
+// FIXME: The two below are well-formed, but we're not parsing them as type-ids.
+// A<int()> *a4;
+// A<int(float)> *a5;
+A<A<int> > *a6;
+
+// [temp.arg.type]p2
+void f() {
+ class X { };
+ A<X> * a = 0; // expected-error{{template argument uses local type 'class X'}}\
+ // FIXME: expected-error{{expected expression}}
+}
+
+struct { int x; } Unnamed; // expected-note{{unnamed type used in template argument was declared here}}
+A<__typeof__(Unnamed)> *a7; // expected-error{{template argument uses unnamed type}} \
+ // FIXME: expected-error{{expected unqualified-id}}
+
+// FIXME: [temp.arg.type]p3. The check doesn't really belong here (it
+// belongs somewhere in the template instantiation section).