gdb/
[platform/upstream/binutils.git] / gdb / valops.c
index b9f5508..ee05d73 100644 (file)
@@ -860,7 +860,7 @@ value_zero (struct type *type, enum lval_type lv)
 {
   struct value *val = allocate_value (type);
 
-  VALUE_LVAL (val) = lv;
+  VALUE_LVAL (val) = (lv == lval_computed ? not_lval : lv);
   return val;
 }
 
@@ -1377,7 +1377,7 @@ value_assign (struct value *toval, struct value *fromval)
 
     case lval_computed:
       {
-       struct lval_funcs *funcs = value_computed_funcs (toval);
+       const struct lval_funcs *funcs = value_computed_funcs (toval);
 
        funcs->write (toval, fromval);
       }
@@ -1740,7 +1740,7 @@ value_ind (struct value *arg1)
 
   if (VALUE_LVAL (arg1) == lval_computed)
     {
-      struct lval_funcs *funcs = value_computed_funcs (arg1);
+      const struct lval_funcs *funcs = value_computed_funcs (arg1);
 
       if (funcs->indirect)
        {
@@ -2585,6 +2585,7 @@ find_overload_match (struct type **arg_types, int nargs,
          if (*valp)
            {
              *staticp = 1;
+             do_cleanups (all_cleanups);
              return 0;
            }
        }
@@ -2670,6 +2671,7 @@ find_overload_match (struct type **arg_types, int nargs,
       if (func_name == NULL)
         {
          *symp = fsym;
+         do_cleanups (all_cleanups);
           return 0;
         }
 
@@ -3098,14 +3100,16 @@ classify_oload_match (struct badness_vector *oload_champ_bv,
 
 /* C++: return 1 is NAME is a legitimate name for the destructor of
    type TYPE.  If TYPE does not have a destructor, or if NAME is
-   inappropriate for TYPE, an error is signaled.  */
+   inappropriate for TYPE, an error is signaled.  Parameter TYPE should not yet
+   have CHECK_TYPEDEF applied, this function will apply it itself.  */
+
 int
-destructor_name_p (const char *name, const struct type *type)
+destructor_name_p (const char *name, struct type *type)
 {
   if (name[0] == '~')
     {
-      char *dname = type_name_no_tag (type);
-      char *cp = strchr (dname, '<');
+      const char *dname = type_name_no_tag_or_error (type);
+      const char *cp = strchr (dname, '<');
       unsigned int len;
 
       /* Do not compare the template part for template classes.  */
@@ -3339,25 +3343,32 @@ value_struct_elt_for_reference (struct type *domain, int offset,
              int ii;
 
              j = -1;
-             for (ii = 0; ii < TYPE_FN_FIELDLIST_LENGTH (t, i);
-                  ++ii)
+             for (ii = 0; ii < len; ++ii)
                {
                  /* Skip artificial methods.  This is necessary if,
                     for example, the user wants to "print
                     subclass::subclass" with only one user-defined
-                    constructor.  There is no ambiguity in this
-                    case.  */
+                    constructor.  There is no ambiguity in this case.
+                    We are careful here to allow artificial methods
+                    if they are the unique result.  */
                  if (TYPE_FN_FIELD_ARTIFICIAL (f, ii))
-                   continue;
+                   {
+                     if (j == -1)
+                       j = ii;
+                     continue;
+                   }
 
                  /* Desired method is ambiguous if more than one
                     method is defined.  */
-                 if (j != -1)
+                 if (j != -1 && !TYPE_FN_FIELD_ARTIFICIAL (f, j))
                    error (_("non-unique member `%s' requires "
                             "type instantiation"), name);
 
                  j = ii;
                }
+
+             if (j == -1)
+               error (_("no matching member function"));
            }
 
          if (TYPE_FN_FIELD_STATIC_P (f, j))
@@ -3592,13 +3603,20 @@ value_full_object (struct value *argp,
    inappropriate context.  */
 
 struct value *
-value_of_local (const char *name, int complain)
+value_of_this (const struct language_defn *lang, int complain)
 {
-  struct symbol *func, *sym;
+  struct symbol *sym;
   struct block *b;
   struct value * ret;
   struct frame_info *frame;
 
+  if (!lang->la_name_of_this)
+    {
+      if (complain)
+       error (_("no `this' in current language"));
+      return 0;
+    }
+
   if (complain)
     frame = get_selected_frame (_("no frame selected"));
   else
@@ -3608,54 +3626,24 @@ value_of_local (const char *name, int complain)
        return 0;
     }
 
-  func = get_frame_function (frame);
-  if (!func)
-    {
-      if (complain)
-       error (_("no `%s' in nameless context"), name);
-      else
-       return 0;
-    }
+  b = get_frame_block (frame, NULL);
 
-  b = SYMBOL_BLOCK_VALUE (func);
-  if (dict_empty (BLOCK_DICT (b)))
-    {
-      if (complain)
-       error (_("no args, no `%s'"), name);
-      else
-       return 0;
-    }
-
-  /* Calling lookup_block_symbol is necessary to get the LOC_REGISTER
-     symbol instead of the LOC_ARG one (if both exist).  */
-  sym = lookup_block_symbol (b, name, VAR_DOMAIN);
+  sym = lookup_language_this (lang, b);
   if (sym == NULL)
     {
       if (complain)
        error (_("current stack frame does not contain a variable named `%s'"),
-              name);
+              lang->la_name_of_this);
       else
        return NULL;
     }
 
   ret = read_var_value (sym, frame);
   if (ret == 0 && complain)
-    error (_("`%s' argument unreadable"), name);
+    error (_("`%s' argument unreadable"), lang->la_name_of_this);
   return ret;
 }
 
-/* C++/Objective-C: return the value of the class instance variable,
-   if one exists.  Flag COMPLAIN signals an error if the request is
-   made in an inappropriate context.  */
-
-struct value *
-value_of_this (int complain)
-{
-  if (!current_language->la_name_of_this)
-    return 0;
-  return value_of_local (current_language->la_name_of_this, complain);
-}
-
 /* Create a slice (sub-string, sub-array) of ARRAY, that is LENGTH
    elements long, starting at LOWBOUND.  The result has the same lower
    bound as the original ARRAY.  */