Turn off implicit truncation warning for compound assignment to bitfields; it might be reasonable in some cases, but it clearly doesn't make sense in some cases, like the included testcase.

<rdar://problem/10238797>, part 2.

llvm-svn: 149095
This commit is contained in:
Eli Friedman 2012-01-26 23:34:06 +00:00
parent 49db052db4
commit 66b6395dd5
2 changed files with 4 additions and 2 deletions

View File

@ -4053,8 +4053,8 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
if (BO->isComparisonOp())
return AnalyzeComparison(S, BO);
// And with assignments and compound assignments.
if (BO->isAssignmentOp())
// And with simple assignments.
if (BO->getOpcode() == BO_Assign)
return AnalyzeAssignment(S, BO);
}

View File

@ -71,4 +71,6 @@ void test7() {
f.twoBits1 = ~1; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -2 to 2}}
f.twoBits2 = ~2; // expected-warning {{implicit truncation from 'int' to bitfield changes value from -3 to 1}}
f.twoBits1 &= ~1; // no-warning
f.twoBits2 &= ~2; // no-warning
}