summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--elaborate.cxx6
-rw-r--r--stap.1.in14
-rw-r--r--tapset/builtin_log.stp2
-rw-r--r--tapset/builtin_printk.stp2
-rw-r--r--tapset/builtin_warn.stp2
-rwxr-xr-xtestsuite/buildok/nine.stp8
-rwxr-xr-xtestsuite/semok/eighteen.stp8
-rw-r--r--translate.cxx7
9 files changed, 44 insertions, 16 deletions
diff --git a/ChangeLog b/ChangeLog
index 0553076a..f05ab027 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
2005-08-10 Frank Ch. Eigler <fche@elastic.org>
+ PR translator/1186
+ * elaborate.cxx (resolve_2types): Accept a flag to tolerate unresolved
+ expression types.
+ (visit_functioncall): Call it thusly.
+ * translate.cxx (emit_function): Tolerate void functions.
+ * stap.1.in: Document possibility of void functions.
+ * tapset/builtin_{log,printk,warn}.stp: Make these void functions.
+ * testsuite/buildok/nine.stp, semok/eighteen.stp: New tests.
+
+2005-08-10 Frank Ch. Eigler <fche@elastic.org>
+
* tapsets.cxx: Correct hex/decimal misformatting of verbose messages.
* main.cxx: Add formal "-h" and "-V" options.
* stap.1.in: Document them.
diff --git a/elaborate.cxx b/elaborate.cxx
index 0cecab7e..de39b496 100644
--- a/elaborate.cxx
+++ b/elaborate.cxx
@@ -1252,7 +1252,7 @@ typeresolution_info::visit_ternary_expression (ternary_expression* e)
template <class Referrer, class Referent>
void resolve_2types (Referrer* referrer, Referent* referent,
- typeresolution_info* r, exp_type t)
+ typeresolution_info* r, exp_type t, bool accept_unknown = false)
{
exp_type& re_type = referrer->type;
const token* re_tok = referrer->tok;
@@ -1290,7 +1290,7 @@ void resolve_2types (Referrer* referrer, Referent* referent,
r->resolved (te_tok, te_type);
// catch re_type/t mismatch later
}
- else
+ else if (! accept_unknown)
r->unresolved (re_tok);
}
@@ -1361,7 +1361,7 @@ typeresolution_info::visit_functioncall (functioncall* e)
{
assert (e->referent != 0);
- resolve_2types (e, e->referent, this, t);
+ resolve_2types (e, e->referent, this, t, true); // accept unknown type
if (e->type == pe_stats)
invalid (e->tok, e->type);
diff --git a/stap.1.in b/stap.1.in
index 44359b68..afaf0c72 100644
--- a/stap.1.in
+++ b/stap.1.in
@@ -190,8 +190,9 @@ Exit or iterate the innermost nesting loop
statement.
.TP
.BR return " EXP"
-Return EXP value from enclosing function. A return value is mandatory,
-since void functions are not supported.
+Return EXP value from enclosing function. If the function's value is
+not taken anywhere, then a return statement is not needed, and the
+function will have a special "unknown" type with no return value.
.TP
.BR next
Return now from enclosing probe handler.
@@ -372,12 +373,9 @@ function thisfn (arg1, arg2) {
.fi
.RE
Note the usual absence of type declarations, which are instead
-inferred by the translator. Because a return value type is required,
-each function must contain at least one
-.I return
-statement. Functions may call others or themselves recursively, up to
-a fixed nesting limit. This limit is defined by a macro in the
-translated C code and is in the neighbourhood of 30.
+inferred by the translator. Functions may call others or themselves
+recursively, up to a fixed nesting limit. This limit is defined by
+a macro in the translated C code and is in the neighbourhood of 30.
.SS EMBEDDED C
When in guru mode, the translator accepts embedded code in the
diff --git a/tapset/builtin_log.stp b/tapset/builtin_log.stp
index 2932d66e..3d1a0aaf 100644
--- a/tapset/builtin_log.stp
+++ b/tapset/builtin_log.stp
@@ -3,5 +3,5 @@ function _log (msg) %{
%}
function log (msg) {
- return 0 + _log (msg . "")
+ _log (msg . "")
}
diff --git a/tapset/builtin_printk.stp b/tapset/builtin_printk.stp
index 3e456fb2..81826849 100644
--- a/tapset/builtin_printk.stp
+++ b/tapset/builtin_printk.stp
@@ -3,5 +3,5 @@ function _printk (msg) %{
%}
function printk (msg) {
- return 0 + _printk (msg . "")
+ _printk (msg . "")
}
diff --git a/tapset/builtin_warn.stp b/tapset/builtin_warn.stp
index 98fef7fe..97289ee0 100644
--- a/tapset/builtin_warn.stp
+++ b/tapset/builtin_warn.stp
@@ -3,5 +3,5 @@ function _warn (msg) %{
%}
function warn (msg) {
- return 0 + _warn (msg . "")
+ _warn (msg . "")
}
diff --git a/testsuite/buildok/nine.stp b/testsuite/buildok/nine.stp
new file mode 100755
index 00000000..d9a15276
--- /dev/null
+++ b/testsuite/buildok/nine.stp
@@ -0,0 +1,8 @@
+#! stap -p2
+
+function f () { }
+function g (arg) { }
+
+probe begin {
+ true ? f() : g(1);
+}
diff --git a/testsuite/semok/eighteen.stp b/testsuite/semok/eighteen.stp
new file mode 100755
index 00000000..1b05d89b
--- /dev/null
+++ b/testsuite/semok/eighteen.stp
@@ -0,0 +1,8 @@
+#! stap -p2
+
+function f () { }
+function g (arg) { }
+
+probe begin {
+ f(); g(1)
+}
diff --git a/translate.cxx b/translate.cxx
index 4add7b64..8806e502 100644
--- a/translate.cxx
+++ b/translate.cxx
@@ -765,8 +765,11 @@ c_unparser::emit_function (functiondecl* v)
}
// initialize return value, if any
- var retvalue = var(true, v->type, "__retvalue");
- o->newline() << retvalue.init();
+ if (v->type != pe_unknown)
+ {
+ var retvalue = var(true, v->type, "__retvalue");
+ o->newline() << retvalue.init();
+ }
v->body->visit (this);
this->current_function = 0;