Add error message for mismatched parentheses in reservation string
Vladimir Makarov
vmakarov@redhat.com
Tue Jun 11 00:49:00 GMT 2013
On 13-06-07 9:12 AM, Tom de Vries wrote:
> 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?
>
>
Yes. Thank you for fixing that, Tom.
More information about the Gcc-patches
mailing list