]> sourceware.org Git - systemtap.git/commitdiff
2005-08-10 Frank Ch. Eigler <fche@elastic.org>
authorfche <fche>
Wed, 10 Aug 2005 23:11:15 +0000 (23:11 +0000)
committerfche <fche>
Wed, 10 Aug 2005 23:11:15 +0000 (23:11 +0000)
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.

ChangeLog
elaborate.cxx
stap.1.in
tapset/builtin_log.stp
tapset/builtin_printk.stp
tapset/builtin_warn.stp
testsuite/buildok/nine.stp [new file with mode: 0755]
testsuite/semok/eighteen.stp [new file with mode: 0755]
translate.cxx

index 0553076a1e44fa2e38123ffe496dd6d98c6cb92c..f05ab0274c29d43e86be126d7291d3a468f189b5 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+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.
index 0cecab7e178ba76942c1d46cdc4bae560f94fa56..de39b49670d96d35962d4cd58fc84b0199834b8d 100644 (file)
@@ -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);
index 44359b689d4d16515aaf5f639189d7d485827284..afaf0c72304d256a0018681c8d5d50cfcb4799ea 100644 (file)
--- 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
index 2932d66ed496160d40ee98c214336a8ee8f9556a..3d1a0aaf88cba2e8f4893c2e2974fe0bff675841 100644 (file)
@@ -3,5 +3,5 @@ function _log (msg) %{
 %}
 
 function log (msg) {
-    return 0 + _log (msg . "")
+   _log (msg . "")
 }
index 3e456fb2baf0e4f8cfb37a3be838192961e3bcbc..81826849f133497c692aaea8304d52f1fd68b759 100644 (file)
@@ -3,5 +3,5 @@ function _printk (msg) %{
 %}
 
 function printk (msg) {
-    return 0 + _printk (msg . "")
+    _printk (msg . "")
 }
index 98fef7fe0f0aff1880479f50ab363834cb48e793..97289ee075048552507c584361136532ce0c7411 100644 (file)
@@ -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 (executable)
index 0000000..d9a1527
--- /dev/null
@@ -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 (executable)
index 0000000..1b05d89
--- /dev/null
@@ -0,0 +1,8 @@
+#! stap -p2
+
+function f () { }
+function g (arg) { }
+
+probe begin {
+  f(); g(1)
+}
index 4add7b64115866031f44e14b2e8827c8bbe72b83..8806e502367c6eee3e9243fa757d8011017a6c02 100644 (file)
@@ -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;
This page took 0.0511 seconds and 5 git commands to generate.