/// When @p ForceRValue, we unconditionally treat the initializer as an rvalue.
bool
Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
+ SourceLocation DeclLoc,
bool SuppressUserConversions,
bool AllowExplicit, bool ForceRValue,
ImplicitConversionSequence *ICS) {
// Since we're performing this reference-initialization for
// real, update the initializer with the resulting function.
if (!ICS) {
- if (DiagnoseUseOfDecl(Fn, Init->getSourceRange().getBegin()))
+ if (DiagnoseUseOfDecl(Fn, DeclLoc))
return true;
FixOverloadedFunctionReference(Init, Fn);
// A&& r = b;
if (isRValRef && InitLvalue == Expr::LV_Valid) {
if (!ICS)
- Diag(Init->getSourceRange().getBegin(), diag::err_lvalue_to_rvalue_ref)
+ Diag(DeclLoc, diag::err_lvalue_to_rvalue_ref)
<< Init->getSourceRange();
return true;
}
}
OverloadCandidateSet::iterator Best;
- switch (BestViableFunction(CandidateSet, Init->getLocStart(), Best)) {
+ switch (BestViableFunction(CandidateSet, DeclLoc, Best)) {
case OR_Success:
// This is a direct binding.
BindsDirectly = true;
return false;
} else {
OwningExprResult InitConversion =
- BuildCXXCastArgument(Init->getLocStart(), QualType(),
+ BuildCXXCastArgument(DeclLoc, QualType(),
CastExpr::CK_UserDefinedConversion,
cast<CXXMethodDecl>(Best->Function),
Owned(Init));
// ambiguity (or inaccessibility) unless the reference binding
// actually happens.
if (DerivedToBase)
- return CheckDerivedToBaseConversion(T2, T1,
- Init->getSourceRange().getBegin(),
+ return CheckDerivedToBaseConversion(T2, T1, DeclLoc,
Init->getSourceRange());
else
return false;
// rvalue reference and the initializer expression shall be an rvalue.
if (!isRValRef && T1.getCVRQualifiers() != QualType::Const) {
if (!ICS)
- Diag(Init->getSourceRange().getBegin(),
- diag::err_not_reference_to_const_init)
+ Diag(DeclLoc, diag::err_not_reference_to_const_init)
<< T1 << (InitLvalue != Expr::LV_Valid? "temporary" : "value")
<< T2 << Init->getSourceRange();
return true;
// added qualification. But that wasn't the case, so the reference
// initialization fails.
if (!ICS)
- Diag(Init->getSourceRange().getBegin(),
- diag::err_reference_init_drops_quals)
+ Diag(DeclLoc, diag::err_reference_init_drops_quals)
<< T1 << (InitLvalue != Expr::LV_Valid? "temporary" : "value")
<< T2 << Init->getSourceRange();
return true;
if (SuppressUserConversions && RefRelationship == Ref_Incompatible &&
(T1->isRecordType() || T2->isRecordType())) {
if (!ICS)
- Diag(Init->getSourceRange().getBegin(),
- diag::err_typecheck_convert_incompatible)
+ Diag(DeclLoc, diag::err_typecheck_convert_incompatible)
<< DeclType << Init->getType() << "initializing" << Init->getSourceRange();
return true;
}
}
}
else
- Diag(Init->getSourceRange().getBegin(), diag::err_lvalue_to_rvalue_ref)
- << Init->getSourceRange();
+ Diag(DeclLoc, diag::err_lvalue_to_rvalue_ref)
+ << Init->getSourceRange();
}
return badConversion;
}
// conversion the reference must bind directly to E1.
if (!Self.CheckReferenceInit(From,
Self.Context.getLValueReferenceType(To->getType()),
+ To->getLocStart(),
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false,
// redoing all the work.
return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
TargetType(ICS)),
+ /*FIXME:*/E->getLocStart(),
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false);
"TryClassUnification should never generate indirect ref bindings");
return Self.CheckReferenceInit(E, Self.Context.getLValueReferenceType(
TargetType(ICS)),
+ /*FIXME:*/E->getLocStart(),
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false);
// (8.3.2), shall be initialized by an object, or function, of
// type T or by an object that can be converted into a T.
if (DeclType->isReferenceType())
- return CheckReferenceInit(Init, DeclType,
+ return CheckReferenceInit(Init, DeclType, InitLoc,
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/DirectInit,
/*ForceRValue=*/false);
Expr *savExpr = expr; // Might be promoted by CheckSingleInitializer.
if (SemaRef.CheckReferenceInit(expr, DeclType,
+ /*FIXME:*/expr->getLocStart(),
/*SuppressUserConversions=*/false,
/*AllowExplicit=*/false,
/*ForceRValue=*/false))