From 94b2749b7d6472d3abc252dbb4be1aaaf2844e19 Mon Sep 17 00:00:00 2001 From: parsons Date: Wed, 10 Nov 2004 16:01:52 +0000 Subject: ChangeLogTag: Wed Nov 10 09:46:46 2004 Jeff Parsons --- TAO/ChangeLog | 15 +++++++++++++++ TAO/TAO_IDL/ast/ast_union.cpp | 2 +- TAO/TAO_IDL/be/be_union_branch.cpp | 2 +- TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp | 12 ++++++++++-- 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 24ddb9ea147..00302bdff03 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,18 @@ +Wed Nov 10 09:46:46 2004 Jeff Parsons + + * TAO_IDL/ast/ast_union.cpp: + * TAO_IDLbe/be_union_branch.cpp: + * TAO_IDLbe/be_visitor_union/union_cs.cpp: + + Changed code generation for a union default constructor to + set the discriminator to a legal defaul value if there is + one, and to the value of the first case label otherwise + (previously the behavior in all cases). This new behavior + is not required by the spec, but is more in line with the + behavior of IDL compilers from other ORB vendors. Thanks + to Rohan Mars for sending in the + example IDL file. + Tue Nov 9 15:35:12 UTC 2004 Johnny Willemsen * tao/GIOP_Utils.h: diff --git a/TAO/TAO_IDL/ast/ast_union.cpp b/TAO/TAO_IDL/ast/ast_union.cpp index 9587fe295b9..f8cd8ccb7b4 100644 --- a/TAO/TAO_IDL/ast/ast_union.cpp +++ b/TAO/TAO_IDL/ast/ast_union.cpp @@ -646,7 +646,7 @@ AST_Union::compute_default_value (void) ACE_NOTREACHED (break;) } // End of switch - // If we have determined that we don't need a default case and even then a + // If we have determined that we don't have a default case and even then a // default case was provided, flag this off as error. if ((this->default_value_.computed_ == 0) && (this->default_index () != -1)) diff --git a/TAO/TAO_IDL/be/be_union_branch.cpp b/TAO/TAO_IDL/be/be_union_branch.cpp index 006ce84d787..4c67346e028 100644 --- a/TAO/TAO_IDL/be/be_union_branch.cpp +++ b/TAO/TAO_IDL/be/be_union_branch.cpp @@ -152,7 +152,7 @@ be_union_branch::gen_default_label_value (TAO_OutStream *os, os->print ("%d", dv.u.char_val); break; case AST_Expression::EV_bool: - *os << dv.u.bool_val; + *os << (dv.u.bool_val == 0 ? "false" : "true"); break; case AST_Expression::EV_enum: // The discriminant is an enum. Some compilers will diff --git a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp index f9801d2d421..c7257392ecc 100644 --- a/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp +++ b/TAO/TAO_IDL/be/be_visitor_union/union_cs.cpp @@ -118,8 +118,16 @@ int be_visitor_union_cs::visit_union (be_union *node) // Get the first label in its list. AST_UnionLabel *ul = ub->label (0); - - if (ul->label_kind () == AST_UnionLabel::UL_label) + AST_Union::DefaultValue dv; + + // This can indicate an error in the return value, but it is + // caught elsewhere. + (void) node->default_value (dv); + + bool test = dv.computed_ == 0 + && ul->label_kind () == AST_UnionLabel::UL_label; + + if (test) { ub->gen_label_value (os); } -- cgit v1.2.1