This is the mail archive of the gdb-patches@sourceware.org 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 method overload resolution to expression parser


>>>>> "Keith" == Keith Seitz <keiths@redhat.com> writes:

Keith> The attached patch is the first of several patches which will attempt
Keith> mitigate the requirement of single-quoting every single C++ expression
Keith> passed to the parser.

I have a couple of questions about this.

First, since this is an extension to C++, I wonder whether it will
introduce any parsing ambiguities once the parser is complete.  I
suspect not, but I thought you might have a better view.

Keith> +exp     :       exp '(' nonempty_typelist ')' const_or_volatile

This is an interesting production.

I would have expected it to explicitly look for maybe-qualified
identifiers -- not an arbitrary expression.  Does this let us do
something we could not otherwise do?  Or, what does this do:

  print (return_a_function ()) (int)

Does it work to call an explicitly-specified overload?

  print overloaded(int)(5)

(I assume from reading the patch that this works as expected.)

Keith>  func_mod:	'(' ')'
Keith>  			{ $$ = 0; }
Keith>  	|	'(' nonempty_typelist ')'
Keith> -			{ free ($2); $$ = 0; }
Keith> +			{ do_cleanups (typelist_cleanup); $$ = 0; }

I'm a bit surprised that the cleanup stuff works in the parser.
Interesting.

Keith> +static void
Keith> +free_param_types (void *arg)

Needs a short intro comment.

Keith> +static struct type *
Keith> +make_params (int num_types, struct type **param_types)
[...]
Keith> +  make_cleanup (free_param_types, type);

It is a little unusual to make a cleanup that isn't returned.  Is it
really safe in this case?  To know that, I think you'd have to examine
all callers of evaluate_subexp_standard.  It seems somewhat safer to do
explicit cleanups in the TYPE_INSTANCE case, what do you think?

At the very least I think the comment for make_params should mention
this cleanup side effect.

Tom


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