[cfe-commits] r50624 - in /cfe/trunk: lib/Lex/PPExpressions.cpp test/Preprocessor/expr_usual_conversions.c

Chris Lattner sabre at nondot.org
Sun May 4 11:25:32 PDT 2008


Author: lattner
Date: Sun May  4 13:25:32 2008
New Revision: 50624

URL: http://llvm.org/viewvc/llvm-project?rev=50624&view=rev
Log:
Fix PR2279 part C: shifts don't perform the UACs, thanks to Neil 
for pointing this out.

Modified:
    cfe/trunk/lib/Lex/PPExpressions.cpp
    cfe/trunk/test/Preprocessor/expr_usual_conversions.c

Modified: cfe/trunk/lib/Lex/PPExpressions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPExpressions.cpp?rev=50624&r1=50623&r2=50624&view=diff

==============================================================================
--- cfe/trunk/lib/Lex/PPExpressions.cpp (original)
+++ cfe/trunk/lib/Lex/PPExpressions.cpp Sun May  4 13:25:32 2008
@@ -409,9 +409,11 @@
     assert(PeekPrec <= ThisPrec && "Recursion didn't work!");
     
     // Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
-    // either operand is unsigned.  Don't do this for x and y in "x ? y : z".
+    // either operand is unsigned.  Don't do this for x and y in "x ? y : z" or
+    // for shifts.
     llvm::APSInt Res(LHS.getBitWidth());
-    if (Operator != tok::question) {
+    if (Operator != tok::question && Operator != tok::lessless &&
+        Operator != tok::greatergreater) {
       Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned());
       // If this just promoted something from signed to unsigned, and if the
       // value was negative, warn about it.

Modified: cfe/trunk/test/Preprocessor/expr_usual_conversions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/expr_usual_conversions.c?rev=50624&r1=50623&r2=50624&view=diff

==============================================================================
--- cfe/trunk/test/Preprocessor/expr_usual_conversions.c (original)
+++ cfe/trunk/test/Preprocessor/expr_usual_conversions.c Sun May  4 13:25:32 2008
@@ -6,3 +6,8 @@
 foo
 #endif
 
+// Shifts don't want the usual conversions: PR2279
+#if (2 << 1U) - 30 >= 0
+#error
+#endif
+





More information about the cfe-commits mailing list