[Patch] p-exp.y: Typecast left operand of BINOP_DIV to long double

Daniel Jacobowitz drow@false.org
Thu Jan 31 22:43:00 GMT 2008


On Mon, Jan 28, 2008 at 04:47:26PM +0100, Pierre Muller wrote:
>   Could someone please confirm that the
> way I inserted the implicit typecast in the parser is
> correct?
>   All comments most welcome.

It looks OK to me.  Does the type of the left operand completely
determine the type of the operation, or do you need to worry about the
type of the right-hand exp too before you cast?

> @@ -367,7 +370,15 @@ exp        :       exp '*' exp
>                         { write_exp_elt_opcode (BINOP_MUL); }
>         ;
> 
> -exp    :       exp '/' exp
> +exp    :       exp '/' {
> +                         if (current_type && is_integral_type
> (current_type))
> +                           {
> +                             write_exp_elt_opcode (UNOP_CAST);
> +                             write_exp_elt_type (builtin_type_long_double);
> +                             write_exp_elt_opcode (UNOP_CAST);
> +                           }
> +                       }
> +               exp
>                         { write_exp_elt_opcode (BINOP_DIV); }
>         ;
> 

Won't current_type still be integral after this?  Try 1 / 2 / 3.

-- 
Daniel Jacobowitz
CodeSourcery



More information about the Gdb-patches mailing list