mirror of https://github.com/microsoft/clang.git
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:
parent
50c0ec3086
commit
e97393dd73
|
@ -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()) {
|
||||
|
|
|
@ -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}}
|
||||
}
|
Loading…
Reference in New Issue