From 27d24ae2a4beddefc1aace0baf25f17ff92e22eb Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 20 May 2008 17:34:07 -0400 Subject: PR6538: warn about read-only variables --- elaborate.cxx | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) (limited to 'elaborate.cxx') diff --git a/elaborate.cxx b/elaborate.cxx index 4bc43832..f8bfabdb 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1624,7 +1624,13 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) // don't increment j } else - j++; + { + if (vut.written.find (l) == vut.written.end()) + if (! s.suppress_warnings) + clog << "WARNING: read-only local variable " << *l->tok << endl; + + j++; + } } for (unsigned i=0; ilocals.size(); /* see below */) @@ -1649,7 +1655,12 @@ void semantic_pass_opt2 (systemtap_session& s, bool& relaxed_p) // don't increment j } else - j++; + { + if (vut.written.find (l) == vut.written.end()) + if (! s.suppress_warnings) + clog << "WARNING: read-only local variable " << *l->tok << endl; + j++; + } } for (unsigned i=0; itok << endl; + i++; + } } } @@ -1834,6 +1850,8 @@ void semantic_pass_opt3 (systemtap_session& s, bool& relaxed_p) for (unsigned i=0; ibody->visit (& dar); // The rewrite operation is performed within the visitor. + + // XXX: we could also zap write-only globals here } @@ -2057,6 +2075,8 @@ void semantic_pass_opt4 (systemtap_session& s, bool& relaxed_p) p->body = new null_statement(); p->body->tok = p->tok; + + // XXX: possible duplicate warnings; see below } } for (unsigned i=0; ibody = new null_statement(); fn->body->tok = fn->tok; + + // XXX: the next iteration of the outer optimization loop may + // take this new null_statement away again, and thus give us a + // fresh warning. It would be better if this fixup was performed + // only after the relaxation iterations. + // XXX: or else see bug #6469. } } } -- cgit