]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Some precursor patch cleanups.
authorKeith Seitz <keiths@redhat.com>
Fri, 5 May 2017 21:21:23 +0000 (14:21 -0700)
committerKeith Seitz <keiths@redhat.com>
Fri, 5 May 2017 21:21:23 +0000 (14:21 -0700)
For dw2_linkage_name{,_attr} and conversion-operators [on c++compile-submit].

gdb/c-exp.y
gdb/dwarf2read.c
gdb/testsuite/gdb.cp/cpexprs.cc
gdb/testsuite/gdb.cp/cpexprs.exp

index 0b5fc536bc59499803819484a68e4db96b9b8b05..a7509dabb7ca96a621957a65c8949c954217fe18 100644 (file)
@@ -1563,10 +1563,10 @@ oper:   OPERATOR NEW
                                        &type_print_raw_options);
 
                          /* This also needs canonicalization.  */
-                         const char *name = buf.c_str ();
-                         std::string canon = cp_canonicalize_string (name);
+                         std::string canon
+                           = cp_canonicalize_string (buf.c_str ());
                          if (canon.empty ())
-                           canon = name;
+                           canon = std::move (buf.string ());
 
                          /* We need a space between "operator" and the
                             canonicalized type name. */
index a9d794c8624c9a610df3799d35b14658bc2c7d5e..276ed0d6a53d7ac34ba6dd61734108a3470aecd6 100644 (file)
@@ -8606,6 +8606,22 @@ die_needs_namespace (struct die_info *die, struct dwarf2_cu *cu)
    or DW_AT_MIPS_linkage_name.  Returns NULL if the attribute is not
    defined for the given DIE.  */
 
+static struct attribute *
+dw2_linkage_name_attr (struct die_info *die, struct dwarf2_cu *cu)
+{
+  struct attribute *attr;
+
+  attr = dwarf2_attr (die, DW_AT_linkage_name, cu);
+  if (attr == NULL)
+    attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
+
+  return attr;
+}
+
+/* Return the DIE's linkage name as a string, either DW_AT_linkage_name
+   or DW_AT_MIPS_linkage_name.  Returns NULL if the attribute is not
+   defined for the given DIE.  */
+
 static const char *
 dw2_linkage_name (struct die_info *die, struct dwarf2_cu *cu)
 {
@@ -13607,8 +13623,8 @@ new_fn_field (struct die_info *name_die, struct dwarf2_cu *name_cu,
                {
                  complaint (&symfile_complaints,
                             _("cannot determine context for virtual member "
-                              "function \"%s\" (offset %d)"), fieldname,
-                            to_underlying (type_die->sect_off));
+                              "function \"%s\" (offset %d)"),
+                            fieldname, to_underlying (type_die->sect_off));
                }
              else
                {
@@ -13757,7 +13773,7 @@ dwarf2_attach_fn_fields_to_type (struct field_info *fip, struct type *type,
 /* Returns non-zero if NAME is the name of a vtable member in CU's
    language, zero otherwise.  */
 static int
-dw2_is_vtable_name (const char *name, struct dwarf2_cu *cu)
+is_vtable_name (const char *name, struct dwarf2_cu *cu)
 {
   static const char vptr[] = "_vptr";
   static const char vtable[] = "vtable";
@@ -14107,7 +14123,7 @@ process_structure_scope (struct die_info *die, struct dwarf2_cu *cu)
                    {
                      const char *fieldname = TYPE_FIELD_NAME (t, i);
 
-                      if (dw2_is_vtable_name (fieldname, cu))
+                      if (is_vtable_name (fieldname, cu))
                        {
                          set_type_vptr_fieldno (type, i);
                          break;
@@ -20527,10 +20543,7 @@ dwarf2_name (struct die_info *die, struct dwarf2_cu *cu)
        {
          char *demangled = NULL;
 
-         attr = dwarf2_attr (die, DW_AT_linkage_name, cu);
-         if (attr == NULL)
-           attr = dwarf2_attr (die, DW_AT_MIPS_linkage_name, cu);
-
+         attr = dw2_linkage_name_attr (die, cu);
          if (attr == NULL || DW_STRING (attr) == NULL)
            return NULL;
 
index f70fd51603c520a0d7b0cc9e2b347e3dd1dc48e5..a2364ebe91d134e82c1b01c8d5e62d36a9bc4ef2 100644 (file)
@@ -270,6 +270,7 @@ public:
   operator int () const { return 21; } // base::operator int
   operator fluff* () const { return new fluff (); } // base::operator fluff*
   operator fluff** () const { return &g_fluff; } // base::operator fluff**
+  operator fluff const* const* () const { return &g_fluff; } // base::operator fluff const* const*
 };
 
 class base1 : public virtual base
@@ -448,6 +449,7 @@ test_function (int argc, char* argv[]) // test_function
   char* str = a;
   fluff* flp = a;
   fluff** flpp = a;
+  fluff const* const* flcpcp = a;
 
   CV_f(CV::i);
 
index d0f41b2d8e3334c0fdadb53a7981a2c8cee8b330..463e89c12cdb6f1c01cf216bd3fa6da6c595c064 100644 (file)
@@ -407,6 +407,10 @@ add {base::operator int} \
     {int (const base * const)} \
     - \
     -
+add {base::operator fluff const* const*} \
+    {const fluff * const *(const base * const)} \
+    - \
+    -
 
 # Templates
 add {tclass<char>::do_something} \
@@ -746,5 +750,17 @@ gdb_test "p CV_f(CV::i)" " = 43"
 gdb_test "p CV_f('cpexprs.cc'::CV::t)" \
     { = {int \(int\)} 0x[0-9a-f]+ <CV_f\(int\)>}
 
+# Make sure conversion operator names are canonicalized and properly
+# "spelled."
+gdb_test "p base::operator const fluff * const *" \
+    [get "base::operator fluff const* const*" print] \
+    "canonicalized conversion operator name 1"
+gdb_test "p base::operator const fluff* const*" \
+    [get "base::operator fluff const* const*" print] \
+    "canonicalized conversion operator name 2"
+gdb_test "p base::operator derived*" \
+    "There is no field named operator derived\\*" \
+    "undefined conversion operator"
+
 gdb_exit
 return 0