aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-11-09 21:07:58 +0000
committerDouglas Gregor <dgregor@apple.com>2010-11-09 21:07:58 +0000
commit7ad5d421d9f12bd287aa17fdb00e0f4d5971d76f (patch)
tree1fc71a77cde7fae6a3b4158f52749bb99bc57e52 /lib/Sema/SemaExpr.cpp
parentdf81c2c6ce37f4ae3c45dd01093b6274fa0b6692 (diff)
Attempt to resolve overloaded functions in comma expressions and
conditional operators. Fixes PR7863. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118631 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 0d0f48cd74..790f8831d2 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4309,6 +4309,21 @@ ExprResult Sema::ActOnParenOrParenListExpr(SourceLocation L,
QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
Expr *&SAVE,
SourceLocation QuestionLoc) {
+ // If both LHS and RHS are overloaded functions, try to resolve them.
+ if (Context.hasSameType(LHS->getType(), RHS->getType()) &&
+ LHS->getType()->isSpecificBuiltinType(BuiltinType::Overload)) {
+ ExprResult LHSResult = CheckPlaceholderExpr(LHS, QuestionLoc);
+ if (LHSResult.isInvalid())
+ return QualType();
+
+ ExprResult RHSResult = CheckPlaceholderExpr(RHS, QuestionLoc);
+ if (RHSResult.isInvalid())
+ return QualType();
+
+ LHS = LHSResult.take();
+ RHS = RHSResult.take();
+ }
+
// C++ is sufficiently different to merit its own checker.
if (getLangOptions().CPlusPlus)
return CXXCheckConditionalOperands(Cond, LHS, RHS, SAVE, QuestionLoc);
@@ -6250,6 +6265,15 @@ QualType Sema::CheckAssignmentOperands(Expr *LHS, Expr *&RHS,
QualType Sema::CheckCommaOperands(Expr *LHS, Expr *&RHS, SourceLocation Loc) {
DiagnoseUnusedExprResult(LHS);
+ ExprResult LHSResult = CheckPlaceholderExpr(LHS, Loc);
+ if (LHSResult.isInvalid())
+ return QualType();
+
+ ExprResult RHSResult = CheckPlaceholderExpr(RHS, Loc);
+ if (RHSResult.isInvalid())
+ return QualType();
+ RHS = RHSResult.take();
+
// C's comma performs lvalue conversion (C99 6.3.2.1) on both its
// operands, but not unary promotions.
// C++'s comma does not do any conversions at all (C++ [expr.comma]p1).