summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--translate.cxx13
2 files changed, 16 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index f65efd14..4a2a5546 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-04-21 Eugene Teo <eteo@redhat.com>
+
+ PR 1326
+ * translate.cxx (c_unparser::visit_binary_expression): Handle
+ negative left and right shift count.
+
2006-04-21 Frank Ch. Eigler <fche@elastic.org>
PR 953
diff --git a/translate.cxx b/translate.cxx
index e0b1f8aa..83d6dd93 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -2468,9 +2468,7 @@ c_unparser::visit_binary_expression (binary_expression* e)
e->op == "*" ||
e->op == "&" ||
e->op == "|" ||
- e->op == "^" ||
- e->op == "<<" ||
- e->op == ">>")
+ e->op == "^")
{
o->line() << "((";
e->left->visit (this);
@@ -2478,6 +2476,15 @@ c_unparser::visit_binary_expression (binary_expression* e)
e->right->visit (this);
o->line() << "))";
}
+ else if (e->op == ">>" ||
+ e->op == "<<")
+ {
+ o->line() << "((";
+ e->left->visit (this);
+ o->line() << ") " << e->op << "max(min(";
+ e->right->visit (this);
+ o->line() << ", (int64_t)64LL), (int64_t)0LL))"; // between 0 and 64
+ }
else if (e->op == "/" ||
e->op == "%")
{