[llvm-branch-commits] [cfe-branch] r119242 - in /cfe/branches/Apple/whitney: lib/Sema/SemaExpr.cpp test/SemaCXX/overloaded-name.cpp
Daniel Dunbar
daniel at zuster.org
Mon Nov 15 13:45:33 PST 2010
Author: ddunbar
Date: Mon Nov 15 15:45:33 2010
New Revision: 119242
URL: http://llvm.org/viewvc/llvm-project?rev=119242&view=rev
Log:
Merge r118631:
--
Author: Douglas Gregor <dgregor at apple.com>
Date: Tue Nov 9 21:07:58 2010 +0000
Attempt to resolve overloaded functions in comma expressions and
conditional operators. Fixes PR7863.
Added:
cfe/branches/Apple/whitney/test/SemaCXX/overloaded-name.cpp
Modified:
cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
Modified: cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp?rev=119242&r1=119241&r2=119242&view=diff
==============================================================================
--- cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp (original)
+++ cfe/branches/Apple/whitney/lib/Sema/SemaExpr.cpp Mon Nov 15 15:45:33 2010
@@ -4305,6 +4305,21 @@
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);
@@ -6245,6 +6260,15 @@
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).
Added: cfe/branches/Apple/whitney/test/SemaCXX/overloaded-name.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/whitney/test/SemaCXX/overloaded-name.cpp?rev=119242&view=auto
==============================================================================
--- cfe/branches/Apple/whitney/test/SemaCXX/overloaded-name.cpp (added)
+++ cfe/branches/Apple/whitney/test/SemaCXX/overloaded-name.cpp Mon Nov 15 15:45:33 2010
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+int ovl(int);
+float ovl(float);
+
+template<typename T> T ovl(T);
+
+void test(bool b) {
+ (void)((void)0, ovl); // expected-error{{cannot resolve overloaded function from context}}
+ // PR7863
+ (void)(b? ovl : &ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)(b? ovl<float> : &ovl); // expected-error{{cannot resolve overloaded function from context}}
+ (void)(b? ovl<float> : ovl<float>);
+}
More information about the llvm-branch-commits
mailing list