summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordsmith <dsmith>2007-04-30 22:24:43 +0000
committerdsmith <dsmith>2007-04-30 22:24:43 +0000
commit53362f0ed669f58cdd2555216dc7eaaf191ca8d1 (patch)
tree09e4469beaab63bb1da570b618d7a65877fbdb7b
parente872ae096714a011eb24a0c1a62961f58533f939 (diff)
downloadsystemtap-steved-53362f0ed669f58cdd2555216dc7eaaf191ca8d1.tar.gz
systemtap-steved-53362f0ed669f58cdd2555216dc7eaaf191ca8d1.tar.xz
systemtap-steved-53362f0ed669f58cdd2555216dc7eaaf191ca8d1.zip
2007-04-30 David Smith <dsmith@redhat.com>
PR 2339 * translate.cxx (c_unparser_assignment::c_assignop): Improved handling of numeric constants in the rest of the assignment operators. (c_tmpcounter_assignment::c_assignop): Updated temporary handling.
-rw-r--r--ChangeLog9
-rw-r--r--translate.cxx44
2 files changed, 22 insertions, 31 deletions
diff --git a/ChangeLog b/ChangeLog
index a9e599a0..e68c57ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2007-04-30 David Smith <dsmith@redhat.com>
+
+ PR 2339
+ * translate.cxx (c_unparser_assignment::c_assignop): Improved
+ handling of numeric constants in the rest of the assignment
+ operators.
+ (c_tmpcounter_assignment::c_assignop): Updated temporary
+ handling.
+
2007-04-29 Frank Ch. Eigler <fche@elastic.org>
* configure.ac: Mention testsuite/configure.ac for version matching.
diff --git a/translate.cxx b/translate.cxx
index 81c4f8b3..e17e36ff 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -1941,11 +1941,11 @@ c_unparser_assignment::c_assignop(tmpvar & res,
if (op == "=")
macop = "*error*"; // special shortcuts below
else if (op == "++" || op == "+=")
- macop = "+=";
+ macop = "+=";
else if (op == "--" || op == "-=")
macop = "-=";
- else if (oplen > 1 && op[oplen-1] == '=') // for %=, <<=, etc...
- macop = op.substr(0, oplen-1);
+ else if (oplen > 1 && op[oplen-1] == '=') // for *=, <<=, etc...
+ macop = op;
else
// internal error
throw semantic_error ("unknown macop for assignment", tok);
@@ -1965,29 +1965,21 @@ c_unparser_assignment::c_assignop(tmpvar & res,
else
{
if (op == "=") // shortcut simple assignment
- {
- o->newline() << lval << " = " << rval << ";";
- res = rval;
- }
- // Handle "+=", "++", "-=" and "--". Note that "x++" gets
- // turned into "x += 1".
- else if (macop == "+=" || macop == "-=")
{
- o->newline() << lval << " " << macop << " " << rval << ";";
- res = lval;
+ o->newline() << lval << " = " << rval << ";";
+ res = rval;
}
else
{
- if (macop == "/")
- o->newline() << res << " = _stp_div64 (&c->last_error, "
+ if (macop == "/=")
+ o->newline() << lval << " = _stp_div64 (&c->last_error, "
<< lval << ", " << rval << ");";
- else if (macop == "%")
- o->newline() << res << " = _stp_mod64 (&c->last_error, "
+ else if (macop == "%=")
+ o->newline() << lval << " = _stp_mod64 (&c->last_error, "
<< lval << ", " << rval << ");";
- else
- o->newline() << res << " = " << lval << " " << macop << " " << rval << ";";
-
- o->newline() << lval << " = " << res << ";";
+ else
+ o->newline() << lval << " " << macop << " " << rval << ";";
+ res = lval;
}
}
}
@@ -3255,19 +3247,9 @@ c_tmpcounter_assignment::c_assignop(tmpvar & res)
res.declare (*(parent->parent));
else if (res.type() == pe_long)
{
+ // Only the 'post' operators ('x++') need a temporary declared.
if (post)
res.declare (*(parent->parent));
- else
- {
- if (op == "=" || op == "+=" || op == "++"
- || op == "-=" || op == "--")
- {
- // these operators don't need any temporaries declared,
- // since they just return the result
- }
- else
- res.declare (*(parent->parent));
- }
}
}