r233320 - Fix -Wshift-count-negative. It didn't work if the right hand side
Davide Italiano
davide at freebsd.org
Thu Mar 26 14:37:50 PDT 2015
Author: davide
Date: Thu Mar 26 16:37:49 2015
New Revision: 233320
URL: http://llvm.org/viewvc/llvm-project?rev=233320&view=rev
Log:
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
Added:
cfe/trunk/test/Sema/warn-shift-negative.c
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=233320&r1=233319&r2=233320&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Mar 26 16:37:49 2015
@@ -7769,7 +7769,7 @@ static void DiagnoseBadShiftValues(Sema&
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()) {
Added: cfe/trunk/test/Sema/warn-shift-negative.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-shift-negative.c?rev=233320&view=auto
==============================================================================
--- cfe/trunk/test/Sema/warn-shift-negative.c (added)
+++ cfe/trunk/test/Sema/warn-shift-negative.c Thu Mar 26 16:37:49 2015
@@ -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}}
+}
More information about the cfe-commits
mailing list