summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/ChangeLog30
-rw-r--r--TAO/TAO_IDL/Makefile.am1
-rw-r--r--TAO/TAO_IDL/ast/ast_enum.cpp2
-rw-r--r--TAO/TAO_IDL/ast/ast_module.cpp3
-rw-r--r--TAO/TAO_IDL/ast/ast_redef.cpp94
-rw-r--r--TAO/TAO_IDL/fe/fe_utils.cpp88
-rw-r--r--TAO/TAO_IDL/include/fe_utils.h7
-rw-r--r--TAO/TAO_IDL/include/global_extern.h12
-rw-r--r--TAO/TAO_IDL/include/utl_scope_T.cpp4
-rw-r--r--TAO/TAO_IDL/util/utl_scope.cpp33
-rw-r--r--TAO/tests/IDL_Test/interface.idl36
11 files changed, 179 insertions, 131 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index b4d0f2dbb04..2e83ca9d220 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,33 @@
+Mon Aug 9 17:06:41 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
+
+ * TAO_IDL/ast/ast_redef.cpp:
+ * TAO_IDL/Makefile.am:
+
+ Removed the source file, since its only
+ method has been moved rewritten in
+ class FE_Utils, and updated the automake
+ file.
+
+ * TAO_IDL/include/fe_utils.h:
+ * TAO_IDL/include/utl_scope_T.cpp:
+ * TAO_IDL/include/global_extern.h:
+ * TAO_IDL/ast/ast_module.cpp:
+ * TAO_IDL/ast/ast_enum.cpp:
+ * TAO_IDL/fe/fe_utils.cpp:
+ * TAO_IDL/util/utl_scope.cpp:
+
+ Rewrote the formerly global method
+ can_be_redefined() in class FE_Utils,
+ and rerouted all calls to the new version.
+ This change fixes some redefinition bugs
+ that were introduced in x.8.1, thanks to
+ Robert Shectman <shectman at llnl dot gov> for
+ reporting the problem.
+
+ * tests/IDL_Test/interface.idl:
+
+ Added test cases for the above change.
+
Mon Aug 9 13:13:21 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu>
* orbsvcs/tests/InterfaceRepo/Bug_3883_Regression/test.idl:
diff --git a/TAO/TAO_IDL/Makefile.am b/TAO/TAO_IDL/Makefile.am
index e5fb33bfb7b..164d924f85d 100644
--- a/TAO/TAO_IDL/Makefile.am
+++ b/TAO/TAO_IDL/Makefile.am
@@ -60,7 +60,6 @@ libTAO_IDL_FE_la_SOURCES = \
ast/ast_provides.cpp \
ast/ast_publishes.cpp \
ast/ast_recursive.cpp \
- ast/ast_redef.cpp \
ast/ast_root.cpp \
ast/ast_sequence.cpp \
ast/ast_string.cpp \
diff --git a/TAO/TAO_IDL/ast/ast_enum.cpp b/TAO/TAO_IDL/ast/ast_enum.cpp
index 44d900e7304..8af1434ec1c 100644
--- a/TAO/TAO_IDL/ast/ast_enum.cpp
+++ b/TAO/TAO_IDL/ast/ast_enum.cpp
@@ -268,7 +268,7 @@ AST_Enum::fe_add_enum_val (AST_EnumVal *t)
// Already defined and cannot be redefined? Or already used?
if ((d = this->lookup_for_add (t)) != 0)
{
- if (!can_be_redefined (d))
+ if (!FE_Utils::can_be_redefined (d, t))
{
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
diff --git a/TAO/TAO_IDL/ast/ast_module.cpp b/TAO/TAO_IDL/ast/ast_module.cpp
index b1f5d3448c0..7c03eaacb54 100644
--- a/TAO/TAO_IDL/ast/ast_module.cpp
+++ b/TAO/TAO_IDL/ast/ast_module.cpp
@@ -364,9 +364,10 @@ AST_Module::fe_add_module (AST_Module *t)
// Already defined and cannot be redefined? Or already used?
AST_Module *m = 0;
AST_Decl *d = this->lookup_for_add (t);
+
if (d)
{
- if (!can_be_redefined (d))
+ if (!FE_Utils::can_be_redefined (d, t))
{
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
diff --git a/TAO/TAO_IDL/ast/ast_redef.cpp b/TAO/TAO_IDL/ast/ast_redef.cpp
deleted file mode 100644
index 3b8109e3a5c..00000000000
--- a/TAO/TAO_IDL/ast/ast_redef.cpp
+++ /dev/null
@@ -1,94 +0,0 @@
-// $Id$
-
-/*
-
-COPYRIGHT
-
-Copyright 1992, 1993, 1994 Sun Microsystems, Inc. Printed in the United
-States of America. All Rights Reserved.
-
-This product is protected by copyright and distributed under the following
-license restricting its use.
-
-The Interface Definition Language Compiler Front End (CFE) is made
-available for your use provided that you include this license and copyright
-notice on all media and documentation and the software program in which
-this product is incorporated in whole or part. You may copy and extend
-functionality (but may not remove functionality) of the Interface
-Definition Language CFE without charge, but you are not authorized to
-license or distribute it to anyone else except as part of a product or
-program developed by you or with the express written consent of Sun
-Microsystems, Inc. ("Sun").
-
-The names of Sun Microsystems, Inc. and any of its subsidiaries or
-affiliates may not be used in advertising or publicity pertaining to
-distribution of Interface Definition Language CFE as permitted herein.
-
-This license is effective until terminated by Sun for failure to comply
-with this license. Upon termination, you shall destroy or return all code
-and documentation for the Interface Definition Language CFE.
-
-INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED AS IS WITH NO WARRANTIES OF
-ANY KIND INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS
-FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR ARISING FROM A COURSE OF
-DEALING, USAGE OR TRADE PRACTICE.
-
-INTERFACE DEFINITION LANGUAGE CFE IS PROVIDED WITH NO SUPPORT AND WITHOUT
-ANY OBLIGATION ON THE PART OF Sun OR ANY OF ITS SUBSIDIARIES OR AFFILIATES
-TO ASSIST IN ITS USE, CORRECTION, MODIFICATION OR ENHANCEMENT.
-
-SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES SHALL HAVE NO LIABILITY WITH
-RESPECT TO THE INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY
-INTERFACE DEFINITION LANGUAGE CFE OR ANY PART THEREOF.
-
-IN NO EVENT WILL SUN OR ANY OF ITS SUBSIDIARIES OR AFFILIATES BE LIABLE FOR
-ANY LOST REVENUE OR PROFITS OR OTHER SPECIAL, INDIRECT AND CONSEQUENTIAL
-DAMAGES, EVEN IF SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-Use, duplication, or disclosure by the government is subject to
-restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
-Technical Data and Computer Software clause at DFARS 252.227-7013 and FAR
-52.227-19.
-
-Sun, Sun Microsystems and the Sun logo are trademarks or registered
-trademarks of Sun Microsystems, Inc.
-
-SunSoft, Inc.
-2550 Garcia Avenue
-Mountain View, California 94043
-
-NOTE:
-
-SunOS, SunSoft, Sun, Solaris, Sun Microsystems or the Sun logo are
-trademarks or registered trademarks of Sun Microsystems, Inc.
-
-*/
-
-#include "ast_decl.h"
-
-// Return TRUE if the node d represents an IDL construct whose name
-// can be redefined.
-bool
-can_be_redefined (AST_Decl *d)
-{
- switch (d->node_type ())
- {
- case AST_Decl::NT_module:
- case AST_Decl::NT_interface:
- case AST_Decl::NT_interface_fwd:
- case AST_Decl::NT_valuetype:
- case AST_Decl::NT_valuetype_fwd:
- case AST_Decl::NT_component:
- case AST_Decl::NT_component_fwd:
- case AST_Decl::NT_eventtype:
- case AST_Decl::NT_eventtype_fwd:
- case AST_Decl::NT_union:
- case AST_Decl::NT_union_fwd:
- case AST_Decl::NT_struct:
- case AST_Decl::NT_struct_fwd:
- return true;
- default:
- return false;
- }
-}
-
diff --git a/TAO/TAO_IDL/fe/fe_utils.cpp b/TAO/TAO_IDL/fe/fe_utils.cpp
index 7cb50f75ffd..b0643ba061e 100644
--- a/TAO/TAO_IDL/fe/fe_utils.cpp
+++ b/TAO/TAO_IDL/fe/fe_utils.cpp
@@ -810,6 +810,94 @@ FE_Utils::original_local_name (Identifier *local_name)
}
bool
+FE_Utils::can_be_redefined (AST_Decl *prev_decl,
+ AST_Decl *curr_decl)
+{
+ AST_Decl::NodeType pnt = prev_decl->node_type ();
+ AST_Decl::NodeType cnt = curr_decl->node_type ();
+
+ switch (cnt)
+ {
+ /// For these, any non-zero previous decl
+ /// is an error.
+ case AST_Decl::NT_attr:
+ case AST_Decl::NT_op:
+ case AST_Decl::NT_ext_port:
+ case AST_Decl::NT_mirror_port:
+ case AST_Decl::NT_provides:
+ case AST_Decl::NT_publishes:
+ case AST_Decl::NT_consumes:
+ case AST_Decl::NT_uses:
+ return false;
+ default:
+ break;
+ }
+
+ UTL_Scope *prev_scope = prev_decl->defined_in ();
+ UTL_Scope *curr_scope = curr_decl->defined_in ();
+ AST_Structure *s = 0;
+ AST_StructureFwd *s_fwd = 0;
+ AST_Interface *i = 0;
+ AST_InterfaceFwd *i_fwd = 0;
+
+ bool nt_eq = (pnt == cnt);
+ bool s_eq = (prev_scope == curr_scope);
+
+ switch (pnt)
+ {
+ case AST_Decl::NT_module:
+ /// Just need to check that both are modules.
+ return (cnt == AST_Decl::NT_module);
+ /// For the *_fwd types, if scopes aren't related, it's ok.
+ /// If they are related, then we need another fwd or a full decl.
+ case AST_Decl::NT_component_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_component));
+ case AST_Decl::NT_eventtype_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_eventtype));
+ case AST_Decl::NT_interface_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_interface));
+ case AST_Decl::NT_struct_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_struct));
+ case AST_Decl::NT_union_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_union));
+ case AST_Decl::NT_valuetype_fwd:
+ return (!s_eq || (nt_eq || cnt == AST_Decl::NT_valuetype));
+ /// If scopes aren't related, it's ok. If they are, check
+ /// if the previous is a dummy for a fwd decl. Even a redef
+ /// in a derived interface type is ok.
+ case AST_Decl::NT_struct:
+ case AST_Decl::NT_union:
+ s = AST_Structure::narrow_from_decl (prev_decl);
+ s_fwd = (s == 0 ? 0 : s->fwd_decl ());
+ return (!s_eq || s_fwd != 0);
+ case AST_Decl::NT_interface:
+ case AST_Decl::NT_component:
+ case AST_Decl::NT_eventtype:
+ case AST_Decl::NT_valuetype:
+ case AST_Decl::NT_connector:
+ i = AST_Interface::narrow_from_decl (prev_decl);
+ i_fwd = (i == 0 ? 0 : i->fwd_decl ());
+ return (!s_eq || i_fwd != 0);
+ /// For factories, exceptions, constants and types, even a
+ /// redef in a derived interface type is ok. Checking for
+ /// unequal scopes covers boxed valuetypes as well.
+ case AST_Decl::NT_valuebox:
+ case AST_Decl::NT_except:
+ case AST_Decl::NT_typedef:
+ case AST_Decl::NT_const:
+ case AST_Decl::NT_factory:
+ case AST_Decl::NT_type:
+ {
+ return !s_eq;
+ }
+ /// What's left are the case from the previous switch statement.
+ /// Same rule applies - no overrides or redefs, ever.
+ default:
+ return false;
+ }
+}
+
+bool
FE_Utils::check_one_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list,
ACE_CString &param_id,
size_t index)
diff --git a/TAO/TAO_IDL/include/fe_utils.h b/TAO/TAO_IDL/include/fe_utils.h
index 79a21367ded..3abce8470f7 100644
--- a/TAO/TAO_IDL/include/fe_utils.h
+++ b/TAO/TAO_IDL/include/fe_utils.h
@@ -108,6 +108,13 @@ struct TAO_IDL_FE_Export FE_Utils
static void
original_local_name (Identifier *local_name);
+ /// Types, constants and exceptions can be redefined in
+ /// derived interfaces, modules may be reopened, forward
+ /// declarations may be repeated, etc.
+ static bool
+ can_be_redefined (AST_Decl *prev_dec,
+ AST_Decl *curr_decl);
+
private:
static bool
check_one_seq_of_param (FE_Utils::T_PARAMLIST_INFO *list,
diff --git a/TAO/TAO_IDL/include/global_extern.h b/TAO/TAO_IDL/include/global_extern.h
index 6bf7335c34d..e9eef69e8d6 100644
--- a/TAO/TAO_IDL/include/global_extern.h
+++ b/TAO/TAO_IDL/include/global_extern.h
@@ -70,17 +70,9 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
#include "TAO_IDL_FE_Export.h"
#include "idl_global.h"
-class AST_Decl;
-
-// global_extern.hh - Global data for the IDL compiler
+// global_extern.h - Global data for the IDL compiler
extern TAO_IDL_FE_Export IDL_GlobalData *idl_global;
-// Contains all "global" data
-
-// Global functions for the IDL compiler
-
-// Return TRUE when the name of this AST_Decl can be reused in
-// a definition in this scope
-extern bool can_be_redefined (AST_Decl *);
+// Contains all "global" data for the frontend.
#endif // _GLOBAL_EXTERN_GLOBAL_EXTERN_HH
diff --git a/TAO/TAO_IDL/include/utl_scope_T.cpp b/TAO/TAO_IDL/include/utl_scope_T.cpp
index 64448c504ac..5bfa87e3319 100644
--- a/TAO/TAO_IDL/include/utl_scope_T.cpp
+++ b/TAO/TAO_IDL/include/utl_scope_T.cpp
@@ -63,7 +63,7 @@ UTL_Scope::fe_add_full_intf_decl (DECL *t)
}
}
- else if (!can_be_redefined (predef))
+ else if (!FE_Utils::can_be_redefined (predef, t))
{
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
@@ -157,7 +157,7 @@ UTL_Scope::fe_add_fwd_intf_decl (typename FULL_DECL::FWD_TYPE *t)
}
}
- if (!can_be_redefined (d)) {
+ if (!FE_Utils::can_be_redefined (d, t)) {
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp
index de7a2134fe5..1d37dad6748 100644
--- a/TAO/TAO_IDL/util/utl_scope.cpp
+++ b/TAO/TAO_IDL/util/utl_scope.cpp
@@ -480,29 +480,16 @@ UTL_Scope::fe_add_decl (AST_Decl *t)
{
// Already defined and cannot be redefined? Or already used?
AST_Decl *d = this->lookup_for_add (t);
+
if (d)
{
- if (!can_be_redefined (d))
+ if (!FE_Utils::can_be_redefined (d, t))
{
- AST_Decl::NodeType tnt = t->node_type ();
- AST_Decl::NodeType dnt = d->node_type ();
-
- // Factories are not inherited, so they can be
- // redefined, but not in the same scope (home or
- // valuetype).
- bool inherited_factory =
- ( tnt == AST_Decl::NT_factory
- && dnt == AST_Decl::NT_factory
- && t->defined_in () != d->defined_in ());
-
- if (!inherited_factory)
- {
- idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
- t,
- ScopeAsDecl (this),
- d);
- return 0;
- }
+ idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
+ t,
+ ScopeAsDecl (this),
+ d);
+ return 0;
}
// For convenience, AST_Template_Module_Inst inherits
@@ -589,9 +576,10 @@ AST_Structure *
UTL_Scope::fe_add_full_struct_type (AST_Structure *t)
{
AST_Decl *predef = this->lookup_for_add (t);
+
if (predef)
{
- if (!can_be_redefined (predef))
+ if (!FE_Utils::can_be_redefined (predef, t))
{
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
@@ -599,6 +587,7 @@ UTL_Scope::fe_add_full_struct_type (AST_Structure *t)
predef);
return 0;
}
+
if (referenced (predef, t->local_name ()) && !t->is_defined ())
{
idl_global->err ()->error3 (UTL_Error::EIDL_DEF_USE,
@@ -648,7 +637,7 @@ UTL_Scope::fe_add_fwd_struct_type (AST_StructureFwd *t)
{
t->set_full_definition (AST_Structure::narrow_from_decl (d));
}
- else if (!can_be_redefined (d))
+ else if (!FE_Utils::can_be_redefined (d, t))
{
idl_global->err ()->error3 (UTL_Error::EIDL_REDEF,
t,
diff --git a/TAO/tests/IDL_Test/interface.idl b/TAO/tests/IDL_Test/interface.idl
index cf82eab264f..d5e713d6e44 100644
--- a/TAO/tests/IDL_Test/interface.idl
+++ b/TAO/tests/IDL_Test/interface.idl
@@ -209,3 +209,39 @@ module i2
string getstr3();
};
};
+
+/// Tests acceptance of legal redefinitions (of
+/// constants, exceptions and types) in a derived
+/// interface.
+module redefs
+{
+ interface base
+ {
+ const long lconst = -5;
+
+ exception ex
+ {
+ string info;
+ };
+
+ struct foo
+ {
+ short index;
+ };
+ };
+
+ interface derived : base
+ {
+ const long lconst = 44;
+
+ exception ex
+ {
+ long serial;
+ };
+
+ struct foo
+ {
+ string str;
+ };
+ };
+};