Commit f06a1142 by Paolo Carlini Committed by Paolo Carlini

re PR c++/54216 (Missing diagnostic for ill-formed anonymous enum declarations)

/cp
2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54216
	* parser.c (cp_parser_enum_specifier): Check for empty
	anonymous enums and anonymous scoped enums.

/testsuite
2013-04-11  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/54216
	* g++.dg/cpp0x/enum26.C: New.
	* g++.old-deja/g++.pt/mangle1.C: Adjust.

From-SVN: r197742
parent d07458be
2013-04-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54216
* parser.c (cp_parser_enum_specifier): Check for empty
anonymous enums and anonymous scoped enums.
2013-04-10 Jakub Jelinek <jakub@redhat.com> 2013-04-10 Jakub Jelinek <jakub@redhat.com>
PR c++/56895 PR c++/56895
......
...@@ -14750,6 +14750,9 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -14750,6 +14750,9 @@ cp_parser_enum_specifier (cp_parser* parser)
{ {
identifier = make_anon_name (); identifier = make_anon_name ();
is_anonymous = true; is_anonymous = true;
if (scoped_enum_p)
error_at (type_start_token->location,
"anonymous scoped enum is not allowed");
} }
} }
pop_deferring_access_checks (); pop_deferring_access_checks ();
...@@ -14897,7 +14900,13 @@ cp_parser_enum_specifier (cp_parser* parser) ...@@ -14897,7 +14900,13 @@ cp_parser_enum_specifier (cp_parser* parser)
if (type == error_mark_node) if (type == error_mark_node)
cp_parser_skip_to_end_of_block_or_statement (parser); cp_parser_skip_to_end_of_block_or_statement (parser);
/* If the next token is not '}', then there are some enumerators. */ /* If the next token is not '}', then there are some enumerators. */
else if (cp_lexer_next_token_is_not (parser->lexer, CPP_CLOSE_BRACE)) else if (cp_lexer_next_token_is (parser->lexer, CPP_CLOSE_BRACE))
{
if (is_anonymous && !scoped_enum_p)
pedwarn (type_start_token->location, OPT_Wpedantic,
"ISO C++ forbids empty anonymous enum");
}
else
cp_parser_enumerator_list (parser, type); cp_parser_enumerator_list (parser, type);
/* Consume the final '}'. */ /* Consume the final '}'. */
......
2013-04-11 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/54216
* g++.dg/cpp0x/enum26.C: New.
* g++.old-deja/g++.pt/mangle1.C: Adjust.
2013-04-11 James Greenhalgh <james.greenhalgh@arm.com> 2013-04-11 James Greenhalgh <james.greenhalgh@arm.com>
* gcc.target/aarch64/vect-fcm.x: Add check for zero forms of * gcc.target/aarch64/vect-fcm.x: Add check for zero forms of
......
// PR c++/54216
// { dg-options "-std=c++11 -pedantic" }
enum {}; // { dg-warning "empty anonymous" }
enum class {}; // { dg-error "anonymous" }
enum class { x }; // { dg-error "anonymous" }
// { dg-do assemble } // { dg-do assemble }
// { dg-options "" }
// Origin: Mark Mitchell <mark@codesourcery.com> // Origin: Mark Mitchell <mark@codesourcery.com>
typedef enum {} i; typedef enum {} i;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment