[PATCH]: Add -Wcast-qual to the bootstrap warning flags

Kaveh R. GHAZI ghazi@caip.rutgers.edu
Mon Sep 24 15:10:00 GMT 2007


On Sun, 23 Sep 2007, Andrew Pinski wrote:

> On 9/23/07, Kaveh R. GHAZI <ghazi@caip.rutgers.edu> wrote:
>
> > +       asprintf (CONST_CAST(char **, &m68k_library_id_string),
>                                               ^
> Missing space.  Also this looks wrong anyways.

What do you think is wrong with this exactly?  The m68k_library_id_string
variable is a const object that's being initialized here in asprintf.
Initializing const objects is one of the legitimate cases I've enumerated
for using CONST_CAST.  And as I mentioned I did "make cc1" cross-targetted
to m68k-unknown-linux-gnu (among many others) to ensure I didn't introduce
a typo.


>
> > +      cselib_val *e = cselib_lookup (CONST_CAST_RTX(x), GET_MODE (x), 0);
>
> Likewise.
>
> > +      cselib_val *e = cselib_lookup (CONST_CAST_RTX(y), GET_MODE (y), 0);
>
> And again.
>
>
> Can you double check all of the added CONST_CAST* to make sure they
> have the needed space between the macro name and the parentheses?

I'll double check these.  Thanks for catching it.


> Also why can't cselib_lookup take const_rtx?  I think you need to take
> more time to think about all of these const_* changes before just
> adding CONST_CAST*.
> Andrew Pinski

The reason cselib_lookup can't take a const_rtx is that it directly or
indirectly calls other functions which cannot be constified.  E.g. it
calls cselib_subst_to_values which returns it's parameter, one of the
cases I cannot fix without using a const_ shadow function.  It calls
wrap_constant, which again returns its param.  There are other problematic
functions called by cselib_lookup which I won't both to enumerate.

I could obviously force cselib_lookup to take a const_rtx, but then I'd
have to insert multiple CONST_CASTs downstream in the places it calls the
non-const functions.  Some people don't like over-using that macro, so I
tried to strike a balance between getting -Wcast-qual working and using
the fewest number of override casts.


Thanks for your feedback, assuming I fix the whitespace issues, ok for
mainline?

		Thanks,
		--Kaveh
--
Kaveh R. Ghazi			ghazi@caip.rutgers.edu



More information about the Gcc-patches mailing list