From: Saar Raz Date: Wed, 22 Jan 2020 02:21:09 +0000 (+0200) Subject: [Concepts] Implement P1616R1 - Using unconstrained template template parameters with... X-Git-Tag: 2020.06-alpha~221^2~798 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d42d5eb8ea77b3a3a502a60ba3f053fb81a897f3;p=platform%2Fupstream%2Fllvm.git [Concepts] Implement P1616R1 - Using unconstrained template template parameters with constrained templates Summary: Allow unconstrained template template parameters to accept constrainted templates as arguments. Reviewers: rsmith Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73155 --- diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp index 2f44f8f08d08..05dde46fffd3 100755 --- a/clang/lib/Sema/SemaTemplate.cpp +++ b/clang/lib/Sema/SemaTemplate.cpp @@ -7164,6 +7164,11 @@ bool Sema::CheckTemplateTemplateArgument(TemplateTemplateParmDecl *Param, // [temp.constr.order]. SmallVector ParamsAC, TemplateAC; Params->getAssociatedConstraints(ParamsAC); + // C++2a[temp.arg.template]p3 + // [...] In this comparison, if P is unconstrained, the constraints on A + // are not considered. + if (ParamsAC.empty()) + return false; Template->getAssociatedConstraints(TemplateAC); bool IsParamAtLeastAsConstrained; if (IsAtLeastAsConstrained(Param, ParamsAC, Template, TemplateAC, diff --git a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp index 593336163fa1..e7feae31889e 100644 --- a/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp +++ b/clang/test/CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp @@ -7,9 +7,9 @@ template concept F = T::f(); // expected-note@-1{{similar constraint expressions not considered equivalent}} template class P> struct S1 { }; // expected-note 2{{'P' declared here}} -template struct X { }; // expected-note{{'X' declared here}} +template struct X { }; -template struct Y { }; // expected-note 2{{'Y' declared here}} +template struct Y { }; // expected-note{{'Y' declared here}} template struct Z { }; template struct W { }; // expected-note{{'W' declared here}} @@ -18,10 +18,10 @@ S1 s12; // expected-error{{template template argument 'Y' is more constrained S1 s13; S1 s14; // expected-error{{template template argument 'W' is more constrained than template template parameter 'P'}} -template class P> struct S2 { }; // expected-note 2{{'P' declared here}} +template class P> struct S2 { }; -S2 s21; // expected-error{{template template argument 'X' is more constrained than template template parameter 'P'}} -S2 s22; // expected-error{{template template argument 'Y' is more constrained than template template parameter 'P'}} +S2 s21; +S2 s22; S2 s23; template