forked from OSchip/llvm-project
Fix crash on init-capture packs where the type of the initializer is non-dependent.
This commit is contained in:
parent
b284005072
commit
f4a45c2ce4
|
@ -507,7 +507,8 @@ static void InitializeCPlusPlusFeatureTestMacros(const LangOptions &LangOpts,
|
||||||
if (LangOpts.CPlusPlus14) {
|
if (LangOpts.CPlusPlus14) {
|
||||||
Builder.defineMacro("__cpp_binary_literals", "201304L");
|
Builder.defineMacro("__cpp_binary_literals", "201304L");
|
||||||
Builder.defineMacro("__cpp_digit_separators", "201309L");
|
Builder.defineMacro("__cpp_digit_separators", "201309L");
|
||||||
Builder.defineMacro("__cpp_init_captures", "201304L"); // (not latest)
|
Builder.defineMacro("__cpp_init_captures",
|
||||||
|
LangOpts.CPlusPlus2a ? "201803L" : "201304L");
|
||||||
Builder.defineMacro("__cpp_generic_lambdas",
|
Builder.defineMacro("__cpp_generic_lambdas",
|
||||||
LangOpts.CPlusPlus2a ? "201707L" : "201304L");
|
LangOpts.CPlusPlus2a ? "201707L" : "201304L");
|
||||||
Builder.defineMacro("__cpp_decltype_auto", "201304L");
|
Builder.defineMacro("__cpp_decltype_auto", "201304L");
|
||||||
|
|
|
@ -4453,7 +4453,8 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType &Result,
|
||||||
/*.IsPack = */ (bool)Type.getAs<PackExpansionTypeLoc>()};
|
/*.IsPack = */ (bool)Type.getAs<PackExpansionTypeLoc>()};
|
||||||
|
|
||||||
if (!DependentDeductionDepth &&
|
if (!DependentDeductionDepth &&
|
||||||
(Type.getType()->isDependentType() || Init->isTypeDependent())) {
|
(Type.getType()->isDependentType() || Init->isTypeDependent() ||
|
||||||
|
Init->containsUnexpandedParameterPack())) {
|
||||||
Result = SubstituteDeducedTypeTransform(*this, DependentResult).Apply(Type);
|
Result = SubstituteDeducedTypeTransform(*this, DependentResult).Apply(Type);
|
||||||
assert(!Result.isNull() && "substituting DependentTy can't fail");
|
assert(!Result.isNull() && "substituting DependentTy can't fail");
|
||||||
return DAR_Succeeded;
|
return DAR_Succeeded;
|
||||||
|
|
|
@ -37,3 +37,11 @@ template<typename ...T> void f(T ...t) {
|
||||||
}... // expected-error {{does not contain any unexpanded}}
|
}... // expected-error {{does not contain any unexpanded}}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<int ...a> constexpr auto x = [...z = a] (auto F) { return F(z...); };
|
||||||
|
static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
|
||||||
|
static_assert(x<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}}
|
||||||
|
|
||||||
|
template<int ...a> constexpr auto y = [z = a...] (auto F) { return F(z...); }; // expected-error {{must appear before the name of the capture}}
|
||||||
|
static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 123);
|
||||||
|
static_assert(y<1,2,3>([](int a, int b, int c) { return 100 * a + 10 * b + c; }) == 124); // expected-error {{failed}}
|
||||||
|
|
|
@ -66,6 +66,8 @@
|
||||||
#error "wrong value for __cpp_impl_three_way_comparison"
|
#error "wrong value for __cpp_impl_three_way_comparison"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// init_captures checked below
|
||||||
|
|
||||||
// --- C++17 features ---
|
// --- C++17 features ---
|
||||||
|
|
||||||
#if check(hex_float, 0, 0, 0, 201603, 201603)
|
#if check(hex_float, 0, 0, 0, 201603, 201603)
|
||||||
|
@ -170,7 +172,7 @@
|
||||||
#error "wrong value for __cpp_digit_separators"
|
#error "wrong value for __cpp_digit_separators"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if check(init_captures, 0, 0, 201304, 201304, 201304)
|
#if check(init_captures, 0, 0, 201304, 201304, 201803)
|
||||||
#error "wrong value for __cpp_init_captures"
|
#error "wrong value for __cpp_init_captures"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue