Now with tests.
http://reviews.llvm.org/D3753
Files:
lib/Sema/SemaExpr.cpp
test/SemaCXX/warn-self-assign.cpp
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9313,8 +9313,9 @@
ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
break;
case BO_AndAssign:
+ case BO_OrAssign: // fallthrough
+ DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc);
case BO_XorAssign:
- case BO_OrAssign:
CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, true);
CompLHSTy = CompResultTy;
if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
Index: test/SemaCXX/warn-self-assign.cpp
===================================================================
--- test/SemaCXX/warn-self-assign.cpp
+++ test/SemaCXX/warn-self-assign.cpp
@@ -8,6 +8,9 @@
b = a = b;
a = a = a; // expected-warning{{explicitly assigning}}
a = b = b = a;
+ a &= a; // expected-warning{{explicitly assigning}}
+ a |= a; // expected-warning{{explicitly assigning}}
+ a ^= a;
}
// Dummy type.
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -9313,8 +9313,9 @@
ResultTy = CheckAssignmentOperands(LHS.get(), RHS, OpLoc, CompResultTy);
break;
case BO_AndAssign:
+ case BO_OrAssign: // fallthrough
+ DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc);
case BO_XorAssign:
- case BO_OrAssign:
CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, true);
CompLHSTy = CompResultTy;
if (!CompResultTy.isNull() && !LHS.isInvalid() && !RHS.isInvalid())
Index: test/SemaCXX/warn-self-assign.cpp
===================================================================
--- test/SemaCXX/warn-self-assign.cpp
+++ test/SemaCXX/warn-self-assign.cpp
@@ -8,6 +8,9 @@
b = a = b;
a = a = a; // expected-warning{{explicitly assigning}}
a = b = b = a;
+ a &= a; // expected-warning{{explicitly assigning}}
+ a |= a; // expected-warning{{explicitly assigning}}
+ a ^= a;
}
// Dummy type.
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits