This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [RFC] Extend existing support for evaluating expressions using overloaded operators
- From: Tom Tromey <tromey at redhat dot com>
- To: Siva Chandra <sivachandra at google dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Mon, 04 Jun 2012 14:53:25 -0600
- Subject: Re: [RFC] Extend existing support for evaluating expressions using overloaded operators
- References: <CAGyQ6gz2SxhgW7WE7dLAwsdoRzV7DrU3M=KSsATSE7-5SRhQWA@mail.gmail.com>
>>>>> "Siva" == Siva Chandra <sivachandra@google.com> writes:
Siva> * valarith.c (value_binop): Extend to handle overloaded
Siva> binary operations on compound types.
I don't understand why value_binop must be modified.
I think in the current design it is up to the caller to check this.
(I don't necessarily think this is a good design -- but changing it
would require more changes elsewhere.)
Siva> +int
Siva> +is_compound_type (struct type *type)
Siva> +{
Siva> + enum type_code type_code;
Siva> +
Siva> + CHECK_TYPEDEF (type);
Siva> +
Siva> + type_code = TYPE_CODE (type);
Siva> + if (type_code == TYPE_CODE_STRUCT || type_code == TYPE_CODE_UNION)
It seems to me that there is other code which assumes that only
TYPE_CODE_STRUCT can be overloaded. At least binop_types_user_defined_p,
but maybe others. Those spots should be updated.
It would be nice if the test suite tested this case as well.
Siva> + TRY_CATCH (except, RETURN_MASK_ERROR)
Siva> + {
Siva> + /* Retrieve the list of methods with the name NAME. */
Siva> + fns_ptr = value_find_oload_method_list (&temp, name,
Siva> + 0, &num_fns,
Siva> + &basetype, &boffset);
Siva> + }
Siva> + if (except.reason < 0)
Siva> + fns_ptr = NULL;
I'll have to go read this in more depth; but I wonder why it is ok to
ignore exceptions here.
Tom