summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclCXX.cpp
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2009-09-23 20:55:32 +0000
committerFariborz Jahanian <fjahanian@apple.com>2009-09-23 20:55:32 +0000
commitaf0262dccf6cce3585e96e9cd5160327846fc6ac (patch)
treea1313b2115702675e690f212ecc1d9bbe521d8eb /clang/lib/Sema/SemaDeclCXX.cpp
parent49f271afb39e6b1d8bf12ef1ee6807b744a8faf9 (diff)
downloadbcm5719-llvm-af0262dccf6cce3585e96e9cd5160327846fc6ac.tar.gz
bcm5719-llvm-af0262dccf6cce3585e96e9cd5160327846fc6ac.zip
This patch addresses a few issues related to 8.5.3 [dcl.init.ref]
It uses a recent API to find inherited conversion functions to do the initializer to reference lvalue conversion (and removes a FIXME). It issues the ambiguity diagnostics when multiple conversions are found. WIP. llvm-svn: 82649
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 1896fb0dc30..a4679e0e281 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -3478,7 +3478,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
OverloadCandidateSet CandidateSet;
OverloadedFunctionDecl *Conversions
- = T2RecordDecl->getConversionFunctions();
+ = T2RecordDecl->getVisibleConversionFunctions();
for (OverloadedFunctionDecl::function_iterator Func
= Conversions->function_begin();
Func != Conversions->function_end(); ++Func) {
@@ -3489,7 +3489,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
Conv = cast<CXXConversionDecl>(ConvTemplate->getTemplatedDecl());
else
Conv = cast<CXXConversionDecl>(*Func);
-
+
// If the conversion function doesn't return a reference type,
// it can't be considered for this conversion.
if (Conv->getConversionType()->isLValueReferenceType() &&
@@ -3688,7 +3688,27 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType,
}
return ICS->ConversionKind == ImplicitConversionSequence::BadConversion;
} else {
- return PerformImplicitConversion(Init, T1, "initializing");
+ ImplicitConversionSequence Conversions;
+ bool badConversion = PerformImplicitConversion(Init, T1, "initializing",
+ false, false,
+ Conversions);
+ if (badConversion) {
+ if ((Conversions.ConversionKind ==
+ ImplicitConversionSequence::BadConversion)
+ && Conversions.ConversionFunctionSet.size() > 0) {
+ Diag(Init->getSourceRange().getBegin(),
+ diag::err_lvalue_to_rvalue_ambig_ref) << Init->getSourceRange();
+ for (int j = Conversions.ConversionFunctionSet.size()-1;
+ j >= 0; j--) {
+ FunctionDecl *Func = Conversions.ConversionFunctionSet[j];
+ Diag(Func->getLocation(), diag::err_ovl_candidate);
+ }
+ }
+ else
+ Diag(Init->getSourceRange().getBegin(), diag::err_lvalue_to_rvalue_ref)
+ << Init->getSourceRange();
+ }
+ return badConversion;
}
}
OpenPOWER on IntegriCloud