From: Chandler Carruth Date: Thu, 24 Feb 2011 00:03:53 +0000 (+0000) Subject: Handle value dependent LHS as well as RHS. Test both of these, they X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6c3c3f53b32288f0be38e010c96da271f264f2ad;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126345 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index 076ffeb268..0a7d22dd64 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -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 = diff --git a/test/SemaCXX/shift.cpp b/test/SemaCXX/shift.cpp new file mode 100644 index 0000000000..c5e50128c9 --- /dev/null +++ b/test/SemaCXX/shift.cpp @@ -0,0 +1,14 @@ +// RUN: %clang_cc1 -Wall -Wshift-sign-overflow -ffreestanding -fsyntax-only -verify %s + +#include + +#define WORD_BIT (sizeof(int) * CHAR_BIT) + +template 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}} +}