summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-12-16 19:28:59 +0000
committerJohn McCall <rjmccall@apple.com>2010-12-16 19:28:59 +0000
commit57cdd888971d1c079e2e98729f50846ede69634a (patch)
treefaa14add4b13f4d906a1ee829ba6450106b05379
parentb5743b9d76fee759f3491d4500eb9269ade431f8 (diff)
downloadbcm5719-llvm-57cdd888971d1c079e2e98729f50846ede69634a.tar.gz
bcm5719-llvm-57cdd888971d1c079e2e98729f50846ede69634a.zip
Do lvalue-to-rvalue conversions on the LHS of a shift operator.
Fixes rdar://problem/8776586. llvm-svn: 121992
-rw-r--r--clang/lib/Sema/SemaExpr.cpp16
-rw-r--r--clang/test/Analysis/constant-folding.c1
-rw-r--r--clang/test/Analysis/idempotent-operations.c1
3 files changed, 8 insertions, 10 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index e4896afa323..01a505bb081 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -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
diff --git a/clang/test/Analysis/constant-folding.c b/clang/test/Analysis/constant-folding.c
index 9710c2ccbd7..9191a9e0578 100644
--- a/clang/test/Analysis/constant-folding.c
+++ b/clang/test/Analysis/constant-folding.c
@@ -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)
diff --git a/clang/test/Analysis/idempotent-operations.c b/clang/test/Analysis/idempotent-operations.c
index 514607b14a0..197357f800e 100644
--- a/clang/test/Analysis/idempotent-operations.c
+++ b/clang/test/Analysis/idempotent-operations.c
@@ -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
OpenPOWER on IntegriCloud