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: [RFC] Extend existing support for evaluating expressions using overloaded operators

>>>>> "Siva" == Siva Chandra <> 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.


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