]> sourceware.org Git - systemtap.git/commitdiff
Never permit homonymous vars with different arity
authorJosh Stone <jistone@redhat.com>
Mon, 7 Jun 2010 19:58:00 +0000 (12:58 -0700)
committerJosh Stone <jistone@redhat.com>
Mon, 7 Jun 2010 20:30:30 +0000 (13:30 -0700)
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.

elaborate.cxx

index 3775b0692816d310362d4e2687f3fdb3a89422a6..9f442f3c67031e39ebfcd462fdcdf3bb6c1672ef 100644 (file)
@@ -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; i<locals.size(); i++)
-        if (locals[i]->name == 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; i<session.globals.size(); i++)
-    if (session.globals[i]->name == 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; j<f->globals.size(); j++)
         {
           vardecl* g = f->globals[j];
-          if (g->name == name && g->compatible_arity (arity))
+          if (g->name == name)
             {
              g->set_arity (arity);
 
This page took 0.038823 seconds and 5 git commands to generate.