re PR c++/4100 ([parser] friend qualifier accepted in definition of nested class)
authorScott Brumbaugh <scottb.lists@verizon.net>
Mon, 12 Jan 2004 16:14:41 +0000 (16:14 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Mon, 12 Jan 2004 16:14:41 +0000 (16:14 +0000)
PR c++/4100
* parser.c (cp_parser_decl_specifier_seq): Add check for a friend
decl-specifier occurring along with a class definition.

From-SVN: r75726

gcc/cp/ChangeLog
gcc/cp/parser.c

index a8b4781ac44ee664b5d292c34b0ae0cbf1195b5f..48d831ecb63fa9c8bccc01f20535fcefd61e991f 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-12  Scott Brumbaugh  <scottb.lists@verizon.net>
+
+       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  <ian@wasabisystems.com>
 
        * parser.c (cp_parser_decl_specifier_seq): Add parenthetical
index 866012644cef64446ec9ef6888e51e610698f8ed..fe3a3dec9651c0fa1cab08aff90de40768a3e0a6 100644 (file)
@@ -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);