diff options
author | Wenji Huang <wenji.huang@oracle.com> | 2010-01-12 13:45:55 +0800 |
---|---|---|
committer | Wenji Huang <wenji.huang@oracle.com> | 2010-01-12 13:45:55 +0800 |
commit | c28668eaddf956b8c481e436e939d0b35bacaf68 (patch) | |
tree | a7cd9ebe06e19b1478172236f839000ddd602089 /parse.cxx | |
parent | f2aadddae0d01fa5a676404e49c6c36825b40512 (diff) | |
download | systemtap-steved-c28668eaddf956b8c481e436e939d0b35bacaf68.tar.gz systemtap-steved-c28668eaddf956b8c481e436e939d0b35bacaf68.tar.xz systemtap-steved-c28668eaddf956b8c481e436e939d0b35bacaf68.zip |
PR10747: check invalid preprocessor construct
* parse.cxx (scan_pp): Match '%(' and '%?'.
* testsuite/semko/conditional.stp: New test.
Diffstat (limited to 'parse.cxx')
-rw-r--r-- | parse.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -380,6 +380,7 @@ parser::scan_pp (bool wildcard) vector<const token*> my_enqueued_pp; int nesting = 0; + int then = 0; while (true) // consume THEN tokens { try @@ -394,11 +395,18 @@ parser::scan_pp (bool wildcard) if (m && m->type == tok_operator && m->content == "%(") // nested %( nesting ++; + if (m && m->type == tok_operator && m->content == "%?") { + then ++; + if (nesting != then) + throw parse_error ("incomplete conditional - missing '%('", m); + } if (nesting == 0 && m && (m->type == tok_operator && (m->content == "%:" || // ELSE m->content == "%)"))) // END break; - if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) + if (nesting && m && m->type == tok_operator && m->content == "%)") { // nested %) nesting --; + then --; + } if (!m) throw parse_error ("incomplete conditional - missing '%:' or '%)'", t); @@ -414,6 +422,7 @@ parser::scan_pp (bool wildcard) { delete m; // "%:" int nesting = 0; + int then = 0; while (true) { try @@ -428,10 +437,17 @@ parser::scan_pp (bool wildcard) if (m && m->type == tok_operator && m->content == "%(") // nested %( nesting ++; + if (m && m->type == tok_operator && m->content == "%?") { + then ++; + if (nesting != then) + throw parse_error ("incomplete conditional - missing '%('", m); + } if (nesting == 0 && m && m->type == tok_operator && m->content == "%)") // END break; - if (nesting && m && m->type == tok_operator && m->content == "%)") // nested %) + if (nesting && m && m->type == tok_operator && m->content == "%)") { // nested %) nesting --; + then --; + } if (!m) throw parse_error ("incomplete conditional - missing %)", t); |