This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch] Fix 11553 (duplicated friend specifier)


Hi,

I am trying to understand the C++ parser and thought fixing some bugs
would help to that end.  This is a pretty straight forward one, I
think.  The parser allows multiple friend decl-specifiers to appear in
a friend declaration.  This change will cause the function
cp_parser_decl_specifier_seq to complain if it sees more than one
friend specifier.


Thanks,

Scott Brumbaugh




2003-08-14  Scott Brumbaugh  <scottb.lists@verizon.net>


	PR C++/11553

	* parser.c (cp_parser_decl_specifier_seq): Add check for a
	duplicate friend decl-specifier.


Index: parser.c
===================================================================
RCS file: /cvsroot/gcc/gcc/gcc/cp/parser.c,v
retrieving revision 1.100
diff -c -3 -p -r1.100 parser.c
*** parser.c	12 Aug 2003 22:26:22 -0000	1.100
--- parser.c	14 Aug 2003 05:24:52 -0000
*************** cp_parser_decl_specifier_seq (cp_parser*
*** 6282,6288 ****
  	case RID_FRIEND:
  	  /* decl-specifier:
  	       friend  */
! 	  friend_p = true;
  	  /* The representation of the specifier is simply the
  	     appropriate TREE_IDENTIFIER node.  */
  	  decl_spec = token->value;
--- 6282,6291 ----
  	case RID_FRIEND:
  	  /* decl-specifier:
  	       friend  */
! 	  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;



// { dg-do compile }

// PR 11553 catch duplicate friend specifiers

struct S
{
	friend friend class C; // { dg-error "duplicate" }
};


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]