https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86733

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Emmanuel Thomé from comment #2)
> (In reply to Jonathan Wakely from comment #1)
> > Presumably the handling for the pragma just turns the option on without
> > considering the current cxx_dialect.
> 
> It seems to me that it is not consistent with the test case compiling fine
> with g++ -std=c++11 -c foo.cpp , is it ?

That's why I confirmed it as a bug.

> > This should fix it:
> > 
> > --- a/gcc/cp/parser.c
> > +++ b/gcc/cp/parser.c
> > @@ -9210,7 +9210,7 @@ cp_parser_binary_expression (cp_parser* parser, bool
> > cast_p,
> >        /* Get an operator token.  */
> >        token = cp_lexer_peek_token (parser->lexer);
> >  
> > -      if (warn_cxx11_compat
> > +      if (warn_cxx11_compat && cxx_dialect < cxx11
> >            && token->type == CPP_RSHIFT
> >            && !parser->greater_than_is_operator_p)
> >          {
> 
> Yes it does.
> 
> However, when reading gcc/c-family/c-opts.c one surmises that there is an
> intent to disable warn_cxx11_compat altogether if cxx_dialect >= cxx11 ;
> this code path is apparently not walked when warnings are enabled with
> #pragma, which (I presume) sets -Wall only based on EnabledBy and
> LangEnabledBy in c.opt, unconditionally.

Yes, that's what I said above.

> Maybe there are other bugs in the same vein, then (insofar as "warning X is
> enabled by -Wall [or -Wextra] in [dialect XYZ]" is often implemented in
> c-opts.c, and would then be missed by the #pragma).

Possibly. I had a look at some other uses of warn_cxx11_compat and they were OK
(because the warning would not get reached for later dialects).

Reply via email to