[C++ PATCH] Fix -std=c++11 -std=gnu++11 option handling (PR c++/77948)

Jason Merrill jason@redhat.com
Mon Oct 31 12:36:00 GMT 2016


On Sat, Oct 29, 2016 at 1:09 PM, Jakub Jelinek <jakub@redhat.com> wrote:
> On Sat, Oct 29, 2016 at 12:41:43PM -0400, Jason Merrill wrote:
>> On Sat, Oct 29, 2016 at 12:09 PM, Jakub Jelinek <jakub@redhat.com> wrote:
>> > Apparently the driver reorders the options, -std=* options come before
>> > all -f* options, so both of the following patches work the same, except
>> > when cc1plus is invoked by hand.  The first (inlined) patch solves it
>> > more in line how e.g. -fgnu-keywords and similar options are handled, so I think
>> > it is preferable (and I've successfully bootstrapped/regtested it on
>> > x86_64-linux and i686-linux).  The second (attached) patch handles it
>> > by not clearing -fext-numeric-literals during option processing
>> > for -std=* options, just in post option handling clears it for the
>> > strict c++11+ modes if the option is not specified explicitly.
>> > If the driver wouldn't reorder the options, it would handle better
>> > cases like -fext-numeric-literals -std=c++11 to mean the same thing
>> > as -std=c++11 -fext-numeric-literals etc., but due to the reordering
>> > it isn't needed and for consistency we'd also need to change -fgnu-keywords
>> > etc.
>>
>> I lean toward the second patch because it keeps the logic in a single
>> place, but it looks like it doesn't currently handle C++98
>> differently.  I don't think we need to change the handling of other
>> options to match.
>
> The second patch has that
> +      /* Unless -f{,no-}ext-numeric-literals has been used explicitly,
> +        for -std=c++{11,14,1z} default to -fno-ext-numeric-literals.  */
> +      if (flag_iso && !global_options_set.x_flag_ext_numeric_literals)
> +       cpp_opts->ext_numeric_literals = 0;
> in a block guarded with cxx_dialect >= cxx11.  So for -std=c++98 it will
> just not disable them

Ah, OK then.

Jason



More information about the Gcc-patches mailing list