This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [C++ PATCH] Fix -std=c++11 -std=gnu++11 option handling (PR c++/77948)
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches List <gcc-patches at gcc dot gnu dot org>
- Date: Sat, 29 Oct 2016 19:09:23 +0200
- Subject: Re: [C++ PATCH] Fix -std=c++11 -std=gnu++11 option handling (PR c++/77948)
- Authentication-results: sourceware.org; auth=none
- References: <20161029160907.GZ3541@tucnak.redhat.com> <CADzB+2=EDHQQ=p-XPbP4dP3gGQSdELB3GyNHvWDwuP0XCGjUSg@mail.gmail.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
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 (the same as the other patch, and the same as
vanilla trunk/6/5 if just using -std=c++98 and not -std=c++11 -std=c++98;
or do you want to change behavior of -std=c++98 to reject those unless
using -std=gnu++98 or -std=c++98 -fext-numeric-literals? Pedantically
they are GNU extensions, but if we want to be pedantic,
-pedantic/-pedantic-errors already rejects those anyway.
Jakub