InitListExpr *InitList = dyn_cast<InitListExpr>(Init);
if (InitList) {
+ // Notionally, we substitute std::initializer_list<T> for 'auto' and deduce
+ // against that. Such deduction only succeeds if removing cv-qualifiers and
+ // references results in std::initializer_list<T>.
+ if (!Type.getType().getNonReferenceType()->getAs<AutoType>())
+ return DAR_Failed;
+
for (unsigned i = 0, e = InitList->getNumInits(); i < e; ++i) {
if (DeduceTemplateArgumentsFromCallArgument(
*this, TemplateParamsSt.get(), TemplArg, InitList->getInit(i),
Explode<ContainsIncomplete, 4>([](int) {});
}
}
+
+namespace no_conversion_after_auto_list_deduction {
+ // We used to deduce 'auto' == 'std::initializer_list<X>' here, and then
+ // incorrectly accept the declaration of 'x'.
+ struct X { using T = std::initializer_list<X> X::*; operator T(); };
+ auto X::*x = { X() }; // expected-error {{from initializer list}}
+
+ struct Y { using T = std::initializer_list<Y>(*)(); operator T(); };
+ auto (*y)() = { Y() }; // expected-error {{from initializer list}}
+}