From: Josh Stone Date: Mon, 7 Jun 2010 19:58:00 +0000 (-0700) Subject: Never permit homonymous vars with different arity X-Git-Tag: release-1.3~279 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=60bebf58e032c417fff238d200f81964d10d1cc6;p=systemtap.git Never permit homonymous vars with different arity It was previously possible to generate a global array and local scalar having the same name, because find_var was glossing over globals that didn't have compatible_arity. Fixes semko/nine, and improves semko/six to an arity-mismatch error rather than a local-array error. * elaborate.cxx (symresolution_info::find_var): Use set_arity without checking compatibile_arity, so that compatibility gets asserted. (symresolution_info::visit_foreach_loop): Add "missing global" hint. (symresolution_info::visit_arrayindex): Don't create local arrays. --- diff --git a/elaborate.cxx b/elaborate.cxx index 3775b0692..9f442f3c6 100644 --- a/elaborate.cxx +++ b/elaborate.cxx @@ -1645,12 +1645,13 @@ symresolution_info::visit_foreach_loop (foreach_loop* e) if (d) array->referent = d; else - { - stringstream msg; - msg << "unresolved arity-" << e->indexes.size() - << " global array " << array->name; - throw semantic_error (msg.str(), e->tok); - } + { + stringstream msg; + msg << "unresolved arity-" << e->indexes.size() + << " global array " << array->name + << ", missing global declaration? "; + throw semantic_error (msg.str(), e->tok); + } } } else @@ -1757,19 +1758,11 @@ symresolution_info::visit_arrayindex (arrayindex* e) array->referent = d; else { - // new local - vardecl* v = new vardecl; - v->set_arity(e->indexes.size()); - v->name = array->name; - v->tok = array->tok; - if (current_function) - current_function->locals.push_back (v); - else if (current_probe) - current_probe->locals.push_back (v); - else - // must not happen - throw semantic_error ("no current probe/function", e->tok); - array->referent = v; + stringstream msg; + msg << "unresolved arity-" << e->indexes.size() + << " global array " << array->name + << ", missing global declaration? "; + throw semantic_error (msg.str(), e->tok); } } else @@ -1822,8 +1815,7 @@ symresolution_info::find_var (const string& name, int arity, const token* tok) for (unsigned i=0; iname == name - && locals[i]->compatible_arity(arity)) + if (locals[i]->name == name) { locals[i]->set_arity (arity); return locals[i]; @@ -1842,8 +1834,7 @@ symresolution_info::find_var (const string& name, int arity, const token* tok) // search processed globals for (unsigned i=0; iname == name - && session.globals[i]->compatible_arity(arity)) + if (session.globals[i]->name == name) { session.globals[i]->set_arity (arity); if (! session.suppress_warnings) @@ -1866,7 +1857,7 @@ symresolution_info::find_var (const string& name, int arity, const token* tok) for (unsigned j=0; jglobals.size(); j++) { vardecl* g = f->globals[j]; - if (g->name == name && g->compatible_arity (arity)) + if (g->name == name) { g->set_arity (arity);