From: John McCall Date: Thu, 16 Dec 2010 19:28:59 +0000 (+0000) Subject: Do lvalue-to-rvalue conversions on the LHS of a shift operator. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1bc80af703ceff3e92797f33c41634d327bf067a;p=clang Do lvalue-to-rvalue conversions on the LHS of a shift operator. Fixes rdar://problem/8776586. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121992 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index e4896afa32..01a505bb08 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/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/test/Analysis/constant-folding.c b/test/Analysis/constant-folding.c index 9710c2ccbd..9191a9e057 100644 --- a/test/Analysis/constant-folding.c +++ b/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/test/Analysis/idempotent-operations.c b/test/Analysis/idempotent-operations.c index 514607b14a..197357f800 100644 --- a/test/Analysis/idempotent-operations.c +++ b/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