summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX
diff options
context:
space:
mode:
authorSaar Raz <saar@raz.email>2020-01-31 15:55:06 +0200
committerSaar Raz <saar@raz.email>2020-01-31 16:00:41 +0200
commit3b32963252bc8580ad8237ded3814e2a6a2ba9b6 (patch)
treead3048a40aba5f5b1e1bdb8af02af201e9896bcc /clang/test/CXX
parent3573526c0286c9461f0459be1a4592b2214594e7 (diff)
downloadbcm5719-llvm-3b32963252bc8580ad8237ded3814e2a6a2ba9b6.tar.gz
bcm5719-llvm-3b32963252bc8580ad8237ded3814e2a6a2ba9b6.zip
[Concepts] Correctly form initial parameter mapping for parameter packs, support substitution into SubstNonTypeTemplateParmExpr
We previously would not correctly for the initial parameter mapping for variadic template parameters in Concepts. Testing this lead to the discovery that with the normalization process we would need to substitute into already-substituted-into template arguments, which means we need to add NonTypeTemplateParmExpr support to TemplateInstantiator. We do that by substituting into the replacement and the type separately, and then re-checking the expression against the NTTP with the new type, in order to form any new required implicit casts (for cases where the type of the NTTP was dependent). (cherry picked from commit ba1f3db4b0729ad932aa4f091e9578132d98a0c8)
Diffstat (limited to 'clang/test/CXX')
-rw-r--r--clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
index 95fe35b4591..153d4a56bea 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -16,3 +16,54 @@ template<typename T> requires Bar2<T> struct S2 { };
template<typename T> requires Bar2<T> && true struct S2<T> { };
// expected-error@-1{{class template partial specialization is not more specialized than the primary template}}
// expected-note@-2{{while calculating associated constraint of template 'S2' here}}
+
+namespace type_pack {
+ template<typename... Args>
+ concept C1 = ((sizeof(Args) >= 0) && ...);
+
+ template<typename A, typename... B>
+ concept C2 = C1<A, B...>;
+
+ template<typename T>
+ constexpr void foo() requires C2<T, char, T> { }
+
+ template<typename T>
+ constexpr void foo() requires C1<T, char, T> && true { }
+
+ static_assert((foo<int>(), true));
+}
+
+namespace template_pack {
+ template<typename T> struct S1 {};
+ template<typename T> struct S2 {};
+
+ template<template<typename> typename... Args>
+ concept C1 = ((sizeof(Args<int>) >= 0) && ...);
+
+ template<template<typename> typename A, template<typename> typename... B>
+ concept C2 = C1<A, B...>;
+
+ template<template<typename> typename T>
+ constexpr void foo() requires C2<T, S1, T> { }
+
+ template<template<typename> typename T>
+ constexpr void foo() requires C1<T, S1, T> && true { }
+
+ static_assert((foo<S2>(), true));
+}
+
+namespace non_type_pack {
+ template<int... Args>
+ concept C1 = ((Args >= 0) && ...);
+
+ template<int A, int... B>
+ concept C2 = C1<A, B...>;
+
+ template<int T>
+ constexpr void foo() requires C2<T, 2, T> { }
+
+ template<int T>
+ constexpr void foo() requires C1<T, 2, T> && true { }
+
+ static_assert((foo<1>(), true));
+}
OpenPOWER on IntegriCloud