Ping.

On Mon, Jul 7, 2014 at 9:01 PM, Logan Chien <[email protected]>
wrote:

> Ping?
>
> This patch tries to fix an assertion failure related to the template alias
> with two (or more) parameter packs.  For example,
>
>
> template <typename... T> struct tuple;
> template <typename... T> struct extract_;
> template <typename... T> using extract = typename extract_<T...>::type;
>
> template <typename... A, typename... B>
> inline auto test(tuple<A...>&& xs, B&&... ys) -> extract<A&&..., B...> { }
>
> Please have a look, and feel free to let me know if there is any problem.
> Thanks!
>
> Sincerely,
> Logan
>
>
> On Mon, Jun 30, 2014 at 1:10 AM, Logan Chien <[email protected]>
> wrote:
>
>> Hi rsmith,
>>
>> If the template has two variadic formal parameters, then the type
>> might not be canonical.  We have call ASTContext.getCanonicalType()
>> to canonicalize the type; otherwise, an assertion failure will be
>> raised.
>>
>> This patch fix this issue by adding getCanonicalType() in
>> TransformTemplateTypeParmType.
>>
>> http://reviews.llvm.org/D4343
>>
>> Files:
>>   lib/Sema/SemaTemplateInstantiate.cpp
>>   test/SemaTemplate/alias-templates.cpp
>>
>> Index: lib/Sema/SemaTemplateInstantiate.cpp
>> ===================================================================
>> --- lib/Sema/SemaTemplateInstantiate.cpp
>> +++ lib/Sema/SemaTemplateInstantiate.cpp
>> @@ -1376,7 +1376,7 @@
>>      assert(Arg.getKind() == TemplateArgument::Type &&
>>             "Template argument kind mismatch");
>>
>> -    QualType Replacement = Arg.getAsType();
>> +    QualType Replacement =
>> getSema().Context.getCanonicalType(Arg.getAsType());
>>
>>      // TODO: only do this uniquing once, at the start of instantiation.
>>      QualType Result
>> Index: test/SemaTemplate/alias-templates.cpp
>> ===================================================================
>> --- test/SemaTemplate/alias-templates.cpp
>> +++ test/SemaTemplate/alias-templates.cpp
>> @@ -201,3 +201,17 @@
>>    template <typename T, typename U, typename V>
>>    using derived2 = ::PR16904::base<T, U>::template derived<V>; //
>> expected-error {{expected a type}} expected-error {{expected ';'}}
>>  }
>> +
>> +namespace VariadicTemplateAlias {
>> +  template <typename... T> struct tuple;
>> +  template <typename... T> struct extract_;
>> +
>> +  // Note: Both the template alias and the concatenation of variadic
>> template
>> +  // arguments A and B are required to trigger the assertion failure.
>> +
>> +  template <typename... T>
>> +  using extract = typename extract_<T...>::type;
>> +
>> +  template <typename... A, typename... B>
>> +  inline auto test(tuple<A...>&& xs, B&&... ys) -> extract<A&&..., B...>
>> { }
>> +}
>>
>
>
From a8cf42306c6092ba15ed6a13c8e738eb852bd55d Mon Sep 17 00:00:00 2001
From: Logan Chien <[email protected]>
Date: Mon, 30 Jun 2014 01:00:15 +0800
Subject: [PATCH] Canonicalize the variadic template alias with multiple
 ellipsis.

---
 lib/Sema/SemaTemplateInstantiate.cpp  |  2 +-
 test/SemaTemplate/alias-templates.cpp | 14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/lib/Sema/SemaTemplateInstantiate.cpp b/lib/Sema/SemaTemplateInstantiate.cpp
index 14c6405..c51ffd4 100644
--- a/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1376,7 +1376,7 @@ TemplateInstantiator::TransformTemplateTypeParmType(TypeLocBuilder &TLB,
     assert(Arg.getKind() == TemplateArgument::Type &&
            "Template argument kind mismatch");
 
-    QualType Replacement = Arg.getAsType();
+    QualType Replacement = getSema().Context.getCanonicalType(Arg.getAsType());
 
     // TODO: only do this uniquing once, at the start of instantiation.
     QualType Result
diff --git a/test/SemaTemplate/alias-templates.cpp b/test/SemaTemplate/alias-templates.cpp
index e7be184..c82b69e 100644
--- a/test/SemaTemplate/alias-templates.cpp
+++ b/test/SemaTemplate/alias-templates.cpp
@@ -201,3 +201,17 @@ namespace PR16904 {
   template <typename T, typename U, typename V>
   using derived2 = ::PR16904::base<T, U>::template derived<V>; // expected-error {{expected a type}} expected-error {{expected ';'}}
 }
+
+namespace VariadicTemplateAlias {
+  template <typename... T> struct tuple;
+  template <typename... T> struct extract_;
+
+  // Note: Both the template alias and the concatenation of variadic template
+  // arguments A and B are required to trigger the assertion failure.
+
+  template <typename... T>
+  using extract = typename extract_<T...>::type;
+
+  template <typename... A, typename... B>
+  inline auto test(tuple<A...>&& xs, B&&... ys) -> extract<A&&..., B...> { }
+}
-- 
1.9.1

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to