This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Fix bootstrap issues with C++
On Tue, 1 Jun 2010, Richard Guenther wrote:
> > > case OPT_pedantic_errors:
> > > ! global_dc->pedantic_errors = flag_pedantic_errors = pedantic = 1;
> > > --- 2182,2189 ----
> > > ! flag_pedantic_errors = pedantic = 1;
> > > ! global_dc->pedantic_errors = 1;
> >
> > ? Somehow I must have missed this decision.
>
> The above is the bool vs. int issue. flag_pedantic_errors = pedantic = 1
> is treated as truth-value and thus we emit a warnign that suggests
> parantheses.
>
> I don't see these as "ugly workarounds" at all.
The proper fix would be for most option variables to be bool, unless the
actually have values other than 0 and 1 (those that use "-1" for default
or uninitialized might better use a separate boolean variable to indicate
that). (bool = bool = whatever doesn't get the warning from the C++ front
end that bool = int = whatever does.) Maybe that will be easier after I
generally overhaul the option processing machinery.
(Changing int to bool (along with using true and false instead of 1 and 0)
to make it more explicit what values may occur in a particular variable,
function argument, function return value is something I'd generally
consider a good idea, and can of course be done incrementally in most of
the compiler where you're not dealing with automatically-generated
declarations as you are with options.)
--
Joseph S. Myers
joseph@codesourcery.com