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

--- Comment #5 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Simon Martin <simar...@gcc.gnu.org>:

https://gcc.gnu.org/g:786ebbd6058540b2110da16a693f0c582c11413c

commit r15-2855-g786ebbd6058540b2110da16a693f0c582c11413c
Author: Simon Martin <si...@nasilyan.com>
Date:   Thu Aug 8 14:59:49 2024 +0200

    c++: Don't accept multiple enum definitions within template class
[PR115806]

    We have been accepting the following invalid code since revision
557831a91df

    === cut here ===
    template <typename T> struct S {
      enum E { a };
      enum E { b };
    };
    S<int> s;
    === cut here ===

    The problem is that start_enum will set OPAQUE_ENUM_P to true even if it
    retrieves an existing definition for the enum, which causes the
redefinition
    check in cp_parser_enum_specifier to be bypassed.

    This patch only sets OPAQUE_ENUM_P and ENUM_FIXED_UNDERLYING_TYPE_P when
    actually pushing a new tag for the enum.

            PR c++/115806

    gcc/cp/ChangeLog:

            * decl.cc (start_enum): Only set OPAQUE_ENUM_P and
            ENUM_FIXED_UNDERLYING_TYPE_P when pushing a new tag.

    gcc/testsuite/ChangeLog:

            * g++.dg/parse/enum15.C: New test.

Reply via email to