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.
This commit is contained in:
parent
1912fd3a42
commit
8fa28e0ce9
1 changed files with 7 additions and 4 deletions
|
|
@ -1299,6 +1299,8 @@ ready:
|
||||||
|| (Cmp(Getattr(node, "kind"), "function") == 0)) {
|
|| (Cmp(Getattr(node, "kind"), "function") == 0)) {
|
||||||
if ((Cmp(Getattr(node, "access"), "public") == 0)
|
if ((Cmp(Getattr(node, "access"), "public") == 0)
|
||||||
&& (Cmp(Getattr(node, "storage"), "static") != 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);
|
Node *new_node = copy_node(node);
|
||||||
String *parent_name = Getattr(parentNode(node), "name");
|
String *parent_name = Getattr(parentNode(node), "name");
|
||||||
Hash *dupl_name_node = is_in(Getattr(node, "name"), n);
|
Hash *dupl_name_node = is_in(Getattr(node, "name"), n);
|
||||||
|
|
@ -1306,14 +1308,14 @@ ready:
|
||||||
// inheritance, change both names to avoid ambiguity
|
// inheritance, change both names to avoid ambiguity
|
||||||
if (dupl_name_node) {
|
if (dupl_name_node) {
|
||||||
String *cif = Getattr(dupl_name_node, "c:inherited_from");
|
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)) {
|
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(dupl_name_node, "c:base_name", old_name);
|
||||||
Setattr(new_node, "name", NewStringf("%s%s", parent_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:base_name", old_name);
|
||||||
Setattr(new_node, "c:inherited_from", parent_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"));
|
Setattr(new_node, "sym:symtab", Getattr(n, "symtab"));
|
||||||
set_nodeType(new_node, "cdecl");
|
set_nodeType(new_node, "cdecl");
|
||||||
appendChild(n, new_node);
|
appendChild(n, new_node);
|
||||||
|
|
@ -1321,11 +1323,12 @@ ready:
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Setattr(new_node, "c:inherited_from", parent_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"));
|
Setattr(new_node, "sym:symtab", Getattr(n, "symtab"));
|
||||||
set_nodeType(new_node, "cdecl");
|
set_nodeType(new_node, "cdecl");
|
||||||
appendChild(n, new_node);
|
appendChild(n, new_node);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue