This is the mail archive of the mailing list for the GDB 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: [RFA] Add parsing support for C++ operators

>>>>> "Keith" == Keith Seitz <> writes:

Keith> 2009-11-10  Keith Seitz  <>
Keith> 	* c-expy. (operator_stoken): New function.
Keith> 	(OPERATOR): New token.
Keith> 	(NEW): New token.
Keith> 	(DELETE): New token.
Keith> 	(operator): New rule.
Keith> 	(name): Add operator.
Keith> 	(ident_tokens): Add "new", "delete", and "operator".
Keith> 	* gdbtypes.c (rank_one_type): Don't complain about
Keith> 	void pointer conversion badness if both types are
Keith> 	void pointers.

Keith> +	|	OPERATOR ptype
Keith> +			{ char *name;
Keith> +			  long length;
Keith> +			  struct ui_file *buf = mem_fileopen ();
Keith> +
Keith> +			  c_print_type ($2, NULL, buf, -1, 0);
Keith> +			  name = ui_file_xstrdup (buf, &length);
Keith> +			  ui_file_delete (buf);
Keith> +			  $$ = operator_stoken (name);

This leaks 'name', you need a free after the call to operator_stoken.

Keith> +  /* The toplevel (c_parse) will free the memory allocated here.  */
Keith> +  make_cleanup (free, st.ptr);
Keith> +  return st;

On irc you expressed some doubt about this approach.  It is fine.

This is ok with the above change.  Thanks.


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