diff options
-rw-r--r-- | TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp index a8a2fbe44b7..017b0e00ac3 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/cdr_op_ci.cpp @@ -106,6 +106,21 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) "visit_union - " "codegen for scope failed\n"), -1); } + + // If there is no explicit default case, but there + // is an implicit one, and the discriminant is an enum, + // we need this to avert warnings in some compilers that + // not all case values are included. If there is no + // implicit default case, or the discriminator is not + // an enum, this does no harm. + if (node->default_index () == -1) + { + os->decr_indent (0); + *os << "default:" << be_nl; + os->incr_indent (); + *os << "break;"; + } + *os << be_uidt_nl << "}" << be_nl << "return result;" << be_uidt_nl << "}\n\n"; @@ -162,6 +177,20 @@ be_visitor_union_cdr_op_ci::visit_union (be_union *node) "codegen for scope failed\n"), -1); } + // If there is no explicit default case, but there + // is an implicit one, and the discriminant is an enum, + // we need this to avert warnings in some compilers that + // not all case values are included. If there is no + // implicit default case, or the discriminator is not + // an enum, this does no harm. + if (node->default_index () == -1) + { + os->decr_indent (0); + *os << "default:" << be_nl; + os->incr_indent (); + *os << "break;"; + } + *os << be_uidt_nl << "}" << be_nl << "return result;" << be_uidt_nl << "}\n\n"; |