]> granicus.if.org Git - clang/commitdiff
Turn off implicit truncation warning for compound assignment to bitfields; it might...
authorEli Friedman <eli.friedman@gmail.com>
Thu, 26 Jan 2012 23:34:06 +0000 (23:34 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Thu, 26 Jan 2012 23:34:06 +0000 (23:34 +0000)
<rdar://problem/10238797>, part 2.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149095 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaChecking.cpp
test/Sema/constant-conversion.c

index 8d01352fd221aa9b2e0aa63386657a1c48d943b3..7579a5d0eebc81c727c43f7f94c0f53f122b1971 100644 (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);
   }
 
index c97eb05cd190fbb27bdd95232b3939f59ba2201c..e3097f8be30e85862a8d1c1b9399a6b7e6b971a4 100644 (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
 }