diff options
author | fche <fche> | 2005-08-10 23:11:15 +0000 |
---|---|---|
committer | fche <fche> | 2005-08-10 23:11:15 +0000 |
commit | 319660888893154e17ebbe313501ede739a92dcd (patch) | |
tree | 49653a0c1916d8dd8d8539e3ed1d9ba12a61155f | |
parent | c0de7a8dc7987f0d1648e36085d328e290217aaa (diff) | |
download | systemtap-steved-319660888893154e17ebbe313501ede739a92dcd.tar.gz systemtap-steved-319660888893154e17ebbe313501ede739a92dcd.tar.xz systemtap-steved-319660888893154e17ebbe313501ede739a92dcd.zip |
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.
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | elaborate.cxx | 6 | ||||
-rw-r--r-- | stap.1.in | 14 | ||||
-rw-r--r-- | tapset/builtin_log.stp | 2 | ||||
-rw-r--r-- | tapset/builtin_printk.stp | 2 | ||||
-rw-r--r-- | tapset/builtin_warn.stp | 2 | ||||
-rwxr-xr-x | testsuite/buildok/nine.stp | 8 | ||||
-rwxr-xr-x | testsuite/semok/eighteen.stp | 8 | ||||
-rw-r--r-- | translate.cxx | 7 |
9 files changed, 44 insertions, 16 deletions
@@ -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); @@ -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; |