From eff66d4087f2c1c99bd0658de1075b19a9854ac3 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 2 Apr 2014 17:33:47 -0700 Subject: [PATCH] parse: don't do auto-@cast promotion for old scripts 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 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/parse.cxx b/parse.cxx index 785a5070c..c16221c8d 100644 --- 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; -- 2.43.5