summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-10-23 19:23:15 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-10-23 19:23:15 +0000
commitc057f423a079bf67942cd1e4b3c29953bbd48703 (patch)
treeb19e5e959b3eb67d9c06c048272ffe9fd8bb48a1 /clang/lib
parent4bd90e53c292b73d51301600bd8eada862693dfc (diff)
downloadbcm5719-llvm-c057f423a079bf67942cd1e4b3c29953bbd48703.tar.gz
bcm5719-llvm-c057f423a079bf67942cd1e4b3c29953bbd48703.zip
Apply the special enum restrictions from [over.match.oper]p3b2 in argument-dependent lookup too. This fixes PR5244.
llvm-svn: 84963
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Sema/Sema.h2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp4
-rw-r--r--clang/lib/Sema/SemaLookup.cpp14
-rw-r--r--clang/lib/Sema/SemaOverload.cpp4
-rw-r--r--clang/lib/Sema/TreeTransform.h3
5 files changed, 19 insertions, 8 deletions
diff --git a/clang/lib/Sema/Sema.h b/clang/lib/Sema/Sema.h
index 6dd081bdc25..7f3c49acc8b 100644
--- a/clang/lib/Sema/Sema.h
+++ b/clang/lib/Sema/Sema.h
@@ -1377,7 +1377,7 @@ public:
QualType T1, QualType T2,
FunctionSet &Functions);
- void ArgumentDependentLookup(DeclarationName Name,
+ void ArgumentDependentLookup(DeclarationName Name, bool Operator,
Expr **Args, unsigned NumArgs,
FunctionSet &Functions);
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index accdc7e5c85..490c73896ed 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5435,7 +5435,7 @@ Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc,
Expr *Args[2] = { lhs, rhs };
DeclarationName OpName
= Context.DeclarationNames.getCXXOperatorName(OverOp);
- ArgumentDependentLookup(OpName, Args, 2, Functions);
+ ArgumentDependentLookup(OpName, /*Operator*/true, Args, 2, Functions);
}
// Build the (potentially-overloaded, potentially-dependent)
@@ -5553,7 +5553,7 @@ Action::OwningExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc,
Functions);
DeclarationName OpName
= Context.DeclarationNames.getCXXOperatorName(OverOp);
- ArgumentDependentLookup(OpName, &Input, 1, Functions);
+ ArgumentDependentLookup(OpName, /*Operator*/true, &Input, 1, Functions);
}
return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, move(input));
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index dd877c16fba..abed5d4d170 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1561,7 +1561,7 @@ static void CollectFunctionDecl(Sema::FunctionSet &Functions,
Functions.insert(FunTmpl);
}
-void Sema::ArgumentDependentLookup(DeclarationName Name,
+void Sema::ArgumentDependentLookup(DeclarationName Name, bool Operator,
Expr **Args, unsigned NumArgs,
FunctionSet &Functions) {
// Find all of the associated namespaces and classes based on the
@@ -1572,6 +1572,13 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
AssociatedNamespaces,
AssociatedClasses);
+ QualType T1, T2;
+ if (Operator) {
+ T1 = Args[0]->getType();
+ if (NumArgs >= 2)
+ T2 = Args[1]->getType();
+ }
+
// C++ [basic.lookup.argdep]p3:
// Let X be the lookup set produced by unqualified lookup (3.4.1)
// and let Y be the lookup set produced by argument dependent
@@ -1608,7 +1615,10 @@ void Sema::ArgumentDependentLookup(DeclarationName Name,
continue;
}
- CollectFunctionDecl(Functions, D);
+ FunctionDecl *Fn;
+ if (!Operator || !(Fn = dyn_cast<FunctionDecl>(D)) ||
+ IsAcceptableNonMemberOperatorCandidate(Fn, T1, T2, Context))
+ CollectFunctionDecl(Functions, D);
}
}
}
diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 9e79b999e7f..5e946eb7621 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -2761,7 +2761,7 @@ void Sema::AddOperatorCandidates(OverloadedOperatorKind Op, Scope *S,
DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(Op);
if (S)
LookupOverloadedOperatorName(Op, S, T1, T2, Functions);
- ArgumentDependentLookup(OpName, Args, NumArgs, Functions);
+ ArgumentDependentLookup(OpName, /*Operator*/true, Args, NumArgs, Functions);
AddFunctionCandidates(Functions, Args, NumArgs, CandidateSet);
AddMemberOperatorCandidates(Op, OpLoc, Args, NumArgs, CandidateSet, OpRange);
AddBuiltinOperatorCandidates(Op, OpLoc, Args, NumArgs, CandidateSet);
@@ -3908,7 +3908,7 @@ Sema::AddArgumentDependentLookupCandidates(DeclarationName Name,
}
// FIXME: Pass in the explicit template arguments?
- ArgumentDependentLookup(Name, Args, NumArgs, Functions);
+ ArgumentDependentLookup(Name, /*Operator*/false, Args, NumArgs, Functions);
// Erase all of the candidates we already knew about.
// FIXME: This is suboptimal. Is there a better way?
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 94a0e11ec8e..872b3c0189b 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -5107,7 +5107,8 @@ TreeTransform<Derived>::RebuildCXXOperatorCallExpr(OverloadedOperatorKind Op,
unsigned NumArgs = 1 + (SecondExpr != 0);
DeclarationName OpName
= SemaRef.Context.DeclarationNames.getCXXOperatorName(Op);
- SemaRef.ArgumentDependentLookup(OpName, Args, NumArgs, Functions);
+ SemaRef.ArgumentDependentLookup(OpName, /*Operator*/true, Args, NumArgs,
+ Functions);
// Create the overloaded operator invocation for unary operators.
if (NumArgs == 1 || isPostIncDec) {
OpenPOWER on IntegriCloud