aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaOverload.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2009-11-18 23:10:33 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2009-11-18 23:10:33 +0000
commit275c2b47a1dc200d6b55dd867bdfeb7a91b8d876 (patch)
tree25b4d3f08a56638f2fad6792af0bbc62efe3ac4f /lib/Sema/SemaOverload.cpp
parenta93b108e025ef2480fa867cc533e7781a40a639b (diff)
Do overload resolution for compound assignment even if only the RHS is overloadable. Compound assignment may be overloaded as a non-member, and anyway the overload resolution is necessary because it triggers implicit (used-defined) conversions. Fixes PR5512, but not really the deeper issues lurking. Those are standard defects.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@89268 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaOverload.cpp')
-rw-r--r--lib/Sema/SemaOverload.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index 04bc6b10c0..daf5b7f360 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -4895,11 +4895,13 @@ Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
if (Opc == BinaryOperator::PtrMemD)
return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
- // If this is one of the assignment operators, we only perform
- // overload resolution if the left-hand side is a class or
- // enumeration type (C++ [expr.ass]p3).
- if (Opc >= BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign &&
- !Args[0]->getType()->isOverloadableType())
+ // If this is the assignment operator, we only perform overload resolution
+ // if the left-hand side is a class or enumeration type. This is actually
+ // a hack. The standard requires that we do overload resolution between the
+ // various built-in candidates, but as DR507 points out, this can lead to
+ // problems. So we do it this way, which pretty much follows what GCC does.
+ // Note that we go the traditional code path for compound assignment forms.
+ if (Opc==BinaryOperator::Assign && !Args[0]->getType()->isOverloadableType())
return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
// Build an empty overload set.