Skip to content
Snippets Groups Projects
Commit 786ebbd6 authored by Simon Martin's avatar Simon Martin
Browse files

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

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

=== 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.
parent 180ede35
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment