[cfe-commits] r149095 - in /cfe/trunk: lib/Sema/SemaChecking.cpp test/Sema/constant-conversion.c

Eli Friedman eli.friedman at gmail.com
Thu Jan 26 15:34:06 PST 2012


Author: efriedma
Date: Thu Jan 26 17:34:06 2012
New Revision: 149095

URL: http://llvm.org/viewvc/llvm-project?rev=149095&view=rev
Log:
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.


Modified:
    cfe/trunk/lib/Sema/SemaChecking.cpp
    cfe/trunk/test/Sema/constant-conversion.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=149095&r1=149094&r2=149095&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu Jan 26 17:34:06 2012
@@ -4053,8 +4053,8 @@
     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);
   }
 

Modified: cfe/trunk/test/Sema/constant-conversion.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/constant-conversion.c?rev=149095&r1=149094&r2=149095&view=diff
==============================================================================
--- cfe/trunk/test/Sema/constant-conversion.c (original)
+++ cfe/trunk/test/Sema/constant-conversion.c Thu Jan 26 17:34:06 2012
@@ -71,4 +71,6 @@
 
 	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
 }





More information about the cfe-commits mailing list