[PATCH] D18495: Check default arguments of template template parameters for compatibility.

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 26 21:31:42 PDT 2016

rsmith added inline comments.

Comment at: lib/Sema/SemaTemplate.cpp:793-800
@@ -792,10 +792,2 @@
   if (!Default.isInvalid()) {
-    // Check only that we have a template template argument. We don't want to
-    // try to check well-formedness now, because our template template parameter
-    // might have dependent types in its template parameters, which we wouldn't
-    // be able to match now.
-    //
-    // If none of the template template parameter's template arguments mention
-    // other template parameters, we could actually perform more checking here.
-    // However, it isn't worth doing.
     TemplateArgumentLoc DefaultArg = translateTemplateArgument(*this, Default);
You don't appear to have added any test coverage for these cases. Are there existing tests for this? Something like:

  template<typename T, template<T> typename A>
  struct X {
    template<template<int> typename = A> struct Y {};

Similar cases exist where the template template parameter has a parameter pack and is used as a default template argument for a template template parameter that takes a non-pack.

Comment at: test/CXX/temp/temp.arg/temp.arg.template/p3-0x.cpp:73-74
@@ +72,4 @@
+struct A {
+  template<class U, template<U, class> //expected-note{{declared here}}
+      class UU = TT> //expected-error{{different template parameters}}
+  struct B;
This looks like a rejects-valid. Consider:

  template<int, class> struct Q;
  A<Q>::B<int> b;

Here, `TT` refers to `Q`, which is valid as a template template argument for parameter `UU`.


More information about the cfe-commits mailing list