PR python/18285
[deliverable/binutils-gdb.git] / gdb / valarith.c
index 154629bfc62baa7668d0d110f2a852675f321e4a..df1e8c3a17c621a21d2c624e57b70aa425db17e3 100644 (file)
@@ -1,6 +1,6 @@
 /* Perform arithmetic and other operations on values, for GDB.
 
-   Copyright (C) 1986-2014 Free Software Foundation, Inc.
+   Copyright (C) 1986-2015 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -284,14 +284,14 @@ unop_user_defined_p (enum exp_opcode op, struct value *arg1)
    situations or combinations thereof.  */
 
 static struct value *
-value_user_defined_cpp_op (struct value **args, int nargs, char *operator,
+value_user_defined_cpp_op (struct value **args, int nargs, char *oper,
                            int *static_memfuncp, enum noside noside)
 {
 
   struct symbol *symp = NULL;
   struct value *valp = NULL;
 
-  find_overload_match (args, nargs, operator, BOTH /* could be method */,
+  find_overload_match (args, nargs, oper, BOTH /* could be method */,
                        &args[0] /* objp */,
                        NULL /* pass NULL symbol since symbol is unknown */,
                        &valp, &symp, static_memfuncp, 0, noside);
@@ -308,7 +308,7 @@ value_user_defined_cpp_op (struct value **args, int nargs, char *operator,
       return value_of_variable (symp, 0);
     }
 
-  error (_("Could not find %s."), operator);
+  error (_("Could not find %s."), oper);
 }
 
 /* Lookup user defined operator NAME.  Return a value representing the
@@ -482,6 +482,21 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
          argvec[1] = argvec[0];
          argvec++;
        }
+      if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD)
+       {
+         /* Static xmethods are not supported yet.  */
+         gdb_assert (static_memfuncp == 0);
+         if (noside == EVAL_AVOID_SIDE_EFFECTS)
+           {
+             struct type *return_type
+               = result_type_of_xmethod (argvec[0], 2, argvec + 1);
+
+             if (return_type == NULL)
+               error (_("Xmethod is missing return type."));
+             return value_zero (return_type, VALUE_LVAL (arg1));
+           }
+         return call_xmethod (argvec[0], 2, argvec + 1);
+       }
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
        {
          struct type *return_type;
@@ -490,16 +505,8 @@ value_x_binop (struct value *arg1, struct value *arg2, enum exp_opcode op,
            = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0])));
          return value_zero (return_type, VALUE_LVAL (arg1));
        }
-
-      if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD)
-       {
-         /* Static xmethods are not supported yet.  */
-         gdb_assert (static_memfuncp == 0);
-         return call_xmethod (argvec[0], 2, argvec + 1);
-       }
-      else
-       return call_function_by_hand (argvec[0], 2 - static_memfuncp,
-                                     argvec + 1);
+      return call_function_by_hand (argvec[0], 2 - static_memfuncp,
+                                   argvec + 1);
     }
   throw_error (NOT_FOUND_ERROR,
                _("member function %s not found"), tstr);
@@ -594,6 +601,21 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
          nargs --;
          argvec++;
        }
+      if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD)
+       {
+         /* Static xmethods are not supported yet.  */
+         gdb_assert (static_memfuncp == 0);
+         if (noside == EVAL_AVOID_SIDE_EFFECTS)
+           {
+             struct type *return_type
+               = result_type_of_xmethod (argvec[0], 1, argvec + 1);
+
+             if (return_type == NULL)
+               error (_("Xmethod is missing return type."));
+             return value_zero (return_type, VALUE_LVAL (arg1));
+           }
+         return call_xmethod (argvec[0], 1, argvec + 1);
+       }
       if (noside == EVAL_AVOID_SIDE_EFFECTS)
        {
          struct type *return_type;
@@ -602,14 +624,7 @@ value_x_unop (struct value *arg1, enum exp_opcode op, enum noside noside)
            = TYPE_TARGET_TYPE (check_typedef (value_type (argvec[0])));
          return value_zero (return_type, VALUE_LVAL (arg1));
        }
-      if (TYPE_CODE (value_type (argvec[0])) == TYPE_CODE_XMETHOD)
-       {
-         /* Static xmethods are not supported yet.  */
-         gdb_assert (static_memfuncp == 0);
-         return call_xmethod (argvec[0], 1, argvec + 1);
-       }
-      else
-       return call_function_by_hand (argvec[0], nargs, argvec + 1);
+      return call_function_by_hand (argvec[0], nargs, argvec + 1);
     }
   throw_error (NOT_FOUND_ERROR,
                _("member function %s not found"), tstr);
This page took 0.05112 seconds and 4 git commands to generate.