summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorGeorge Burgess IV <george.burgess.iv@gmail.com>2015-10-12 18:40:58 +0000
committerGeorge Burgess IV <george.burgess.iv@gmail.com>2015-10-12 18:40:58 +0000
commit5f2ef457bfb1dbfdb34f05d4075089e937678936 (patch)
treecf99940773cb993333e1ebd1c0710d0bb0c58bab /clang/lib/Sema
parent61e13de40859751d0c605d7509eeb5a99cf7e9c1 (diff)
downloadbcm5719-llvm-5f2ef457bfb1dbfdb34f05d4075089e937678936.tar.gz
bcm5719-llvm-5f2ef457bfb1dbfdb34f05d4075089e937678936.zip
[Sema] Don't emit multiple diags for one error
Fixed a bug where we'd emit multiple diagnostics if there was a problem taking the address of an overloaded template function. Differential Revision: http://reviews.llvm.org/D13664 llvm-svn: 250078
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaOverload.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a9259bb0756..b646c853561 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -9911,6 +9911,7 @@ class AddressOfFunctionResolver {
bool TargetTypeIsNonStaticMemberFunction;
bool FoundNonTemplateFunction;
bool StaticMemberFunctionFromBoundPointer;
+ bool HasComplained;
OverloadExpr::FindResult OvlExprInfo;
OverloadExpr *OvlExpr;
@@ -9927,6 +9928,7 @@ public:
!!TargetType->getAs<MemberPointerType>()),
FoundNonTemplateFunction(false),
StaticMemberFunctionFromBoundPointer(false),
+ HasComplained(false),
OvlExprInfo(OverloadExpr::find(SourceExpr)),
OvlExpr(OvlExprInfo.Expression),
FailedCandidates(OvlExpr->getNameLoc()) {
@@ -9977,7 +9979,9 @@ public:
Matches.size() > 1)
EliminateSuboptimalCudaMatches();
}
-
+
+ bool hasComplained() const { return HasComplained; }
+
private:
bool isTargetTypeAFunction() const {
return TargetFunctionType->isFunctionType();
@@ -10057,8 +10061,10 @@ private:
// now.
if (S.getLangOpts().CPlusPlus14 &&
FunDecl->getReturnType()->isUndeducedType() &&
- S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain))
+ S.DeduceReturnType(FunDecl, SourceExpr->getLocStart(), Complain)) {
+ HasComplained |= Complain;
return false;
+ }
QualType ResultTy;
if (Context.hasSameUnqualifiedType(TargetFunctionType,
@@ -10140,7 +10146,8 @@ private:
Matches[0].first = Matches[Result - MatchesCopy.begin()].first;
Matches[0].second = cast<FunctionDecl>(*Result);
Matches.resize(1);
- }
+ } else
+ HasComplained |= Complain;
}
void EliminateAllTemplateMatches() {
@@ -10261,13 +10268,14 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr,
Complain);
int NumMatches = Resolver.getNumMatches();
FunctionDecl *Fn = nullptr;
- if (NumMatches == 0 && Complain) {
+ bool ShouldComplain = Complain && !Resolver.hasComplained();
+ if (NumMatches == 0 && ShouldComplain) {
if (Resolver.IsInvalidFormOfPointerToMemberFunction())
Resolver.ComplainIsInvalidFormOfPointerToMemberFunction();
else
Resolver.ComplainNoMatchesFound();
}
- else if (NumMatches > 1 && Complain)
+ else if (NumMatches > 1 && ShouldComplain)
Resolver.ComplainMultipleMatchesFound();
else if (NumMatches == 1) {
Fn = Resolver.getMatchingFunctionDecl();
OpenPOWER on IntegriCloud