Vladimir, If I introduce an unbalanced parentheses error in a reservation string, f.i. in athlon.md using the following patch: ... diff --git a/gcc/config/i386/athlon.md b/gcc/config/i386/athlon.md index d872b8f..b1ed5cd 100644 --- a/gcc/config/i386/athlon.md +++ b/gcc/config/i386/athlon.md @@ -90,7 +90,7 @@ (athlon-decode0 | athlon-decode1 | athlon-decode2)") ;; Double instructions behaves like two direct instructions. -(define_reservation "athlon-double" "((athlon-decode2, athlon-decode0) +(define_reservation "athlon-double" "(athlon-decode2, athlon-decode0) | (nothing,(athlon-decode0 + athlon-decode1)) | (nothing,(athlon-decode1 + athlon-decode2)))") ...
and rebuild cc1, I get a segmentation fault: ... build/genautomata gcc/config/i386/i386.md \ insn-conditions.md > tmp-automata.c /bin/bash: line 1: 18077 Segmentation fault (core dumped) build/genautomata gcc/config/i386/i386.md insn-conditions.md > tmp-automata.c make: *** [s-automata] Error 139 ... The segmentation fault happens because sequence_vect is set to NULL here in gen_regexp_sequence in genautomata.c: ... sequence_vect = get_str_vect (str, &els_num, ',', TRUE); if (els_num > 1) ... and sequence_vect is dereferenced here: ... else return gen_regexp_oneof (sequence_vect[0]); ... The patch adds error checking for the specific case of unbalanced parentheses, and for sequence_vect == NULL in general. Using the patch the error message becomes: ... genautomata: unbalanced parentheses in reservation `(athlon-decode2, athlon-decode0) | (nothing,(athlon-decode0 + athlon-decode1)) | (nothing,(athlon-decode1 + athlon-decode2)))' ... Tested by completing a non-bootstrap build. OK for trunk? Thanks, - Tom 2013-06-07 Tom de Vries <t...@codesourcery.com> * genautomata.c (gen_regexp_sequence): Handle els_num == -1. Handle sequence_vect == NULL.
diff --git a/gcc/genautomata.c b/gcc/genautomata.c index 3665d95..add4624 100644 --- a/gcc/genautomata.c +++ b/gcc/genautomata.c @@ -1672,6 +1672,10 @@ gen_regexp_sequence (const char *str) int i; sequence_vect = get_str_vect (str, &els_num, ',', TRUE); + if (els_num == -1) + fatal ("unbalanced parentheses in reservation `%s'", str); + if (sequence_vect == NULL) + fatal ("invalid reservation `%s'", str); if (els_num > 1) { sequence = XCREATENODEVAR (struct regexp, sizeof (struct regexp)