]> sourceware.org Git - systemtap.git/commitdiff
parse: don't do auto-@cast promotion for old scripts
authorJosh Stone <jistone@redhat.com>
Thu, 3 Apr 2014 00:33:47 +0000 (17:33 -0700)
committerJosh Stone <jistone@redhat.com>
Fri, 4 Apr 2014 23:47:32 +0000 (16:47 -0700)
There's at least one case that will parse differently now:
  (expression) [index] in array

Before: (expression); [index] in array
i.e. two separate statements

After: [(expression)[index]] in array
i.e. @cast-dereference the expression, then test that in array

I don't see any use for the case before, but it's still valid syntax
that has changed behavior, so we'll be compatible about it.  Guard the
new @cast promotion for stap 2.6 and later only.  (The Future!)

parse.cxx

index 785a5070c266ccc2932c4b7cf4b387cb928b430d..c16221c8d213ab510ae81259a1c27761e7377f55 100644 (file)
--- a/parse.cxx
+++ b/parse.cxx
@@ -3336,7 +3336,6 @@ parser::parse_dwarf_value ()
     }
 
   // First try target_symbol types: $var, @cast, and @var.
-  // Otherwise just get a plain value of any sort.
   const token* t = peek ();
   if (t && t->type == tok_identifier && t->content[0] == '$')
     expr = tsym = parse_target_symbol ();
@@ -3344,11 +3343,17 @@ parser::parse_dwarf_value ()
     expr = tsym = parse_cast_op ();
   else if (tok_is (t, tok_operator, "@var"))
     expr = tsym = parse_atvar_op ();
+  else if (addressof && strverscmp(session.compatible.c_str(), "2.6") < 0)
+    // '&' on old version only allowed specific target_symbol types
+    throw PARSE_ERROR (_("expected @cast, @var or $var"));
   else
+    // Otherwise just get a plain value of any sort.
     expr = parse_value ();
 
   // If we had '&' or see any target suffixes, that forces a target_symbol.
-  if (!tsym && (addressof || peek_target_symbol_components ()))
+  // For compatibility, we only do this starting with 2.6.
+  if (!tsym && (addressof || peek_target_symbol_components ())
+      && strverscmp(session.compatible.c_str(), "2.6") >= 0)
     {
       cast_op *cop = new cast_op;
       cop->tok = expr->tok;
This page took 0.0314 seconds and 5 git commands to generate.