From aee8b43f6ee4d0c5eab39b271da20d08d8791db2 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 11 Dec 2024 09:00:02 -0600 Subject: [PATCH 1/2] Fixed warnings: reusing a name in nested scopes Updated style per guidelines --- TAO/tao/Bounded_Array_Sequence_T.h | 43 ++++++++++++++++------------ TAO/tao/Unbounded_Array_Sequence_T.h | 43 ++++++++++++++++------------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/TAO/tao/Bounded_Array_Sequence_T.h b/TAO/tao/Bounded_Array_Sequence_T.h index dc2c6b22f2b4d..b34c4c4ef23bf 100644 --- a/TAO/tao/Bounded_Array_Sequence_T.h +++ b/TAO/tao/Bounded_Array_Sequence_T.h @@ -93,33 +93,38 @@ class bounded_array_sequence namespace TAO { template - bool demarshal_sequence(stream & strm, TAO::bounded_array_sequence & target) { + bool demarshal_sequence (stream &strm, TAO::bounded_array_sequence &target) { typedef typename TAO::bounded_array_sequence sequence; typedef TAO_Array_Forany_T forany; typedef TAO::Array_Traits array_traits; ::CORBA::ULong new_length = 0; - if (!(strm >> new_length)) { - return false; - } - if ((new_length > strm.length()) || (new_length > target.maximum ())) { - return false; - } - sequence tmp; - tmp.length(new_length); - typename sequence::value_type * buffer = tmp.get_buffer(); - for(CORBA::ULong i = 0; i < new_length; ++i) { - forany tmp (array_traits::alloc ()); - bool const _tao_marshal_flag = (strm >> tmp); - if (_tao_marshal_flag) { - array_traits::copy (buffer[i], tmp.in ()); + if (!(strm >> new_length)) + { + return false; } - array_traits::free (tmp.inout ()); - if (!_tao_marshal_flag) { + if ((new_length > strm.length ()) || (new_length > target.maximum ())) + { return false; } - } - tmp.swap(target); + sequence tmp; + tmp.length (new_length); + typename sequence::value_type *const buffer = tmp.get_buffer (); + for (CORBA::ULong i = 0; i < new_length; ++i) + { + forany wrapper (array_traits::alloc ()); + bool const _tao_marshal_flag = strm >> wrapper; + if (_tao_marshal_flag) + { + array_traits::copy (buffer[i], wrapper.in ()); + } + array_traits::free (wrapper.inout ()); + if (!_tao_marshal_flag) + { + return false; + } + } + tmp.swap (target); return true; } diff --git a/TAO/tao/Unbounded_Array_Sequence_T.h b/TAO/tao/Unbounded_Array_Sequence_T.h index 873376148af4b..9ed973a8f5bd3 100644 --- a/TAO/tao/Unbounded_Array_Sequence_T.h +++ b/TAO/tao/Unbounded_Array_Sequence_T.h @@ -95,33 +95,38 @@ class unbounded_array_sequence namespace TAO { template - bool demarshal_sequence(stream & strm, TAO::unbounded_array_sequence & target) { + bool demarshal_sequence (stream &strm, TAO::unbounded_array_sequence &target) { typedef TAO::unbounded_array_sequence sequence; typedef TAO_Array_Forany_T forany; typedef TAO::Array_Traits array_traits; ::CORBA::ULong new_length = 0; - if (!(strm >> new_length)) { - return false; - } - if (new_length > strm.length()) { - return false; - } - sequence tmp(new_length); - tmp.length(new_length); - typename sequence::value_type * buffer = tmp.get_buffer(); - for(CORBA::ULong i = 0; i < new_length; ++i) { - forany tmp (array_traits::alloc ()); - bool const _tao_marshal_flag = (strm >> tmp); - if (_tao_marshal_flag) { - array_traits::copy (buffer[i], tmp.in ()); + if (!(strm >> new_length)) + { + return false; } - array_traits::free (tmp.inout ()); - if (!_tao_marshal_flag) { + if (new_length > strm.length ()) + { return false; } - } - tmp.swap(target); + sequence tmp (new_length); + tmp.length (new_length); + typename sequence::value_type *const buffer = tmp.get_buffer (); + for (CORBA::ULong i = 0; i < new_length; ++i) + { + forany wrapper (array_traits::alloc ()); + bool const _tao_marshal_flag = strm >> wrapper; + if (_tao_marshal_flag) + { + array_traits::copy (buffer[i], wrapper.in ()); + } + array_traits::free (wrapper.inout ()); + if (!_tao_marshal_flag) + { + return false; + } + } + tmp.swap (target); return true; } From 70c1a78cc8d727e7a80bbc9e0e3f5da3193ae255 Mon Sep 17 00:00:00 2001 From: Adam Mitz Date: Wed, 11 Dec 2024 09:10:27 -0600 Subject: [PATCH 2/2] Fixed warnings in tao_idl generated code 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. --- TAO/TAO_IDL/be/be_interface.cpp | 2 +- .../be/be_visitor_interface/amh_ss.cpp | 2 +- .../be/be_visitor_interface/interface_ss.cpp | 26 ++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/TAO/TAO_IDL/be/be_interface.cpp b/TAO/TAO_IDL/be/be_interface.cpp index 2eebde2ba5c02..6f16d76577261 100644 --- a/TAO/TAO_IDL/be/be_interface.cpp +++ b/TAO/TAO_IDL/be/be_interface.cpp @@ -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; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp index 87642de80f33d..0db6a99e3bbd5 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/amh_ss.cpp @@ -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; } diff --git a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp index d87a9d64457e7..e8ac39c4fcdf8 100644 --- a/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp +++ b/TAO/TAO_IDL/be/be_visitor_interface/interface_ss.cpp @@ -107,13 +107,21 @@ 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; @@ -121,11 +129,15 @@ be_visitor_interface_ss::visit_interface (be_interface *node) *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) {