diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-21 01:53:51 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-21 01:53:51 +0000 |
commit | cc340945bfc8d98c93adb8c743a447ad39636cc7 (patch) | |
tree | da058b35083fc6517f288cd80bd0887f3593bc04 | |
parent | 45aea55bed457db582ac7d728a94e7cd8103aa0d (diff) | |
download | ATCD-cc340945bfc8d98c93adb8c743a447ad39636cc7.tar.gz |
Added default case to switch statements generating cases for
CDR operators. If discriminant is an enum, some compilers
complain if all the enum values are not used and there
is not a default case in the switch, which is the case
when we have an implicit default case.
-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"; |