Skip to content

Commit

Permalink
Fixed warnings in tao_idl generated code
Browse files Browse the repository at this point in the history
Classes that have a pure virtual member cannot be constructed as the
most-derived type of an object.  Their constructors are always called
indirectly from derived constructors.  Initializing virtual bases in
these constructors is effectively dead code since virtual bases can only
be initialized by the most-derived type.  Some compilers, with some
warning settings, generated warnings for this.
  • Loading branch information
mitza-oci committed Dec 11, 2024
1 parent aee8b43 commit 70c1a78
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion TAO/TAO_IDL/be/be_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2234,7 +2234,7 @@ be_interface::copy_ctor_helper (be_interface *derived,
{
// We can't call ourselves in a copy constructor, and
// abstract interfaces don't exist on the skeleton side.
if (derived == base || base->is_abstract ())
if (derived == base || base->is_abstract () || derived->nmembers () > 0)
{
return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ TAO_IDL_Copy_Ctor_Worker::emit (be_interface *derived,
TAO_OutStream *os,
be_interface *base)
{
if (derived == base)
if (derived == base || derived->nmembers () > 0)
{
return 0;
}
Expand Down
26 changes: 19 additions & 7 deletions TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,37 @@ be_visitor_interface_ss::visit_interface (be_interface *node)

*os << full_skel_name << "::"
<< local_name_prefix << node_local_name
<< " ()" << be_idt_nl;
<< " ()";

*os << ": TAO_ServantBase ()" << be_uidt_nl;
bool const init_bases = node->nmembers () == 0;
if (init_bases)
{
*os << be_idt_nl << ": TAO_ServantBase ()" << be_uidt_nl;
}
else
{
*os << be_nl;
}

// Default constructor body.
*os << "{" << be_idt_nl
<< "this->optable_ = std::addressof(tao_" << flat_name
<< "this->optable_ = std::addressof (tao_" << flat_name
<< "_optable);" << be_uidt_nl
<< "}" << be_nl_2;

// find if we are at the top scope or inside some module
*os << full_skel_name << "::"
<< local_name_prefix << node_local_name << " ("
<< "const " << local_name_prefix
<< node_local_name << "& rhs)";
<< node_local_name << " &"
<< (init_bases ? "rhs" : "") << ")";

*os << be_idt_nl
<< ": TAO_Abstract_ServantBase (rhs)," << be_nl
<< " TAO_ServantBase (rhs)";
if (init_bases)
{
*os << be_idt_nl
<< ": TAO_Abstract_ServantBase (rhs)," << be_nl
<< " TAO_ServantBase (rhs)";
}

if (this->generate_copy_ctor (node, os) == -1)
{
Expand Down

0 comments on commit 70c1a78

Please sign in to comment.