aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-12-16 18:24:55 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-12-16 18:24:55 +0000
commitd0af2c6589e1eca2142c6fed09d741820ea96bf3 (patch)
tree11c0289ddf7315923f3d0a6c53633d94b5314718 /gcc
parent7e2ac29ecbf012b42442e3bf9fc143c8645ba13e (diff)
downloadgcc-d0af2c6589e1eca2142c6fed09d741820ea96bf3.zip
gcc-d0af2c6589e1eca2142c6fed09d741820ea96bf3.tar.gz
gcc-d0af2c6589e1eca2142c6fed09d741820ea96bf3.tar.bz2
genmatch.c (parser::parser): Initialize capture_ids.
2014-12-16 Richard Biener <rguenther@suse.de> * genmatch.c (parser::parser): Initialize capture_ids. (parser::parse_pattern): Properly allocate capture_ids before using them. Set capture_ids to zero when its lifetime is supposed to finish. (parser::parse_simplify): Allocate capture_ids only if required. From-SVN: r218786
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog9
-rw-r--r--gcc/genmatch.c11
2 files changed, 18 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index e40fab7..609b8d1 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,12 @@
+2014-12-16 Richard Biener <rguenther@suse.de>
+
+ * genmatch.c (parser::parser): Initialize capture_ids.
+ (parser::parse_pattern): Properly allocate capture_ids before
+ using them. Set capture_ids to zero when its lifetime is
+ supposed to finish.
+ (parser::parse_simplify): Allocate capture_ids only if
+ required.
+
2014-12-16 Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Both config.h and system.h define ABI/API macros for system headers.
diff --git a/gcc/genmatch.c b/gcc/genmatch.c
index 756d54f..70a5f60 100644
--- a/gcc/genmatch.c
+++ b/gcc/genmatch.c
@@ -3171,7 +3171,8 @@ parser::parse_simplify (source_location match_location,
expr *result)
{
/* Reset the capture map. */
- capture_ids = new cid_map_t;
+ if (!capture_ids)
+ capture_ids = new cid_map_t;
/* Reset oper_lists and set. */
hash_set <user_id *> olist;
oper_lists_set = &olist;
@@ -3489,7 +3490,10 @@ parser::parse_pattern ()
const cpp_token *token = peek ();
const char *id = get_ident ();
if (strcmp (id, "simplify") == 0)
- parse_simplify (token->src_loc, simplifiers, NULL, NULL);
+ {
+ parse_simplify (token->src_loc, simplifiers, NULL, NULL);
+ capture_ids = NULL;
+ }
else if (strcmp (id, "match") == 0)
{
bool with_args = false;
@@ -3514,6 +3518,7 @@ parser::parse_pattern ()
expr *e = NULL;
if (with_args)
{
+ capture_ids = new cid_map_t;
e = new expr (p);
while (peek ()->type == CPP_ATSIGN)
e->append_op (parse_capture (NULL));
@@ -3525,6 +3530,7 @@ parser::parse_pattern ()
fatal_at (token, "non-matching number of match operands");
p->nargs = e ? e->ops.length () : 0;
parse_simplify (token->src_loc, p->matchers, p, e);
+ capture_ids = NULL;
}
else if (strcmp (id, "for") == 0)
parse_for (token->src_loc);
@@ -3562,6 +3568,7 @@ parser::parser (cpp_reader *r_)
simplifiers = vNULL;
oper_lists_set = NULL;
oper_lists = vNULL;
+ capture_ids = NULL;
user_predicates = vNULL;
parsing_match_operand = false;