From 8fa28e0ce9c59d2cf42eee938f8bcc30ea8196dd Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 24 Apr 2016 22:47:51 +0200 Subject: [PATCH] Don't lose the correct sym:name when inheriting base class methods For some reason, the copy of the function made in the derived class used the "name" attribute instead of "sym:name", which means that any %renames attached to it were lost and didn't affect the derived class version. Fix this and also a problem uncovered by doing it in the operator_overload unit test as the assignment operator shouldn't be inherited at all, the compiler-generated operator is used instead if the derived class doesn't define its own one. --- Source/Modules/c.cxx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Source/Modules/c.cxx b/Source/Modules/c.cxx index 10cdd50fc..fe68c1489 100644 --- a/Source/Modules/c.cxx +++ b/Source/Modules/c.cxx @@ -1299,6 +1299,8 @@ ready: || (Cmp(Getattr(node, "kind"), "function") == 0)) { if ((Cmp(Getattr(node, "access"), "public") == 0) && (Cmp(Getattr(node, "storage"), "static") != 0)) { + // Assignment operators are not inherited in C++. + if (Cmp(Getattr(node, "name"), "operator =") != 0) { Node *new_node = copy_node(node); String *parent_name = Getattr(parentNode(node), "name"); Hash *dupl_name_node = is_in(Getattr(node, "name"), n); @@ -1306,14 +1308,14 @@ ready: // inheritance, change both names to avoid ambiguity if (dupl_name_node) { String *cif = Getattr(dupl_name_node, "c:inherited_from"); - String *old_name = Getattr(dupl_name_node, "name"); + String *old_name = Getattr(dupl_name_node, "sym:name"); if (cif && parent_name && (Cmp(cif, parent_name) != 0)) { - Setattr(dupl_name_node, "name", NewStringf("%s%s", cif ? cif : "", old_name)); + Setattr(dupl_name_node, "sym:name", NewStringf("%s%s", cif ? cif : "", old_name)); Setattr(dupl_name_node, "c:base_name", old_name); Setattr(new_node, "name", NewStringf("%s%s", parent_name, old_name)); Setattr(new_node, "c:base_name", old_name); Setattr(new_node, "c:inherited_from", parent_name); - Setattr(new_node, "sym:name", Getattr(new_node, "name")); + Setattr(new_node, "sym:name", Getattr(node, "sym:name")); Setattr(new_node, "sym:symtab", Getattr(n, "symtab")); set_nodeType(new_node, "cdecl"); appendChild(n, new_node); @@ -1321,11 +1323,12 @@ ready: } else { Setattr(new_node, "c:inherited_from", parent_name); - Setattr(new_node, "sym:name", Getattr(new_node, "name")); + Setattr(new_node, "sym:name", Getattr(node, "sym:name")); Setattr(new_node, "sym:symtab", Getattr(n, "symtab")); set_nodeType(new_node, "cdecl"); appendChild(n, new_node); } + } } } }