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.

llvm-svn: 126345
This commit is contained in:
Chandler Carruth 2011-02-24 00:03:53 +00:00
parent 220617c1ba
commit 60ed89dc54
2 changed files with 15 additions and 1 deletions

View File

@ -6652,7 +6652,7 @@ static void DiagnoseBadShiftValues(Sema& S, Expr *&lex, Expr *&rex,
// 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 =

View File

@ -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}}
}