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

--- Comment #3 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:77ab4e3be2d92b1ff671d58418d852195f10dd20

commit r12-2607-g77ab4e3be2d92b1ff671d58418d852195f10dd20
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Fri Jul 30 10:30:16 2021 +0200

    c++: Accept C++11 attribute-definition [PR101582]

    As the following testcase shows, we don't parse properly
    C++11 attribute-declaration:
    https://eel.is/c++draft/dcl.dcl#nt:attribute-declaration

    cp_parser_toplevel_declaration just handles empty-declaration parsing
    (with diagnostics for C++98) and otherwise calls cp_parser_declaration
    which on it calls cp_parser_simple_declaration and rejects it with
    "does not declare anything" permerror.

    The following patch moves the handling of empty-declaration from
    cp_parser_toplevel_declaration to cp_parser_declaration and
    handles attribute-declaration in cp_parser_declaration
    by parsing the attributes (standard ones only, we've never supported
    __attribute__((...)); at namespace scope, so I'm not sure we need to
    introduce that), which for C++98 emits the needed diagnostics, and then
    warning if there are any attributes that we throw away on the floor.

    I'll need this later for OpenMP directives at namespace scope, e.g.
    [[omp::directive (requires, atomic_default_mem_order(seq_cst))]];
    should be valid at namespace scope (and many other directives).

    2021-07-30  Jakub Jelinek  <ja...@redhat.com>

            PR c++/101582
            * parser.c (cp_parser_skip_std_attribute_spec_seq): Add a forward
            declaration.
            (cp_parser_declaration): Parse empty-declaration and
            attribute-declaration.
            (cp_parser_toplevel_declaration): Don't parse empty-declaration
here.

            * g++.dg/cpp0x/gen-attrs-45.C: Expect a warning about ignored
            attributes instead of error.
            * g++.dg/cpp0x/gen-attrs-75.C: New test.
            * g++.dg/modules/pr101582-1.C: New test.
  • [Bug c++/101582] C++ FE doesn't... cvs-commit at gcc dot gnu.org via Gcc-bugs

Reply via email to