mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-14 14:56:47 +00:00
Fix bug where types other than 'cv auto', 'cv auto &', and 'cv auto &&' could
incorrectly be deduced from an initializer list in pathological cases. llvm-svn: 291191
This commit is contained in:
parent
c92d206ce4
commit
c8a32e5ed2
@ -4127,6 +4127,12 @@ Sema::DeduceAutoType(TypeLoc Type, Expr *&Init, QualType &Result,
|
||||
|
||||
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),
|
||||
|
@ -337,3 +337,13 @@ namespace update_rbrace_loc_crash {
|
||||
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}}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user