re PR c++/11553 (g++ accepts duplicate 'friend')
authorScott Brumbaugh <scottb.lists@verizon.net>
Tue, 2 Sep 2003 23:22:10 +0000 (23:22 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Tue, 2 Sep 2003 23:22:10 +0000 (23:22 +0000)
PR c++/11553
* parser.c (cp_parser_decl_specifier_seq): Add check for a
duplicate friend decl-specifier.

PR c++/11553
* g++.dg/parse/friend3.C: New test.

From-SVN: r71008

gcc/cp/ChangeLog
gcc/cp/parser.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/parse/friend3.C [new file with mode: 0644]

index b24258b4a87d96b12d7b9f64fade2106fa7ebb32..fbee4d64c181f3dbf83e4d46d45e1d5f285ce93b 100644 (file)
@@ -1,3 +1,9 @@
+2003-09-02  Scott Brumbaugh  <scottb.lists@verizon.net>
+
+       PR c++/11553
+       * parser.c (cp_parser_decl_specifier_seq): Add check for a
+       duplicate friend decl-specifier.
+
 2003-09-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/11847
index 01d6dba61ed3679a690c906dab6181ff6292eb37..916b042d80a2887cc5a32ce4a434d82ac39f1613 100644 (file)
@@ -6312,7 +6312,10 @@ cp_parser_decl_specifier_seq (cp_parser* parser,
        case RID_FRIEND:
          /* decl-specifier:
               friend  */
-         friend_p = true;
+         if (friend_p)
+           error ("duplicate `friend'");
+         else
+           friend_p = true;
          /* The representation of the specifier is simply the
             appropriate TREE_IDENTIFIER node.  */
          decl_spec = token->value;
index 2cac015c21aba608c2c590c3324514158eef8627..57b9436a933eabb3b5cfc1fb0e597d77e1fe2e21 100644 (file)
@@ -1,3 +1,8 @@
+2003-09-02  Scott Brumbaugh  <scottb.lists@verizon.net>
+
+       PR c++/11553
+       * g++.dg/parse/friend3.C: New test.
+       
 2003-09-02  Mark Mitchell  <mark@codesourcery.com>
 
        PR c++/11847
diff --git a/gcc/testsuite/g++.dg/parse/friend3.C b/gcc/testsuite/g++.dg/parse/friend3.C
new file mode 100644 (file)
index 0000000..3932202
--- /dev/null
@@ -0,0 +1,10 @@
+// { dg-do compile }
+//
+// PR 11553 catch duplicate friend specifiers
+
+struct S
+{
+       friend friend class C; // { dg-error "duplicate" }
+};
+
+