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]

Re: [patch] Diagnose invalid destructor name in friend declarations


Volker Reichelt wrote:
> Currently we don't diagnose invalid code like the following:
> 
>   struct A {};
> 
>   struct B
>   {
>     friend A::~B();
>   };
> 
> The following patch fixes that by checking in cp_parser_unqualified_id
> that the destructor name and the scope match.
> 
> Bootstrapped and regtested on x86_64-unknown-linux-gnu.
> Ok for mainline?
> 
> Regards,
> Volker
> 
> :ADDPATCH C++:
> 
> 
> 2005-12-16  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
> 
> 	* parser.c (cp_parser_unqualified_id): Check that destructor name
> 	and scope match.
> 
> ===================================================================
> --- gcc/gcc/cp/parser.c	(revision 108622)
> +++ gcc/gcc/cp/parser.c	(working copy)
> @@ -3419,6 +3419,16 @@
>  	else if (type_decl == error_mark_node)
>  	  return error_mark_node;
>  
> +	/* Check that destructor name and scope match.  */
> +	if (declarator_p && scope
> +	    && !same_type_p (scope, TREE_TYPE (type_decl)))

Use check_dtor_name; OK with that change.

Thanks,

-- 
Mark Mitchell
CodeSourcery, LLC
mark@codesourcery.com
(650) 331-3385 x713


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