forked from OSchip/llvm-project
parent
0b51c729c9
commit
f0647a5fbc
|
@ -791,6 +791,8 @@ public:
|
||||||
OverloadCandidateSet& Conversions,
|
OverloadCandidateSet& Conversions,
|
||||||
bool AllowConversionFunctions,
|
bool AllowConversionFunctions,
|
||||||
bool AllowExplicit, bool ForceRValue);
|
bool AllowExplicit, bool ForceRValue);
|
||||||
|
bool DiagnoseAmbiguousUserDefinedConversion(Expr *From, QualType ToType);
|
||||||
|
|
||||||
|
|
||||||
ImplicitConversionSequence::CompareKind
|
ImplicitConversionSequence::CompareKind
|
||||||
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
|
CompareImplicitConversionSequences(const ImplicitConversionSequence& ICS1,
|
||||||
|
|
|
@ -1501,6 +1501,22 @@ Sema::OverloadingResult Sema::IsUserDefinedConversion(
|
||||||
|
|
||||||
return OR_No_Viable_Function;
|
return OR_No_Viable_Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
Sema::DiagnoseAmbiguousUserDefinedConversion(Expr *From, QualType ToType) {
|
||||||
|
ImplicitConversionSequence ICS;
|
||||||
|
OverloadCandidateSet CandidateSet;
|
||||||
|
OverloadingResult OvResult =
|
||||||
|
IsUserDefinedConversion(From, ToType, ICS.UserDefined,
|
||||||
|
CandidateSet, true, false, false);
|
||||||
|
if (OvResult != OR_Ambiguous)
|
||||||
|
return false;
|
||||||
|
Diag(From->getSourceRange().getBegin(),
|
||||||
|
diag::err_typecheck_ambiguous_condition)
|
||||||
|
<< From->getType() << ToType << From->getSourceRange();
|
||||||
|
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/// CompareImplicitConversionSequences - Compare two implicit
|
/// CompareImplicitConversionSequences - Compare two implicit
|
||||||
/// conversion sequences to determine whether one is better than the
|
/// conversion sequences to determine whether one is better than the
|
||||||
|
@ -1983,18 +1999,10 @@ bool Sema::PerformCopyInitialization(Expr *&From, QualType ToType,
|
||||||
if (!PerformImplicitConversion(From, ToType, Flavor,
|
if (!PerformImplicitConversion(From, ToType, Flavor,
|
||||||
/*AllowExplicit=*/false, Elidable))
|
/*AllowExplicit=*/false, Elidable))
|
||||||
return false;
|
return false;
|
||||||
ImplicitConversionSequence ICS;
|
if (!DiagnoseAmbiguousUserDefinedConversion(From, ToType))
|
||||||
OverloadCandidateSet CandidateSet;
|
|
||||||
if (IsUserDefinedConversion(From, ToType, ICS.UserDefined,
|
|
||||||
CandidateSet,
|
|
||||||
true, false, false) != OR_Ambiguous)
|
|
||||||
return Diag(From->getSourceRange().getBegin(),
|
return Diag(From->getSourceRange().getBegin(),
|
||||||
diag::err_typecheck_convert_incompatible)
|
diag::err_typecheck_convert_incompatible)
|
||||||
<< ToType << From->getType() << Flavor << From->getSourceRange();
|
<< ToType << From->getType() << Flavor << From->getSourceRange();
|
||||||
Diag(From->getSourceRange().getBegin(),
|
|
||||||
diag::err_typecheck_ambiguous_condition)
|
|
||||||
<< From->getType() << ToType << From->getSourceRange();
|
|
||||||
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2109,19 +2117,12 @@ bool Sema::PerformContextuallyConvertToBool(Expr *&From) {
|
||||||
ImplicitConversionSequence ICS = TryContextuallyConvertToBool(From);
|
ImplicitConversionSequence ICS = TryContextuallyConvertToBool(From);
|
||||||
if (!PerformImplicitConversion(From, Context.BoolTy, ICS, "converting"))
|
if (!PerformImplicitConversion(From, Context.BoolTy, ICS, "converting"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
OverloadCandidateSet CandidateSet;
|
if (!DiagnoseAmbiguousUserDefinedConversion(From, Context.BoolTy))
|
||||||
if (IsUserDefinedConversion(From, Context.BoolTy, ICS.UserDefined,
|
return Diag(From->getSourceRange().getBegin(),
|
||||||
CandidateSet,
|
diag::err_typecheck_bool_condition)
|
||||||
true, false, false) != OR_Ambiguous)
|
<< From->getType() << From->getSourceRange();
|
||||||
return Diag(From->getSourceRange().getBegin(),
|
return true;
|
||||||
diag::err_typecheck_bool_condition)
|
|
||||||
<< From->getType() << From->getSourceRange();
|
|
||||||
Diag(From->getSourceRange().getBegin(),
|
|
||||||
diag::err_typecheck_ambiguous_condition)
|
|
||||||
<< From->getType() << Context.BoolTy << From->getSourceRange();
|
|
||||||
PrintOverloadCandidates(CandidateSet, /*OnlyViable=*/false);
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// AddOverloadCandidate - Adds the given function to the set of
|
/// AddOverloadCandidate - Adds the given function to the set of
|
||||||
|
|
Loading…
Reference in New Issue