summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-05-04 18:25:32 +0000
committerChris Lattner <sabre@nondot.org>2008-05-04 18:25:32 +0000
commita08f869c22910bd7f692a21560d8d1f534393158 (patch)
tree77f924371b786ec3c084efbfb6f7836b3ae41e54 /clang
parent1e151816b2cc51fda9e591d5de67a40a84e6af58 (diff)
downloadbcm5719-llvm-a08f869c22910bd7f692a21560d8d1f534393158.tar.gz
bcm5719-llvm-a08f869c22910bd7f692a21560d8d1f534393158.zip
Fix PR2279 part C: shifts don't perform the UACs, thanks to Neil
for pointing this out. llvm-svn: 50624
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Lex/PPExpressions.cpp6
-rw-r--r--clang/test/Preprocessor/expr_usual_conversions.c5
2 files changed, 9 insertions, 2 deletions
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 63170151377..6343a3c0983 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -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.
diff --git a/clang/test/Preprocessor/expr_usual_conversions.c b/clang/test/Preprocessor/expr_usual_conversions.c
index b2ccc409007..90275c99444 100644
--- a/clang/test/Preprocessor/expr_usual_conversions.c
+++ b/clang/test/Preprocessor/expr_usual_conversions.c
@@ -6,3 +6,8 @@
foo
#endif
+// Shifts don't want the usual conversions: PR2279
+#if (2 << 1U) - 30 >= 0
+#error
+#endif
+
OpenPOWER on IntegriCloud