Check template template arguments against their corresponding template
template parameters.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64188 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/test/SemaTemplate/temp_arg_template.cpp b/test/SemaTemplate/temp_arg_template.cpp
new file mode 100644
index 0000000..3e8e6f2
--- /dev/null
+++ b/test/SemaTemplate/temp_arg_template.cpp
@@ -0,0 +1,42 @@
+// RUN: clang -fsyntax-only -verify %s
+
+template<template<typename T> class X> struct A; // expected-note 2{{previous template template parameter is here}}
+
+template<template<typename T, int I> class X> struct B; // expected-note{{previous template template parameter is here}}
+
+template<template<int I> class X> struct C;  // expected-note{{previous non-type template parameter with type 'int' is here}}
+
+template<class> struct X; // expected-note{{too few template parameters in template template argument}}
+template<int N> struct Y; // expected-note{{template parameter has a different kind in template argument}}
+template<long N> struct Ylong; // expected-note{{template non-type parameter has a different type 'long' in template argument}}
+
+namespace N {
+  template<class> struct Z;
+}
+template<class, class> struct TooMany; // expected-note{{too many template parameters in template template argument}}
+
+
+A<X> *a1; 
+A<N::Z> *a2;
+A< ::N::Z> *a3;
+
+A<Y> *a4; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
+          // FIXME::expected-error{{expected unqualified-id}}
+A<TooMany> *a5; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
+          // FIXME::expected-error{{expected unqualified-id}}
+B<X> *a6; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
+          // FIXME::expected-error{{expected unqualified-id}}
+C<Y> *a7;
+C<Ylong> *a8; // expected-error{{template template argument has different template parameters than its corresponding template template parameter}} \
+          // FIXME::expected-error{{expected unqualified-id}}
+
+template<typename T> void f(int);
+
+// 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}}
+
+// FIXME: The code below is ill-formed, because of the evil digraph '<:'. 
+// We should provide a much better error message than we currently do.
+// A<::N::Z> *a10;