diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-26 17:07:54 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2007-01-26 17:07:54 +0000 |
commit | 433448ec1466b415ff6d279ff92521f8e5928feb (patch) | |
tree | 061a4317021e2ea8ce39e8c976b66d26a8c20310 | |
parent | d06a6ae0929171f281f3744bf76d1ece082a0fa1 (diff) | |
download | ATCD-433448ec1466b415ff6d279ff92521f8e5928feb.tar.gz |
ChangeLogTag: Fri Jan 26 16:59:47 UTC 2007 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r-- | TAO/ChangeLog | 24 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_check.cpp | 33 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_enum.cpp | 21 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_structure_fwd.cpp | 3 | ||||
-rw-r--r-- | TAO/TAO_IDL/ast/ast_union_branch.cpp | 42 | ||||
-rw-r--r-- | TAO/tests/IDL_Test/IDL_Test.mpc | 2 |
6 files changed, 101 insertions, 24 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 1de847e8af5..efcfa740157 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,27 @@ +Fri Jan 26 16:59:47 UTC 2007 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/ast/ast_structure_fwd.cpp: + * TAO_IDL/ast/ast_check.cpp: + + Fixed incorrect error reporting of undefined struct when + it is forward declared multiple times. + + * TAO_IDL/ast/ast_enum.cpp: + * TAO_IDL/ast/ast_union_branch.cpp: + + Fixed incomplete initialization of AST_Expression class + that hold the value of a union case label when the + discriminator is an enum type, which was causing the + calculation of the union's default index to be + incorrect. Thanks to Martin Corino <mcorino@remedy.nl> + for reporting both the above IDL compiler bugs. + + * tests/IDL_Test/IDL_Test.mpc: + + Uncommented the struct.idl file in the IDL_Files list, + so it can now be included in the test. The bug it + covers is the first one described above. + Fri Jan 26 13:46:23 UTC 2007 Chad Elliott <elliott_c@ociweb.com> * *.{h,inl,cpp}: diff --git a/TAO/TAO_IDL/ast/ast_check.cpp b/TAO/TAO_IDL/ast/ast_check.cpp index a4c1afcc73d..7bb53bae46e 100644 --- a/TAO/TAO_IDL/ast/ast_check.cpp +++ b/TAO/TAO_IDL/ast/ast_check.cpp @@ -70,17 +70,17 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "global_extern.h" #include "utl_err.h" -ACE_RCSID (ast, - ast_check, +ACE_RCSID (ast, + ast_check, "$Id$") // Static storage for remembering nodes. -static AST_Type **ast_fwds = 0; -static long ast_n_fwds_used = 0; -static long ast_n_fwds_alloc = 0; +static AST_Type **ast_fwds = 0; +static long ast_n_fwds_used = 0; +static long ast_n_fwds_alloc = 0; -#undef INCREMENT -#define INCREMENT 64 +#undef INCREMENT +#define INCREMENT 64 // Store a node representing a forward declared struct or union. void @@ -132,13 +132,26 @@ AST_check_fwd_decls (void) if (!d->is_defined ()) { - idl_global->err ()->fwd_decl_not_defined (d); + // The member pd_full_definition is no longer set for + // every fwd decl, if there is more than one. So if + // is_defined() fails, we try to look up the fwd decl + // that has the full def, and emit an error only if + // this lookup fails. + AST_Decl *f = + d->defined_in ()->lookup_by_name_local (d->local_name (), + 0, + true); + + if (f == 0) + { + idl_global->err ()->fwd_decl_not_defined (d); + } } } - + // This method is called once per file in the command line, // in between which the elements of ast_fwds are destroyed, - // so we have to clean up. + // so we have to clean up. delete [] ast_fwds; ast_fwds = 0; ast_n_fwds_alloc = 0; diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp index 37837f7e5a0..b1b290cd6d5 100644 --- a/TAO/TAO_IDL/ast/ast_enum.cpp +++ b/TAO/TAO_IDL/ast/ast_enum.cpp @@ -156,11 +156,28 @@ AST_Enum::lookup_by_value (const AST_Expression *v) { d = i.item (); item = AST_EnumVal::narrow_from_decl (d); + AST_Expression *cv = item->constant_value (); - if (item->constant_value () == v) + if (cv == v) { return item; } + + // Enum union label expressions don't get evaluated upon + // creation, to evaluate them later, we have only the + // string name to look up the enum value with. + UTL_ScopedName *v_n = const_cast<AST_Expression *> (v)->n (); + + if (v_n != 0) + { + Identifier *cv_i = item->local_name (); + Identifier *v_i = v_n->last_component (); + + if (cv_i->compare (v_i)) + { + return item; + } + } } return 0; @@ -246,7 +263,7 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t) t1 = idl_global->gen ()->create_enum_val (ev->u.ulval, t->name ()); - + delete ev; ev = 0; diff --git a/TAO/TAO_IDL/ast/ast_structure_fwd.cpp b/TAO/TAO_IDL/ast/ast_structure_fwd.cpp index f6b87046559..d057a3e6ec7 100644 --- a/TAO/TAO_IDL/ast/ast_structure_fwd.cpp +++ b/TAO/TAO_IDL/ast/ast_structure_fwd.cpp @@ -69,6 +69,9 @@ AST_StructureFwd::set_full_definition (AST_Structure *nfd) delete this->pd_full_definition; this->pd_full_definition = 0; this->pd_full_definition = nfd; + + // In case it's not already set. + this->is_defined_ = true; } bool diff --git a/TAO/TAO_IDL/ast/ast_union_branch.cpp b/TAO/TAO_IDL/ast/ast_union_branch.cpp index 8fff20afb86..332cff62a18 100644 --- a/TAO/TAO_IDL/ast/ast_union_branch.cpp +++ b/TAO/TAO_IDL/ast/ast_union_branch.cpp @@ -72,6 +72,8 @@ trademarks or registered trademarks of Sun Microsystems, Inc. #include "ast_union_branch.h" #include "ast_union_label.h" #include "ast_union.h" +#include "ast_enum.h" +#include "ast_enum_val.h" #include "ast_visitor.h" #include "utl_labellist.h" @@ -80,21 +82,21 @@ ACE_RCSID(ast, ast_union_branch, "$Id$") AST_UnionBranch::AST_UnionBranch (void) : COMMON_Base (), AST_Decl (), - AST_Field (), - pd_ll (0) + AST_Field (), + pd_ll (0) { } AST_UnionBranch::AST_UnionBranch (UTL_LabelList *ll, AST_Type *ft, - UTL_ScopedName *n) + UTL_ScopedName *n) : COMMON_Base (), AST_Decl (AST_Decl::NT_union_branch, n), - AST_Field (AST_Decl::NT_union_branch, + AST_Field (AST_Decl::NT_union_branch, ft, n), - pd_ll (ll) + pd_ll (ll) { } @@ -133,7 +135,7 @@ AST_UnionBranch::destroy (void) this->pd_ll->destroy (); delete this->pd_ll; this->pd_ll = 0; - + this->AST_Field::destroy (); } @@ -144,8 +146,8 @@ AST_UnionBranch::label (unsigned long index) { unsigned long i = 0; - for (UTL_LabellistActiveIterator iter (this->pd_ll); - !iter.is_done (); + for (UTL_LabellistActiveIterator iter (this->pd_ll); + !iter.is_done (); iter.next ()) { if (i == index) @@ -178,19 +180,37 @@ AST_UnionBranch::add_labels (AST_Union *u) AST_UnionLabel *ul = 0; AST_Expression *ex = 0; + bool enum_labels = (u->udisc_type () == AST_Expression::EV_enum); + for (UTL_LabellistActiveIterator i (this->pd_ll); !i.is_done (); i.next ()) { ul = i.item (); - + if (ul->label_kind () == AST_UnionLabel::UL_default) { return; } - + ex = ul->label_val (); - u->add_to_name_referenced (ex->n ()->first_component ()); + UTL_ScopedName *n = ex->n (); + + if (n != 0) + { + u->add_to_name_referenced (ex->n ()->first_component ()); + } + + // If we have enum val labels, we need to set the type and + // evaluate here, so the value will be available when the + // default index in calculated. + if (enum_labels) + { + ex->ev ()->et = AST_Expression::EV_enum; + AST_Enum *disc = AST_Enum::narrow_from_decl (u->disc_type ()); + AST_EnumVal *dval = disc->lookup_by_value (ex); + ex->ev ()->u.eval = dval->constant_value ()->ev ()->u.ulval; + } } } diff --git a/TAO/tests/IDL_Test/IDL_Test.mpc b/TAO/tests/IDL_Test/IDL_Test.mpc index de047a61107..c9edfb66edc 100644 --- a/TAO/tests/IDL_Test/IDL_Test.mpc +++ b/TAO/tests/IDL_Test/IDL_Test.mpc @@ -25,7 +25,7 @@ project(*Main): taoserver, messaging { params.idl reopened_modules.idl sequence.idl -// struct.idl + struct.idl reopen_include1.idl reopen_include2.idl typeprefix.idl |