summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog8
-rw-r--r--translate.cxx16
2 files changed, 22 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index e26ba003..2732b5cd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-08-30 David Smith <dsmith@redhat.com>
+
+ PR 4983
+ * translate.cxx (c_tmpcounter::visit_print_format): Don't declare
+ temporaries for number and string constants.
+ (c_unparser::visit_print_format): Use numeric and string constants
+ directly instead of copying them into temporaries.
+
2007-08-27 Frank Ch. Eigler <fche@redhat.com>
PR 4817
diff --git a/translate.cxx b/translate.cxx
index 4891c617..d621cf26 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -3938,7 +3938,9 @@ c_tmpcounter::visit_print_format (print_format* e)
e->args[i]->tok);
}
- t.declare (*parent);
+ if (e->args[i]->tok->type != tok_number
+ && e->args[i]->tok->type != tok_string)
+ t.declare (*parent);
e->args[i]->visit (this);
}
@@ -4004,7 +4006,17 @@ c_unparser::visit_print_format (print_format* e)
o->newline() << "c->last_stmt = "
<< lex_cast_qstring(*e->args[i]->tok) << ";";
- c_assign (t.value(), e->args[i], "print format actual argument evaluation");
+
+ // If we've got a numeric or string constant, instead of
+ // assigning the numeric or string constant to a temporary,
+ // then passing the temporary to _stp_printf/_stp_snprintf,
+ // let's just override the temporary with the constant.
+ if (e->args[i]->tok->type == tok_number
+ || e->args[i]->tok->type == tok_string)
+ tmp[i].override(c_expression(e->args[i]));
+ else
+ c_assign (t.value(), e->args[i],
+ "print format actual argument evaluation");
}
std::vector<print_format::format_component> components;