]> granicus.if.org Git - clang/commitdiff
Do lvalue-to-rvalue conversions on the LHS of a shift operator.
authorJohn McCall <rjmccall@apple.com>
Thu, 16 Dec 2010 19:28:59 +0000 (19:28 +0000)
committerJohn McCall <rjmccall@apple.com>
Thu, 16 Dec 2010 19:28:59 +0000 (19:28 +0000)
Fixes rdar://problem/8776586.

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

lib/Sema/SemaExpr.cpp
test/Analysis/constant-folding.c
test/Analysis/idempotent-operations.c

index e4896afa323db6c943b456399d2a9b4b0a23a7c5..01a505bb081757c9a34afe5888c5e7a25fd61e7e 100644 (file)
@@ -6246,15 +6246,15 @@ QualType Sema::CheckShiftOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
 
   // Shifts don't perform usual arithmetic conversions, they just do integer
   // promotions on each operand. C99 6.5.7p3
-  QualType LHSTy = Context.isPromotableBitField(lex);
-  if (LHSTy.isNull()) {
-    LHSTy = lex->getType();
-    if (LHSTy->isPromotableIntegerType())
-      LHSTy = Context.getPromotedIntegerType(LHSTy);
-  }
-  if (!isCompAssign)
-    ImpCastExprToType(lex, LHSTy, CK_IntegralCast);
 
+  // For the LHS, do usual unary conversions, but then reset them away
+  // if this is a compound assignment.
+  Expr *old_lex = lex;
+  UsualUnaryConversions(lex);
+  QualType LHSTy = lex->getType();
+  if (isCompAssign) lex = old_lex;
+
+  // The RHS is simpler.
   UsualUnaryConversions(rex);
 
   // Sanity-check shift operands
index 9710c2ccbd7148e14cd1b60543a3d80bffe38217..9191a9e0578ec65535c00e0e0482a6c41829af23 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -analyze -analyzer-experimental-internal-checks -analyzer-check-objc-mem -analyzer-experimental-checks -verify %s
-// XFAIL: *
 
 // Trigger a warning if the analyzer reaches this point in the control flow.
 #define WARN ((void)*(char*)0)
index 514607b14a045530e7766967fbcacfbc4c9b25aa..197357f800e753078595d3dad85ff52f9e341c20 100644 (file)
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -verify %s
-// XFAIL: *
 
 // Basic tests