[cfe-commits] r126345 - in /cfe/trunk: lib/Sema/SemaExpr.cpp test/SemaCXX/shift.cpp
Chandler Carruth
chandlerc at gmail.com
Wed Feb 23 16:03:54 PST 2011
Author: chandlerc
Date: Wed Feb 23 18:03:53 2011
New Revision: 126345
URL: http://llvm.org/viewvc/llvm-project?rev=126345&view=rev
Log:
Handle value dependent LHS as well as RHS. Test both of these, they
don't seem to have been covered by our tests previously.
This should fix bootstrap failure.
Added:
cfe/trunk/test/SemaCXX/shift.cpp
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=126345&r1=126344&r2=126345&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Wed Feb 23 18:03:53 2011
@@ -6652,7 +6652,7 @@
// integers have defined behavior modulo one more than the maximum value
// representable in the result type, so never warn for those.
llvm::APSInt Left;
- if (!lex->isIntegerConstantExpr(Left, S.Context) ||
+ if (lex->isValueDependent() || !lex->isIntegerConstantExpr(Left, S.Context) ||
LHSTy->hasUnsignedIntegerRepresentation())
return;
llvm::APInt ResultBits =
Added: cfe/trunk/test/SemaCXX/shift.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/shift.cpp?rev=126345&view=auto
==============================================================================
--- cfe/trunk/test/SemaCXX/shift.cpp (added)
+++ cfe/trunk/test/SemaCXX/shift.cpp Wed Feb 23 18:03:53 2011
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -verify %s
+
+#include <limits.h>
+
+#define WORD_BIT (sizeof(int) * CHAR_BIT)
+
+template <int N> void f() {
+ (void)(N << 30); // expected-warning {{the promoted type of the shift expression is 'int'}}
+ (void)(30 << N); // expected-warning {{the promoted type of the shift expression is 'int'}}
+}
+
+void test() {
+ f<30>(); // expected-note {{instantiation}}
+}
More information about the cfe-commits
mailing list