[patch]: Address const warnings in gimple.h

Kai Tietz ktietz70@googlemail.com
Wed Jun 9 13:10:00 GMT 2010


2010/6/9 Richard Guenther <richard.guenther@gmail.com>:
> On Wed, Jun 9, 2010 at 2:41 PM, Kai Tietz <Kai.Tietz@onevision.com> wrote:
>> Hello,
>>
>> this patch address some warnings seen during build caused by
>> const/non-const type-casts. I've noticed them by using gcc 3.4.4 for
>> bootstrap a cross-compiler.
>>
>> ChangeLog
>>
>> 2010-06-09  Kai Tietz
>>
>>        * gimple.h (gimple_statement_structure): Use const argument.
>>        (gimple_ops): Likewise.
>>        Do type-cast by union.
>>        (gimple_op): Remove use of CONST_CAST_GIMPLE.
>>        (gimple_op_ptr): Likewise.
>>
>> Tested for x86_64-pc-linux-gnu, i686-pc-cygwin, and x86_64-pc-mingw32. Ok
>> for apply?
>
> +gimple_ops (const_gimple gs)
>  {
> +  union {
> +    tree *t;
> +    const_gimple gs;
> +    char *c;
> +  } v;
>   size_t off;
>
>   /* All the tuples have their operand vector at the very bottom
> @@ -1642,7 +1647,9 @@ gimple_ops (gimple gs)
>   off = gimple_ops_offset_[gimple_statement_structure (gs)];
>   gcc_assert (off != 0);
>
> -  return (tree *) ((char *) gs + off);
> +  v.gs = gs;
> +  v.c += off;
>
> ugh.
>
> Why not simply use
>
> static inline const_tree *
> gimple_ops (const_gimple gs)
> {
>  ...
>  return (const_tree *)((const char *) gs + off);
> }
>
> ?

Well return of gimple_ops is returning tree * AFAIR. Therefore here is
const/non-const change necessary, which makes here exactly the issue
for 3.4.4, as it get warned.

Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination



More information about the Gcc-patches mailing list