diff options
author | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-11-25 01:38:23 +0000 |
---|---|---|
committer | parsons <parsons@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-11-25 01:38:23 +0000 |
commit | 067631e69510bed3b6622ea172ab50650aab9975 (patch) | |
tree | 09fa8c44402d78ff88161786bdcf540e96164265 | |
parent | 5d72c19b9c635d2a9175940e07128c3c6a6845fd (diff) | |
download | ATCD-067631e69510bed3b6622ea172ab50650aab9975.tar.gz |
ChangeLogTag: Wed Nov 25 01:35:38 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu>
-rw-r--r-- | modules/TAO/ChangeLog | 9 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/idl.yy | 48 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/fe/y.tab.cpp | 57 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/include/idl_global.h | 8 | ||||
-rw-r--r-- | modules/TAO/TAO_IDL/util/utl_global.cpp | 72 |
5 files changed, 141 insertions, 53 deletions
diff --git a/modules/TAO/ChangeLog b/modules/TAO/ChangeLog index b7523fb5e3d..06f608925fd 100644 --- a/modules/TAO/ChangeLog +++ b/modules/TAO/ChangeLog @@ -1,3 +1,12 @@ +Wed Nov 25 01:35:38 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> + + * TAO_IDL/include/idl_global.h: + * TAO_IDL/util/utl_global.cpp: + * TAO_IDL/fe/y.tab.cpp: + * TAO_IDL/fe/idl.yy: + + Fixed bugs in 'sequence<xxx>' template param checking. + Tue Nov 24 21:20:55 UTC 2009 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/fe/idl.yy: diff --git a/modules/TAO/TAO_IDL/fe/idl.yy b/modules/TAO/TAO_IDL/fe/idl.yy index 685a1ee11a3..ed13db04c16 100644 --- a/modules/TAO/TAO_IDL/fe/idl.yy +++ b/modules/TAO/TAO_IDL/fe/idl.yy @@ -541,7 +541,19 @@ fixed_module { // fixed_module : module_header idl_global->set_parse_state (IDL_GlobalData::PS_ModuleIDSeen); - // Check that scoped name contains no delimitor. + + // The module_header rule is common to template module, fixed + // module and instantiated template module. In the last + // case, a fully scoped name is allowed, but here we + // allow only an identifier (a scoped name of length + // 1). If not satisfied, we output a parse error with + // the appropriate message. + if ($1->length () != 1) + { + idl_global->err ()->syntax_error ( + IDL_GlobalData::PS_ModuleIDSeen); + } + AST_Module *m = 0; UTL_Scope *s = idl_global->scopes ().top_non_null (); @@ -592,7 +604,18 @@ template_module : template_module_header { // template_module : template_module_header - // Check that scoped name contains no delimitor. + + // The module_header rule is common to template module, fixed + // module and instantiated template module. In the last + // case, a fully scoped name is allowed, but here we + // allow only an identifier (a scoped name of length + // 1). If not satisfied, we output a parse error with + // the appropriate message. + if ((tao_yyvsp[(1) - (1)].idlist)->length () != 1) + { + idl_global->err ()->syntax_error ( + IDL_GlobalData::PS_ModuleIDSeen); + } } at_least_one_formal_parameter { @@ -5980,7 +6003,7 @@ formal_parameter_type at_least_one_formal_parameter : formal_parameter formal_parameters { -// formal_parameter formal_parameters +// at_least_one_formal_parameter : formal_parameter formal_parameters if ($2 == 0) { ACE_NEW_RETURN ($2, @@ -5991,6 +6014,22 @@ at_least_one_formal_parameter $2->enqueue_head (*$1); delete $1; $1 = 0; + + // The param added above is always the last one parsed, + // so we check for matches between sequence<T> & T here. + ACE_CString bad_id = + idl_global->check_for_seq_of_param ( + $2); + + if (!bad_id.empty ()) + { + delete $2; + $2 = 0; + + idl_global->err ()->mismatch_seq_of_param (bad_id.c_str ()); + } + + $<plval>$ = $2; } ; @@ -6010,6 +6049,9 @@ formal_parameters 1); } + $1->enqueue_tail (*$4); + $<plval>$ = $1; + bool so_far_so_good = idl_global->check_for_seq_of_param ($1, $4); diff --git a/modules/TAO/TAO_IDL/fe/y.tab.cpp b/modules/TAO/TAO_IDL/fe/y.tab.cpp index bc328aa79c8..635dcd78c94 100644 --- a/modules/TAO/TAO_IDL/fe/y.tab.cpp +++ b/modules/TAO/TAO_IDL/fe/y.tab.cpp @@ -2867,7 +2867,19 @@ tao_yyreduce: { // fixed_module : module_header idl_global->set_parse_state (IDL_GlobalData::PS_ModuleIDSeen); - // Check that scoped name contains no delimitor. + + // The module_header rule is common to template module, fixed + // module and instantiated template module. In the last + // case, a fully scoped name is allowed, but here we + // allow only an identifier (a scoped name of length + // 1). If not satisfied, we output a parse error with + // the appropriate message. + if ((tao_yyvsp[(1) - (1)].idlist)->length () != 1) + { + idl_global->err ()->syntax_error ( + IDL_GlobalData::PS_ModuleIDSeen); + } + AST_Module *m = 0; UTL_Scope *s = idl_global->scopes ().top_non_null (); @@ -8857,6 +8869,22 @@ tao_yyreduce: (tao_yyvsp[(2) - (2)].plval)->enqueue_head (*(tao_yyvsp[(1) - (2)].pival)); delete (tao_yyvsp[(1) - (2)].pival); (tao_yyvsp[(1) - (2)].pival) = 0; + + // The param added above is always the last one parsed, + // so we check for matches between sequence<T> & T here. + ACE_CString bad_id = + idl_global->check_for_seq_of_param ( + (tao_yyvsp[(2) - (2)].plval)); + + if (!bad_id.empty ()) + { + delete (tao_yyvsp[(2) - (2)].plval); + (tao_yyvsp[(2) - (2)].plval) = 0; + + idl_global->err ()->mismatch_seq_of_param (bad_id.c_str ()); + } + + (tao_yyval.plval) = (tao_yyvsp[(2) - (2)].plval); } break; @@ -8879,32 +8907,11 @@ tao_yyreduce: 1); } - bool so_far_so_good = - idl_global->check_for_seq_of_param ((tao_yyvsp[(1) - (4)].plval), - (tao_yyvsp[(4) - (4)].pival)); - - if (so_far_so_good) - { - (tao_yyvsp[(1) - (4)].plval)->enqueue_tail (*(tao_yyvsp[(4) - (4)].pival)); - (tao_yyval.plval) = (tao_yyvsp[(1) - (4)].plval); - } - else - { - delete (tao_yyvsp[(1) - (4)].plval); - (tao_yyvsp[(1) - (4)].plval) = 0; - - idl_global->err ()->mismatch_seq_of_param ( - (tao_yyvsp[(4) - (4)].pival)->name_.c_str ()); - } - + (tao_yyvsp[(1) - (4)].plval)->enqueue_tail (*(tao_yyvsp[(4) - (4)].pival)); + (tao_yyval.plval) = (tao_yyvsp[(1) - (4)].plval); + delete (tao_yyvsp[(4) - (4)].pival); (tao_yyvsp[(4) - (4)].pival) = 0; - - if (!so_far_so_good) - { - return 1; - } - } break; diff --git a/modules/TAO/TAO_IDL/include/idl_global.h b/modules/TAO/TAO_IDL/include/idl_global.h index 2b9f04599c3..491c767bd62 100644 --- a/modules/TAO/TAO_IDL/include/idl_global.h +++ b/modules/TAO/TAO_IDL/include/idl_global.h @@ -649,8 +649,7 @@ public: UTL_String *utl_string_factory (const char *str); // Utility function to create UTL_String classes on the FE heap. - bool check_for_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list, - FE_Utils::T_Param_Info *param); + ACE_CString check_for_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list); // Check if 'param' is a sequence of a previous param, and if // so, if the previous param exists. @@ -663,6 +662,11 @@ public: void original_local_name (Identifier *local_name); // Strips _cxx_ prefix for use in port names. + +private: + bool check_one_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list, + ACE_CString ¶m_id, + size_t index); private: // Data diff --git a/modules/TAO/TAO_IDL/util/utl_global.cpp b/modules/TAO/TAO_IDL/util/utl_global.cpp index 45583d32f2c..498a35b16da 100644 --- a/modules/TAO/TAO_IDL/util/utl_global.cpp +++ b/modules/TAO/TAO_IDL/util/utl_global.cpp @@ -1795,41 +1795,38 @@ IDL_GlobalData::utl_string_factory (const char *str) return new UTL_String (str); } -bool -IDL_GlobalData::check_for_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list, - FE_Utils::T_Param_Info *param) +ACE_CString +IDL_GlobalData::check_for_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list) { - ACE_CString id; + ACE_CString id, retval; const char *pattern = "sequence<"; size_t len = ACE_OS::strlen (pattern); + size_t index = 0; + - if (param->name_.find (pattern) == 0) - { - // Get the substring of what's between the brackets. - // It will have to match a previous param in the list. - id = param->name_.substr (len, - param->name_.length () - (len + 1)); - } - else - { - // No check to make. - return true; - } - for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*list); !i.done (); - i.advance ()) + i.advance (), ++index) { - FE_Utils::T_Param_Info *info = 0; - i.next (info); + FE_Utils::T_Param_Info *param = 0; + i.next (param); - if (info->name_ == id) + if (param->name_.find (pattern) == 0) { - return true; + // Get the substring of what's between the brackets. + // It will have to match a previous param in the list. + id = param->name_.substr (len, + param->name_.length () - (len + 1)); + + if (!this->check_one_seq_of_param (list, id, index)) + { + retval = id; + break; + } } } - return false; + return retval; } void @@ -2068,3 +2065,32 @@ IDL_GlobalData::original_local_name (Identifier *local_name) } } +bool +IDL_GlobalData::check_one_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list, + ACE_CString ¶m_id, + size_t index) +{ + size_t local_index = 0; + + for (FE_Utils::T_PARAMLIST_INFO::CONST_ITERATOR i (*list); + !i.done (); + i.advance (), ++local_index) + { + if (local_index == index) + { + break; + } + + FE_Utils::T_Param_Info *info = 0; + i.next (info); + + if (info->name_ == param_id) + { + return true; + } + } + + return false; +} + + |