forked from OSchip/llvm-project
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:
parent
220617c1ba
commit
60ed89dc54
|
@ -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 =
|
||||
|
|
|
@ -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}}
|
||||
}
|
Loading…
Reference in New Issue