summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_union.cpp
diff options
context:
space:
mode:
authorvzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-02-08 11:17:40 +0000
committervzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2010-02-08 11:17:40 +0000
commit5c35cd8f650949db1f910e39f719398df2fee63b (patch)
treef5f0a1746502c00ba5c72c9c88db9b2b5543eb97 /TAO/TAO_IDL/be/be_union.cpp
parentc90311d918d197e886b5d11097774c43ca680c33 (diff)
downloadATCD-5c35cd8f650949db1f910e39f719398df2fee63b.tar.gz
Mon Feb 8 10:58:21 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com>
* tests/Bug_3821_Regression/test.cpp: * tests/Bug_3821_Regression/test.idl: * tests/Bug_3821_Regression/Bug_3821_Regression.mpc: * tests/Bug_3821_Regression/run_test.pl: * tests/Bug_3821_Regression/README: * tests/IDL_Test/Bug_3821_Regression.idl: * bin/tao_orb_tests.lst: Added a test for bug#3821 and scheduled it for run. Added the same IDL file to IDL_Test, it can be useful for testing tao_idl's behavior on unions. * TAO_IDL/be/be_union.cpp: * TAO_IDL/be/be_visitor_union/discriminant_ci.cpp: * TAO_IDL/be/be_visitor_union/cdr_op_cs.cpp: * TAO_IDL/be/be_visitor_union/serializer_op_cs.cpp: * TAO_IDL/be/be_visitor_union/union_cs.cpp: * TAO_IDL/ast/ast_union.cpp: * TAO_IDL/be_include/be_union.h: Fixed a bug#3821. In particular it changes how tao_idl generates code for enum discriminated unions. Fixed other minor bugs.
Diffstat (limited to 'TAO/TAO_IDL/be/be_union.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_union.cpp61
1 files changed, 37 insertions, 24 deletions
diff --git a/TAO/TAO_IDL/be/be_union.cpp b/TAO/TAO_IDL/be/be_union.cpp
index 92831e7302c..bf8d1b0a1fd 100644
--- a/TAO/TAO_IDL/be/be_union.cpp
+++ b/TAO/TAO_IDL/be/be_union.cpp
@@ -222,49 +222,62 @@ be_union::gen_empty_default_label (void)
}
AST_ConcreteType *disc = this->disc_type ();
+ if (disc == 0)
+ {
+ return true; // In reality this is an error.
+ }
+
AST_Decl::NodeType nt = disc->node_type ();
- unsigned long n_labels = this->nlabels ();
+ ACE_UINT64 n_labels = this->nlabels ();
if (nt == AST_Decl::NT_enum)
{
- AST_Enum *e = AST_Enum::narrow_from_decl (disc);
-
- if (e == 0)
- {
- return true;
- }
-
- // If we have an enum and the number of labels if as big as the enum
- // has members we don't have to generate a default label
- if (n_labels == static_cast<unsigned long> (e->member_count ()))
- {
- return false;
- }
- else
- {
- return true;
- }
+ // Enums in CORBA are always 32bits in size, so unless
+ // there are that many enum labels in the set, it is
+ // incomplete (reguardless as to the actual member_count).
+ return (n_labels <= ACE_UINT32_MAX);
}
AST_PredefinedType *pdt = AST_PredefinedType::narrow_from_decl (disc);
-
if (pdt == 0)
{
- return true;
+ return true; // In reality this is an error.
}
- if (pdt->pt () == AST_PredefinedType::PT_boolean && n_labels == 2)
+ switch (pdt->pt ())
{
- return false;
+ case AST_PredefinedType::PT_boolean:
+ return (n_labels < 2);
+
+ case AST_PredefinedType::PT_char:
+ return (n_labels <= ACE_OCTET_MAX);
+
+ case AST_PredefinedType::PT_short:
+ case AST_PredefinedType::PT_ushort:
+ return (n_labels <= ACE_UINT16_MAX);
+
+ case AST_PredefinedType::PT_long:
+ case AST_PredefinedType::PT_ulong:
+ return (n_labels <= ACE_UINT32_MAX);
+
+ case AST_PredefinedType::PT_longlong:
+ case AST_PredefinedType::PT_ulonglong:
+ // We would wrap to 0 here - we are using a 64 bit count
+ // this case is so marginal as to always be incomplete.
+ return true;
+
+ // Keep fussy compilers happy.
+ default:
+ break;
}
return true;
}
-unsigned long
+ACE_UINT64
be_union::nlabels (void)
{
- unsigned long retval = 0;
+ ACE_UINT64 retval = 0;
for (UTL_ScopeActiveIterator si (this, UTL_Scope::IK_decls);
!si.is_done ();