Fix -Wshift-count-negative. It didn't work if the right hand side

of the shift wasn't a constant integer expression, now it (hopefully)
does.

PR:		22059


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@233320 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Davide Italiano 2015-03-26 21:37:49 +00:00
parent 50c0ec3086
commit e97393dd73
2 changed files with 7 additions and 1 deletions

View File

@ -7769,7 +7769,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult &LHS, ExprResult &RHS,
llvm::APSInt Right;
// Check right/shifter operand
if (RHS.get()->isValueDependent() ||
!RHS.get()->isIntegerConstantExpr(Right, S.Context))
!RHS.get()->EvaluateAsInt(Right, S.Context))
return;
if (Right.isNegative()) {

View File

@ -0,0 +1,6 @@
// RUN: %clang_cc1 -fsyntax-only -Wshift-count-negative -fblocks -verify %s
int f(int a) {
const int i = -1;
return a << i; // expected-warning{{shift count is negative}}
}