forked from OSchip/llvm-project
Fix PR2279 part C: shifts don't perform the UACs, thanks to Neil
for pointing this out. llvm-svn: 50624
This commit is contained in:
parent
1e151816b2
commit
a08f869c22
|
@ -409,9 +409,11 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec,
|
|||
assert(PeekPrec <= ThisPrec && "Recursion didn't work!");
|
||||
|
||||
// Usual arithmetic conversions (C99 6.3.1.8p1): result is unsigned if
|
||||
// either operand is unsigned. Don't do this for x and y in "x ? y : z".
|
||||
// either operand is unsigned. Don't do this for x and y in "x ? y : z" or
|
||||
// for shifts.
|
||||
llvm::APSInt Res(LHS.getBitWidth());
|
||||
if (Operator != tok::question) {
|
||||
if (Operator != tok::question && Operator != tok::lessless &&
|
||||
Operator != tok::greatergreater) {
|
||||
Res.setIsUnsigned(LHS.isUnsigned()|RHS.isUnsigned());
|
||||
// If this just promoted something from signed to unsigned, and if the
|
||||
// value was negative, warn about it.
|
||||
|
|
|
@ -6,3 +6,8 @@
|
|||
foo
|
||||
#endif
|
||||
|
||||
// Shifts don't want the usual conversions: PR2279
|
||||
#if (2 << 1U) - 30 >= 0
|
||||
#error
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Reference in New Issue