[cfe-commits] r70613 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/Sema/bitfield.c

Douglas Gregor dgregor at apple.com
Fri May 1 17:36:19 PDT 2009


Author: dgregor
Date: Fri May  1 19:36:19 2009
New Revision: 70613

URL: http://llvm.org/viewvc/llvm-project?rev=70613&view=rev
Log:
Fix bitfield promotions in several more cases. We don't seem to work hard enough at determining whether an expression is a bitfield or not, yet.

Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp
    cfe/trunk/test/Sema/bitfield.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=70613&r1=70612&r2=70613&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri May  1 19:36:19 2009
@@ -264,6 +264,14 @@
   if (!lhs->isArithmeticType() || !rhs->isArithmeticType())
     return lhs;
 
+  // Perform bitfield promotions.
+  QualType LHSBitfieldPromoteTy = isPromotableBitField(lhsExpr, Context);
+  if (!LHSBitfieldPromoteTy.isNull())
+    lhs = LHSBitfieldPromoteTy;
+  QualType RHSBitfieldPromoteTy = isPromotableBitField(rhsExpr, Context);
+  if (!RHSBitfieldPromoteTy.isNull())
+    rhs = RHSBitfieldPromoteTy;
+
   QualType destType = UsualArithmeticConversionsType(lhs, rhs);
   if (!isCompAssign)
     ImpCastExprToType(lhsExpr, destType);
@@ -3475,6 +3483,12 @@
         QualType LHSTy = lex->getType();
         if (LHSTy->isPromotableIntegerType())
           LHSTy = Context.IntTy;
+        else {
+          QualType T = isPromotableBitField(lex, Context);
+          if (!T.isNull())
+            LHSTy = T;
+        }
+
         *CompLHSTy = LHSTy;
       }
       return PExp->getType();
@@ -3628,8 +3642,11 @@
   QualType LHSTy;
   if (lex->getType()->isPromotableIntegerType())
     LHSTy = Context.IntTy;
-  else
-    LHSTy = lex->getType();
+  else {
+    LHSTy = isPromotableBitField(lex, Context);
+    if (LHSTy.isNull())
+      LHSTy = lex->getType();
+  }
   if (!isCompAssign)
     ImpCastExprToType(lex, LHSTy);
 
@@ -4067,7 +4084,7 @@
   // C99 6.5.16.1p2: In simple assignment, the value of the right operand
   // is converted to the type of the assignment expression (above).
   // C++ 5.17p1: the type of the assignment expression is that of its left
-  // oprdu.
+  // operand.
   return LHSType.getUnqualifiedType();
 }
 

Modified: cfe/trunk/test/Sema/bitfield.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/bitfield.c?rev=70613&r1=70612&r2=70613&view=diff

==============================================================================
--- cfe/trunk/test/Sema/bitfield.c (original)
+++ cfe/trunk/test/Sema/bitfield.c Fri May  1 19:36:19 2009
@@ -29,3 +29,8 @@
 struct b {unsigned x : 2;} x;
 __typeof__(x.x+1) y;
 int y;
+
+struct {unsigned x : 2;} x2;
+// FIXME: __typeof__((x.x+=1)+1) y;
+__typeof__(x.x<<1) y;
+int y;





More information about the cfe-commits mailing list