diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index a8b4781ac44..48d831ecb63 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2004-01-12 Scott Brumbaugh + + PR c++/4100 + * parser.c (cp_parser_decl_specifier_seq): Add check for a friend + decl-specifier occurring along with a class definition. + 2004-01-12 Ian Lance Taylor * parser.c (cp_parser_decl_specifier_seq): Add parenthetical diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index 866012644ce..fe3a3dec965 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -6726,6 +6726,10 @@ cp_parser_decl_specifier_seq (cp_parser* parser, flags |= CP_PARSER_FLAGS_OPTIONAL; } + /* Don't allow a friend specifier with a class definition. */ + if (friend_p && (*declares_class_or_enum & 2)) + error ("class definition may not be declared a friend"); + /* We have built up the DECL_SPECS in reverse order. Return them in the correct order. */ return nreverse (decl_specs);