public inbox for archer-commits@sourceware.org
help / color / mirror / Atom feed
* [SCM]  archer-swagiaal-upstream: Fix overload resolution between children of common ancestor.
@ 2010-08-23 17:20 swagiaal
  0 siblings, 0 replies; only message in thread
From: swagiaal @ 2010-08-23 17:20 UTC (permalink / raw)
  To: archer-commits

The branch, archer-swagiaal-upstream has been updated
       via  0b1172b7810275b9ff3342cb293b6e9c50148ac0 (commit)
       via  d30d08cbc1a437f871279b0cefc4f05763238e9e (commit)
       via  b6c2e78d5aa2b52cde4a9150cd7dcc91a6f0f7c7 (commit)
       via  b7cebc083e9475f3146c27def7ae6b3e2fa73e2a (commit)
       via  6239b97886ed7527d3e77bdda8a77e80cfece556 (commit)
       via  83aca1085035c1c3da63d44891e44dfea9ea2265 (commit)
       via  e86c896f9856a8af198c85b0798032241ef8a5a5 (commit)
       via  2c5567253350010207722f073ebf1d3500c75ad7 (commit)
       via  5a078cb53dc4808d6f36986fb990b461f81aa2aa (commit)
       via  55c93c81de2bf85de1f6990961fea2755b565ea3 (commit)
       via  b2e4bddfc79c51eccf59e0cdc628fe47421562fc (commit)
      from  b7cc4b712fb3f599e8725f2b0d2e5b410d5b6403 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email.

- Log -----------------------------------------------------------------
commit 0b1172b7810275b9ff3342cb293b6e9c50148ac0
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Jul 26 15:14:47 2010 -0400

    Fix overload resolution between children of common ancestor.
    
    2010-07-26  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdbtypes.h (distance_to_public_ancestor): New function.
    	* gdbtypes.c (distance_to_public_ancestor): New function.
    	(rank_one_type): Concider distance_to_public_ancestor when ranking
    	two structs.
    	(is_public_ancestor): Use distance_to_public_ancestor.
    
    2010-07-26  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.cp/overload.cc: Add testing for overload resolution based on
    	distance to ancestor.
    	* gdb.cp/overload.exp: Ditto.

commit d30d08cbc1a437f871279b0cefc4f05763238e9e
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Jul 26 11:49:59 2010 -0400

    Fixed void* vs int* overload issue (PR C++/10343).
    
    2010-07-26  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdbtypes.h: Made VOID_PTR_CONVERSION_BADNESS better than
    	INTEGER_PROMOTION_BADNESS.
    
    2010-07-26  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	PR C++/10343
    	* gdb.cp/overload.cc: Added test for void* vs int* overload.
    	* gdb.cp/overload.exp: Ditto.

commit b6c2e78d5aa2b52cde4a9150cd7dcc91a6f0f7c7
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Jul 20 11:10:33 2010 -0400

    Support overloading of 'operator->'.
    
    2010-08-09  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	 PR C++/11500:
    	* valarith.c (value_x_unop): Handle STRUCTOP_PTR.
    	* eval.c (evaluate_subexp_standard): Check for overload of
    	'operator->'.
    
    2010-08-09  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.cp/smartp.exp: New test.
    	* gdb.cp/smartp.cc : New test.

commit b7cebc083e9475f3146c27def7ae6b3e2fa73e2a
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Jul 6 16:26:33 2010 -0400

    Template meta var now knows about its instances.
    
    2010-07-16  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* symtab.h (symbol_add_template_instance): New function prototype.
    	(symbol_get_template_instances): New function prototype.
    	Created struct symbol_list_element.
    	(instances): Add an instance of symbol_list_element to
    	general_symbol_info
    	* symtab.c (symbol_add_template_instance): New function.
    	(symbol_get_template_instances): New function.
    	* findvar.c (read_var_value): Print list of candidates when
    	attempting to
    	evaluate a LOC_TEMPLATE.
    	* dwarf2read.c (add_template_variable): Find template variable and
    	add instance reference to it.

commit 6239b97886ed7527d3e77bdda8a77e80cfece556
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Jun 23 11:24:37 2010 -0400

    Add template meta-variable.
    
    2010-07-16  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* valops.c (find_overload_match): Handle TYPE_CODE_TEMPLATE.
    	* symtab.h: Added LOC_TEMPLATE to address_class.
    	* findvar.c (read_var_value): Handle LOC_TEMPLATE.
    	* dwarf2read.c (add_template_variable): New function.
    	(new_symbol): Moved template symbol handling to
    	add_template_variable().
    	* c-typeprint.c (c_type_print_varspec_prefix): Handle
    	TYPE_CODE_TEMPLATE.
    	(c_type_print_varspec_suffix): Ditto.
    	(c_type_print_base): Ditto.
    	* gdbtypes.h: Ditto.
    
    2010-07-16  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.cp/templates.exp: Added the case of "type = Template Symbol"
    	as an acceptable result for ptype of template symbols.
    	* gdb.cp/temp-op.exp: Added test for a function with
    	templated paramters.
    	* gdb.cp/temp-op.cc: Ditto.
    	* gdb.cp/temp-op.exp: Added overload testing.
    	* gdb.cp/temp-op.cc: Ditto.

commit 83aca1085035c1c3da63d44891e44dfea9ea2265
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Jun 10 11:55:02 2010 -0400

    Create search_name and fixed template lookup
    
    2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* valops.c (find_overload_match): Use SYMBOL_SEARCH_NAME instead of
    	SYMBOL_NATURAL_NAME.
    	* symtab.h: Added new member search_name to cplus_specific.
    	(symbol_set_cplus_search_name): New function prototype.
    	(symbol_get_cplus_search_name): New function prototype.
    	* symtab.c (symbol_set_cplus_search_name): New function.
    	(symbol_get_cplus_search_name): New function.
    	(symbol_search_name): Handle the C++ case.
    	(symbol_matches_template_name): New function.
    	* dwarf2read.c (new_symbol): Set search_name of C++ template symbols.
    	* cp-support.H (cp_name_has_template_parameters): New function
    	prototype.
    	(cp_remove_template_params): New function ptototype.
    	* cp-support.c (cp_name_has_template_parameters): New function.
    	(cp_remove_template_params_component): New function.
    	(cp_remove_template_params): New function.
    	(overload_list_add_symbol): Use SYMBOL_SEARCH_NAME instead of
    	SYMBOL_NATURAL_NAME.
    	* cp-name-parser.y (cp_demangled_name_to_comp): Added more detail to
    	comment.
    
    2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.cp/temp-op.exp: New test.
    	* gdb.cp/temp-op.cc: New test.
    	* gdb.cp/cp-relocate.exp: Set the language C++.

commit e86c896f9856a8af198c85b0798032241ef8a5a5
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Jun 17 12:10:38 2010 -0400

    Complete symbol construction before adding to pending list.
    
    2010-08-05  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* dwarf2read.c (new_symbol): Add symbol to variable list at end of
    	function after symbol construction is complete.

commit 2c5567253350010207722f073ebf1d3500c75ad7
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Tue Jun 22 12:19:08 2010 -0400

    Corrected pre-overload-resolution function evaluation.
    
    2010-07-20  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* eval.c (evaluate_subexp_standard): Disabled evaluation of C++
    	function symbols before overload resolution.
    
    2010-07-20  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* gdb.cp/fpointer.cc: New test.
    	* gdb.cp/fpointer.exp: New test.

commit 5a078cb53dc4808d6f36986fb990b461f81aa2aa
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Mon Jul 12 11:16:49 2010 -0400

    Use allocated cplus_specific for cplus symbols.
    
    2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* symtab.h (symbol_set_demangled_name): Now takes an optional objfile*
    	argument.
    	(cplus_specific): New struct.
    	* symtab.c (symbol_set_demangled_name): Updated.
    	Use cplus_specific for cplus symbols.
    	(symbol_get_demangled_name): Retrive the name from the cplus_specific
    	struct for cplus symbols.
    	(symbol_init_language_specific): Set cplus_specific for cplus symbols.
    	(symbol_set_names): Pass objfile to symbol_set_demangled_name.
    	* symtab.c (symbol_init_cplus_specific): New function.

commit 55c93c81de2bf85de1f6990961fea2755b565ea3
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Thu Jul 8 16:36:19 2010 -0400

    Use setter and getter for demangled_name.
    
    2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* symtab.h (symbol_set_demangled_name): New function.
    	(symbol_get_demangled_name): New function.
    	* symtab.c (symbol_set_demangled_name): New function.
    	(symbol_get_demangled_name): New function.
    	(symbol_init_language_specific): Use demangled_name setter and getter.
    	(symbol_set_names): Ditto.
    	(symbol_natural_name): Ditto.
    	(symbol_demangled_name): Ditto.
    	* dwarf2read.c (new_symbol): Ditto.

commit b2e4bddfc79c51eccf59e0cdc628fe47421562fc
Author: Sami Wagiaalla <swagiaal@redhat.com>
Date:   Wed Jul 7 13:45:46 2010 -0400

    Rename cplus_specific mangled_lang.
    
    2010-07-15  Sami Wagiaalla  <swagiaal@redhat.com>
    
    	* symtab.h: Renamed cplus_specific to mangled_lang.
    	* symtab.c (symbol_init_language_specific): Updated.
    	(symbol_set_names): Updated.
    	(symbol_natural_name): Updated.
    	(symbol_demangled_name): Updated.
    	* ada-lang.c (ada_decode_symbol): Updated.
    	* dwarf2read.c (new_symbol): Updated.

-----------------------------------------------------------------------

Summary of changes:
 gdb/ada-lang.c                       |    2 +-
 gdb/c-typeprint.c                    |    6 ++
 gdb/cp-name-parser.y                 |    9 ++-
 gdb/cp-support.c                     |   68 ++++++++++++++-
 gdb/cp-support.h                     |    4 +
 gdb/dwarf2read.c                     |  131 +++++++++++++++++++++------
 gdb/eval.c                           |   65 ++++++++++++--
 gdb/findvar.c                        |   14 +++
 gdb/gdbtypes.c                       |   39 +++++++--
 gdb/gdbtypes.h                       |   29 ++++---
 gdb/symtab.c                         |  156 +++++++++++++++++++++++++++++---
 gdb/symtab.h                         |   59 ++++++++++++-
 gdb/testsuite/gdb.cp/cp-relocate.exp |    4 +
 gdb/testsuite/gdb.cp/fpointer.cc     |   40 ++++++++
 gdb/testsuite/gdb.cp/fpointer.exp    |   40 ++++++++
 gdb/testsuite/gdb.cp/overload.cc     |   25 +++++
 gdb/testsuite/gdb.cp/overload.exp    |   15 +++
 gdb/testsuite/gdb.cp/smartp.cc       |  163 ++++++++++++++++++++++++++++++++++
 gdb/testsuite/gdb.cp/smartp.exp      |   77 ++++++++++++++++
 gdb/testsuite/gdb.cp/temp-op.cc      |  129 +++++++++++++++++++++++++++
 gdb/testsuite/gdb.cp/temp-op.exp     |   67 ++++++++++++++
 gdb/testsuite/gdb.cp/templates.exp   |   15 +++
 gdb/valarith.c                       |    3 +
 gdb/valops.c                         |    7 +-
 24 files changed, 1089 insertions(+), 78 deletions(-)
 create mode 100644 gdb/testsuite/gdb.cp/fpointer.cc
 create mode 100644 gdb/testsuite/gdb.cp/fpointer.exp
 create mode 100644 gdb/testsuite/gdb.cp/smartp.cc
 create mode 100644 gdb/testsuite/gdb.cp/smartp.exp
 create mode 100644 gdb/testsuite/gdb.cp/temp-op.cc
 create mode 100644 gdb/testsuite/gdb.cp/temp-op.exp

First 500 lines of diff:
diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c
index 1d4c38b..fabb272 100644
--- a/gdb/ada-lang.c
+++ b/gdb/ada-lang.c
@@ -1210,7 +1210,7 @@ char *
 ada_decode_symbol (const struct general_symbol_info *gsymbol)
 {
   char **resultp =
-    (char **) &gsymbol->language_specific.cplus_specific.demangled_name;
+    (char **) &gsymbol->language_specific.mangled_lang.demangled_name;
 
   if (*resultp == NULL)
     {
diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c
index d07fb8f..ad0bfcb 100644
--- a/gdb/c-typeprint.c
+++ b/gdb/c-typeprint.c
@@ -311,6 +311,7 @@ c_type_print_varspec_prefix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_COMPLEX:
     case TYPE_CODE_NAMESPACE:
     case TYPE_CODE_DECFLOAT:
+    case TYPE_CODE_TEMPLATE:
       /* These types need no prefix.  They are listed here so that
          gcc -Wall will reveal any types that haven't been handled.  */
       break;
@@ -644,6 +645,7 @@ c_type_print_varspec_suffix (struct type *type, struct ui_file *stream,
     case TYPE_CODE_COMPLEX:
     case TYPE_CODE_NAMESPACE:
     case TYPE_CODE_DECFLOAT:
+    case TYPE_CODE_TEMPLATE:
       /* These types do not need a suffix.  They are listed so that
          gcc -Wall will report types that may not have been considered.  */
       break;
@@ -1134,6 +1136,10 @@ c_type_print_base (struct type *type, struct ui_file *stream, int show,
       fputs_filtered (TYPE_TAG_NAME (type), stream);
       break;
 
+    case TYPE_CODE_TEMPLATE:
+      fputs_filtered ("Template Symbol", stream);
+      break;
+
     default:
       /* Handle types not explicitly handled by the other cases,
          such as fundamental types.  For these, just print whatever
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y
index 6d7b600..c9b5747 100644
--- a/gdb/cp-name-parser.y
+++ b/gdb/cp-name-parser.y
@@ -1966,9 +1966,12 @@ cp_comp_to_string (struct demangle_component *result, int estimated_len)
 			       &err);
 }
 
-/* Convert a demangled name to a demangle_component tree.  On success,
-   the root of the new tree is returned; it is valid until the next
-   call to this function and should not be freed.  On error, NULL is
+/* Convert a demangled name to a demangle_component tree.  The structure
+   of the tree depends on the format of each node in the tree.  For
+   information on the structure of a node see the comment corresponding
+   to its type in demangle_component_type.
+   On success, the root of the new tree is returned; it is valid until the
+   next call to this function and should not be freed.  On error, NULL is
    returned, and an error message will be set in *ERRMSG (which does
    not need to be freed).  */
 
diff --git a/gdb/cp-support.c b/gdb/cp-support.c
index 41af7ae..4ef1a0a 100644
--- a/gdb/cp-support.c
+++ b/gdb/cp-support.c
@@ -428,6 +428,72 @@ cp_remove_params (const char *demangled_name)
   return ret;
 }
 
+/* Returns 1 if the given name contains template parameters;
+   otherwise return 0.
+   Used as a quick heuristic to avoid more expensive template
+   parsing when not necessary.  */
+
+int
+cp_name_has_template_parameters (const char *name)
+{
+  char *c = strchr (name, '<');
+  return c != NULL && strchr (c+1, '>') != NULL;
+}
+
+/* Remove template parameters components from the give tree.  */
+
+static struct demangle_component *
+cp_remove_template_params_component (struct demangle_component *comp)
+{
+
+  gdb_assert (comp != NULL);
+
+  switch (comp->type)
+    {
+    case DEMANGLE_COMPONENT_TEMPLATE:
+      /* If there is a template component remove this node by re-parenting the
+         the left child.  */
+      comp = d_left (comp);
+      break;
+    case DEMANGLE_COMPONENT_QUAL_NAME:
+      /* For a qualified name remove template components from the right
+         subtree.  */
+      d_right (comp) = cp_remove_template_params_component (d_right (comp));
+      break;
+    case DEMANGLE_COMPONENT_TYPED_NAME:
+      /* Template components, if present, will be in the left subtree.  Remove
+         them.  */
+      d_left (comp) = cp_remove_template_params_component (d_left (comp));
+      break;
+    default:
+      break;
+    }
+
+  return comp;
+}
+
+/* Remove template parameters from the given name.  The returned string is
+   malloc'ed and must be properly saved and freed.  */
+
+char *
+cp_remove_template_params (const char *name)
+{
+  struct demangle_component *ret_comp;
+  char *ret = NULL;
+
+  if (name == NULL)
+    return NULL;
+
+  ret_comp = cp_demangled_name_to_comp (name, NULL);
+  if (ret_comp == NULL)
+    return NULL;
+
+  ret_comp = cp_remove_template_params_component (ret_comp);
+  ret = cp_comp_to_string (ret_comp, 10);
+
+  return ret;
+}
+
 /* Here are some random pieces of trivia to keep in mind while trying
    to take apart demangled names:
 
@@ -661,7 +727,7 @@ overload_list_add_symbol (struct symbol *sym, const char *oload_name)
       return;
 
   /* Get the demangled name without parameters */
-  sym_name = cp_remove_params (SYMBOL_NATURAL_NAME (sym));
+  sym_name = cp_remove_params (SYMBOL_SEARCH_NAME (sym));
   if (!sym_name)
     return;
 
diff --git a/gdb/cp-support.h b/gdb/cp-support.h
index ddc4c93..a2c8f7f 100644
--- a/gdb/cp-support.h
+++ b/gdb/cp-support.h
@@ -107,6 +107,10 @@ extern char *cp_func_name (const char *full_name);
 
 extern char *cp_remove_params (const char *demangled_name);
 
+extern int cp_name_has_template_parameters (const char *name);
+
+extern char *cp_remove_template_params (const char *name);
+
 extern struct symbol **make_symbol_overload_list (const char *,
 						  const char *);
 
diff --git a/gdb/dwarf2read.c b/gdb/dwarf2read.c
index bab1fba..c969f13 100644
--- a/gdb/dwarf2read.c
+++ b/gdb/dwarf2read.c
@@ -8636,6 +8636,82 @@ var_decode_location (struct attribute *attr, struct symbol *sym,
   SYMBOL_CLASS (sym) = LOC_COMPUTED;
 }
 
+static void
+add_template_variable (struct symbol *symbol, struct pending **listhead,
+                       struct objfile *objfile)
+{
+  const struct pending *iterator = *listhead;
+  struct symbol *template_sym = NULL;
+  struct symbol *iterator_sym;
+  struct type *type;
+  char *name = SYMBOL_NATURAL_NAME (symbol);
+  char *search_name;
+  char *tmp;
+  int i;
+
+  struct cleanup *all_cleanups = make_cleanup (null_cleanup, NULL);
+
+  gdb_assert (name != NULL);
+
+  /* Remove template parameters from the symbol's name
+       and set its search name.  */
+  tmp = cp_remove_template_params (name);
+
+  gdb_assert (tmp != NULL);
+  make_cleanup(xfree, tmp);
+
+  if (strcmp (tmp, name) == 0)
+    return;
+
+  search_name = obsavestring (tmp, strlen (tmp),
+                              &objfile->objfile_obstack);
+
+  symbol_set_cplus_search_name (&symbol->ginfo,
+                                objfile,
+                                search_name);
+
+  /* Has a template symbol for this symbol been added already ?  */
+  for (iterator = *(listhead);
+       iterator != NULL && template_sym == NULL;
+       iterator = iterator->next)
+    {
+      for (i = iterator->nsyms - 1; i >= 0; --i)
+        {
+	  iterator_sym = iterator->symbol[i];
+
+	  if (TYPE_CODE (SYMBOL_TYPE (iterator_sym)) == TYPE_CODE_TEMPLATE
+	      && strcmp (SYMBOL_SEARCH_NAME(iterator_sym), search_name) == 0)
+	    {
+	      template_sym = iterator_sym;
+	      break;
+	    }
+        }
+    }
+
+  if (template_sym == NULL)
+    {
+      /* Add a new template symbol.  */
+      template_sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
+					     sizeof (struct symbol));
+      OBJSTAT (objfile, n_syms++);
+      memset (template_sym, 0, sizeof (struct symbol));
+
+      SYMBOL_SET_NAMES (template_sym, search_name, strlen (search_name), 0, objfile);
+      type = alloc_type (objfile);
+      TYPE_CODE (type) = TYPE_CODE_TEMPLATE;
+      SYMBOL_TYPE (template_sym) = type;
+
+      SYMBOL_DOMAIN (template_sym) = VAR_DOMAIN;
+      SYMBOL_CLASS (template_sym) = LOC_TEMPLATE;
+
+      add_symbol_to_list (template_sym, listhead);
+    }
+
+  symbol_add_template_instance (template_sym, symbol, objfile);
+  do_cleanups (all_cleanups);
+
+}
+
 /* Given a pointer to a DWARF information entry, figure out if we need
    to make a symbol table entry for it, and if so, create a new entry
    and return a pointer to it.
@@ -8651,6 +8727,8 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
   struct attribute *attr = NULL;
   struct attribute *attr2 = NULL;
   CORE_ADDR baseaddr;
+  struct pending **list_to_add = NULL;
+
   int inlined_func = (die->tag == DW_TAG_inlined_subroutine);
 
   baseaddr = ANOFFSET (objfile->section_offsets, SECT_OFF_TEXT (objfile));
@@ -8659,6 +8737,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
   if (name)
     {
       const char *linkagename;
+      const char *search_name = NULL;
 
       sym = (struct symbol *) obstack_alloc (&objfile->objfile_obstack,
 					     sizeof (struct symbol));
@@ -8673,9 +8752,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
       /* Fortran does not have mangling standard and the mangling does differ
 	 between gfortran, iFort etc.  */
       if (cu->language == language_fortran
-          && sym->ginfo.language_specific.cplus_specific.demangled_name == NULL)
-	sym->ginfo.language_specific.cplus_specific.demangled_name
-	  = (char *) dwarf2_full_name (name, die, cu);
+          && symbol_get_demangled_name (&(sym->ginfo)) == NULL)
+	symbol_set_demangled_name (&(sym->ginfo),
+				   (char *) dwarf2_full_name (name, die, cu),
+	                           NULL);
 
       /* Default assumptions.
          Use the passed type or decode it from the die.  */
@@ -8737,11 +8817,11 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
                  access them globally.  For instance, we want to be able
                  to break on a nested subprogram without having to
                  specify the context.  */
-	      add_symbol_to_list (sym, &global_symbols);
+	      list_to_add = &global_symbols;
 	    }
 	  else
 	    {
-	      add_symbol_to_list (sym, cu->list_in_scope);
+	      list_to_add = cu->list_in_scope;
 	    }
 	  break;
 	case DW_TAG_inlined_subroutine:
@@ -8766,9 +8846,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	      dwarf2_const_value (attr, sym, cu);
 	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
 	      if (attr2 && (DW_UNSND (attr2) != 0))
-		add_symbol_to_list (sym, &global_symbols);
+		list_to_add = &global_symbols;
 	      else
-		add_symbol_to_list (sym, cu->list_in_scope);
+		list_to_add = cu->list_in_scope;
 	      break;
 	    }
 	  attr = dwarf2_attr (die, DW_AT_location, cu);
@@ -8778,8 +8858,6 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	      attr2 = dwarf2_attr (die, DW_AT_external, cu);
 	      if (attr2 && (DW_UNSND (attr2) != 0))
 		{
-		  struct pending **list_to_add;
-
 		  /* Workaround gfortran PR debug/40040 - it uses
 		     DW_AT_location for variables in -fPIC libraries which may
 		     get overriden by other libraries/executable and get
@@ -8798,10 +8876,9 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 		     but it may be block-scoped.  */
 		  list_to_add = (cu->list_in_scope == &file_symbols
 				 ? &global_symbols : cu->list_in_scope);
-		  add_symbol_to_list (sym, list_to_add);
 		}
 	      else
-		add_symbol_to_list (sym, cu->list_in_scope);
+		list_to_add = cu->list_in_scope;
 	    }
 	  else
 	    {
@@ -8815,21 +8892,18 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	      if (attr2 && (DW_UNSND (attr2) != 0)
 		  && dwarf2_attr (die, DW_AT_type, cu) != NULL)
 		{
-		  struct pending **list_to_add;
-
 		  /* A variable with DW_AT_external is never static, but it
 		     may be block-scoped.  */
 		  list_to_add = (cu->list_in_scope == &file_symbols
 				 ? &global_symbols : cu->list_in_scope);
 
 		  SYMBOL_CLASS (sym) = LOC_UNRESOLVED;
-		  add_symbol_to_list (sym, list_to_add);
 		}
 	      else if (!die_is_declaration (die, cu))
 		{
 		  /* Use the default LOC_OPTIMIZED_OUT class.  */
 		  gdb_assert (SYMBOL_CLASS (sym) == LOC_OPTIMIZED_OUT);
-		  add_symbol_to_list (sym, cu->list_in_scope);
+		  list_to_add = cu->list_in_scope;
 		}
 	    }
 	  break;
@@ -8861,7 +8935,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	      SYMBOL_TYPE (sym) = ref_type;
 	    }
 
-	  add_symbol_to_list (sym, cu->list_in_scope);
+	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_unspecified_parameters:
 	  /* From varargs functions; gdb doesn't seem to have any
@@ -8886,14 +8960,10 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	       saves you.  See the OtherFileClass tests in
 	       gdb.c++/namespace.exp.  */
 
-	    struct pending **list_to_add;
-
 	    list_to_add = (cu->list_in_scope == &file_symbols
 			   && (cu->language == language_cplus
 			       || cu->language == language_java)
 			   ? &global_symbols : cu->list_in_scope);
-	  
-	    add_symbol_to_list (sym, list_to_add);
 
 	    /* The semantics of C++ state that "struct foo { ... }" also
 	       defines a typedef for "foo".  A Java class declaration also
@@ -8913,7 +8983,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	case DW_TAG_typedef:
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	  add_symbol_to_list (sym, cu->list_in_scope);
+	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_base_type:
         case DW_TAG_subrange_type:
@@ -8921,7 +8991,7 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
         case DW_TAG_volatile_type:
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
 	  SYMBOL_DOMAIN (sym) = VAR_DOMAIN;
-	  add_symbol_to_list (sym, cu->list_in_scope);
+	  list_to_add = cu->list_in_scope;
 	  break;
 	case DW_TAG_enumerator:
 	  attr = dwarf2_attr (die, DW_AT_const_value, cu);
@@ -8933,19 +9003,15 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	    /* NOTE: carlton/2003-11-10: See comment above in the
 	       DW_TAG_class_type, etc. block.  */
 
-	    struct pending **list_to_add;
-
 	    list_to_add = (cu->list_in_scope == &file_symbols
 			   && (cu->language == language_cplus
 			       || cu->language == language_java)
 			   ? &global_symbols : cu->list_in_scope);
-	  
-	    add_symbol_to_list (sym, list_to_add);
 	  }
 	  break;
 	case DW_TAG_namespace:
 	  SYMBOL_CLASS (sym) = LOC_TYPEDEF;
-	  add_symbol_to_list (sym, &global_symbols);
+	  list_to_add = &global_symbols;
 	  break;
 	default:
 	  /* Not a tag we recognize.  Hopefully we aren't processing
@@ -8957,6 +9023,17 @@ new_symbol (struct die_info *die, struct type *type, struct dwarf2_cu *cu)
 	  break;
 	}
 
+      if (list_to_add != NULL)
+	{
+	  /* For C++ if the name contains template parameters remove them, and set
+             the cleaned up name to be the search name.  */
+	  if (cu->language == language_cplus && sym->ginfo.name
+	      && cp_name_has_template_parameters (sym->ginfo.name))
+	    add_template_variable (sym, list_to_add, objfile);
+
+	  add_symbol_to_list (sym, list_to_add);
+	}
+
       /* For the benefit of old versions of GCC, check for anonymous
 	 namespaces based on the demangled name.  */
       if (!processing_has_namespace_info
diff --git a/gdb/eval.c b/gdb/eval.c
index 9a60616..9786c1e 100644
--- a/gdb/eval.c
+++ b/gdb/eval.c
@@ -1431,6 +1431,24 @@ evaluate_subexp_standard (struct type *expect_type,
 	  else
 	    {
 	      arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
+
+	      /* Check to see if the operator '->' has been overloaded.  If the operator
+	         has been overloaded replace arg2 with the value returned by the custom
+	         operator and continue evaluation.  */
+	      while (unop_user_defined_p (op, arg2))
+		{
+		  volatile struct gdb_exception except;
+		  struct value *value = NULL;
+		  TRY_CATCH (except, RETURN_MASK_ERROR)
+		    {
+		      value = value_x_unop (arg2, op, noside);
+		    }
+
+		  if (except.reason < 0)
+		    break;
+
+		  arg2 = value;
+		}
 	    }
 	  /* Now, say which argument to start evaluating from */
 	  tem = 2;
@@ -1491,19 +1509,29 @@ evaluate_subexp_standard (struct type *expect_type,
 	{
 	  /* Non-method function call */
 	  save_pos1 = *pos;
-	  argvec[0] = evaluate_subexp_with_coercion (exp, pos, noside);
 	  tem = 1;
-	  type = value_type (argvec[0]);
-	  if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
-	    type = TYPE_TARGET_TYPE (type);
-	  if (type && TYPE_CODE (type) == TYPE_CODE_FUNC)
+
+	  /* If this is a C++ function wait until overload resolution.  */
+	  if (op == OP_VAR_VALUE
+	      && overload_resolution
+	      && (exp->language_defn->la_language == language_cplus))
 	    {
-	      for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+	      (*pos) += 4; /* Skip the evaluation of the symbol.  */
+	      argvec[0] = NULL;
+	    }
+	  else
+	    {
+	      argvec[0] = evaluate_subexp_with_coercion (exp, pos, noside);
+	      type = value_type (argvec[0]);
+	      if (type && TYPE_CODE (type) == TYPE_CODE_PTR)
+		type = TYPE_TARGET_TYPE (type);
+	      if (type && TYPE_CODE (type) == TYPE_CODE_FUNC)
 		{
-		  /* pai: FIXME This seems to be coercing arguments before
-		   * overload resolution has been done! */
-		  argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1),
-						 exp, pos, noside);
+		  for (; tem <= nargs && tem <= TYPE_NFIELDS (type); tem++)
+		    {
+		      argvec[tem] = evaluate_subexp (TYPE_FIELD_TYPE (type, tem - 1),
+						     exp, pos, noside);
+		    }


hooks/post-receive
--
Repository for Project Archer.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2010-08-23 17:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-23 17:20 [SCM] archer-swagiaal-upstream: Fix overload resolution between children of common ancestor swagiaal

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).