This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch]: Address const warnings in gimple.h


2010/6/9 Richard Guenther <richard.guenther@gmail.com>:
> On Wed, Jun 9, 2010 at 2:57 PM, Kai Tietz <ktietz70@googlemail.com> wrote:
>> 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.
>
> Well, if gimple_ops returns tree * then it shouldn't get a const_gimple.
> Your patch just moves the kludge elsewhere (and adds to it with
> a ugly union), and thus is not an improvement for const-correcntess.
>
> Richard.

Well, it moves the kludge of using CONST_CAST_GIMPLE at one point and
avoids the warning for older gcc. I see that this is worse then
before, but well, I am open-minded here.
Maybe this could be also addressed (at least for the known CAST-type
macros in system.h via static inline functions for gcc <= 4.0, which
are hiding the necessary kludge.

Kai


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]