[C++ PATCH] Disallow type specifiers among lambda-declarator decl-specifier-seq (PR c++/86550)

Jason Merrill jason@redhat.com
Wed Jul 18 01:34:00 GMT 2018


On Wed, Jul 18, 2018 at 4:57 AM, Jakub Jelinek <jakub@redhat.com> wrote:
> The standard says:
> "In the decl-specifier-seq of the lambda-declarator, each decl-specifier shall
> either be mutable or constexpr."
> and the C++ FE has CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR flag for that.
> But as implemented, it is actually
> CP_PARSER_FLAGS_ONLY_TYPE_OR_MUTABLE_OR_CONSTEXPR
> as it allows mutable, constexpr and type specifiers.
>
> Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, ok for
> trunk?
>
> 2018-07-17  Jakub Jelinek  <jakub@redhat.com>
>
>         PR c++/86550
>         * parser.c (cp_parser_decl_specifier_seq): Don't parse a type specifier
>         if CP_PARSER_FLAGS_ONLY_MUTABLE_OR_CONSTEXPR.

I think the diagnostic would be better if we parse the type-specifier
and then give an error about it being invalid in this context, rather
than not parse it and therefore give a syntax error; the constraint is
semantic rather than syntactic.

Jason



More information about the Gcc-patches mailing list