diff options
Diffstat (limited to 'TAO/TAO_IDL/util/utl_scope.cpp')
-rw-r--r-- | TAO/TAO_IDL/util/utl_scope.cpp | 109 |
1 files changed, 85 insertions, 24 deletions
diff --git a/TAO/TAO_IDL/util/utl_scope.cpp b/TAO/TAO_IDL/util/utl_scope.cpp index 083cb626c64..b790d4070c7 100644 --- a/TAO/TAO_IDL/util/utl_scope.cpp +++ b/TAO/TAO_IDL/util/utl_scope.cpp @@ -1576,20 +1576,79 @@ UTL_Scope::lookup_primitive_type (AST_Expression::ExprType et) return 0; } -// Look through inherited list. Overridden in AST_Interface. +// Look through inherited interfaces. AST_Decl * -UTL_Scope::look_in_inherited (UTL_ScopedName *, - idl_bool ) +UTL_Scope::look_in_inherited (UTL_ScopedName *e, + idl_bool treat_as_ref) { - return 0; -} + AST_Decl *d = 0; + AST_Decl *d_before = 0; + AST_Interface *i = AST_Interface::narrow_from_scope (this); + AST_Interface **is = 0; + long nis = -1; -// Look through supported interface list. Overridden where necessary. -AST_Decl * -UTL_Scope::look_in_supported (UTL_ScopedName *, - idl_bool) -{ - return 0; + // This scope is not an interface. + if (i == 0) + { + return 0; + } + + // Can't look in an interface which was not yet defined. + if (!i->is_defined ()) + { + idl_global->err ()->fwd_decl_lookup (i, + e); + return 0; + } + + // OK, loop through inherited interfaces. + + // (Don't leave the inheritance hierarchy, no module or global ...) + // Find all and report ambiguous results as error. + + for (nis = i->n_inherits (), is = i->inherits (); nis > 0; nis--, is++) + { + d = (*is)->lookup_by_name (e, + treat_as_ref, + 0 /* not in parent */); + if (d != 0) + { + if (d_before == 0) + { + // First result found. + d_before = d; + } + else + { + // Conflict against further results? + if (d != d_before) + { + ACE_ERROR ((LM_ERROR, + "warning in %s line %d: ", + idl_global->filename ()->get_string (), + idl_global->lineno ())); + + e->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR ((LM_ERROR, + " is ambiguous in scope.\n" + "Found ")); + + d->name ()->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR ((LM_ERROR, + " and ")); + + d_before->name ()->dump (*ACE_DEFAULT_LOG_STREAM); + + ACE_ERROR ((LM_ERROR, + ".\n")); + } + } + } + } + + return d_before; } // Look up a String * in local scope only. @@ -1620,11 +1679,7 @@ UTL_Scope::lookup_by_name_local (Identifier *e, idl_bool in_corba = ACE_OS::strcmp (e->get_string (), "CORBA") == 0; - // Iterate over this scope. We need IK_both here for the legacy - // case where a recursive type is defined via an anonymous sequence. - // Looking up the anonymous sequence parameter succeeds only if - // references are included, since the decl for the (unfinished) - // enclosing type has not yet been added to the scope decls. + // Iterate over this scope. for (UTL_ScopeActiveIterator i (this, UTL_Scope::IK_both); !i.is_done (); i.next ()) @@ -1770,13 +1825,17 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, if (d == 0) { - // A no-op unless d can inherit. - d = look_in_inherited (e, treat_as_ref); - - if (d == 0) + + // Special case for scope which is an interface or value type. + // We have to look in the inherited interfaces as well. + // Look before parent scopes. + if (pd_scope_node_type == AST_Decl::NT_interface + || pd_scope_node_type == AST_Decl::NT_valuetype + || pd_scope_node_type == AST_Decl::NT_component + || pd_scope_node_type == AST_Decl::NT_eventtype) { - // A no-op unless d can support interfaces. - d = look_in_supported (e, treat_as_ref); + d = look_in_inherited (e, + treat_as_ref); } if ((d == 0) && in_parent && idl_global->err_count () == 0) @@ -1847,6 +1906,7 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, } // For the possible call to look_in_inherited() below. + AST_Decl::NodeType nt = d->node_type (); t = DeclAsScope (d); // OK, start of name is defined. Now loop doing local lookups @@ -1865,9 +1925,10 @@ UTL_Scope::lookup_by_name (UTL_ScopedName *e, // up was inherited into that interface. The first call to // look_in_inherited() is this function only checks base classes // of the scope (interface) we started the lookup from. - if (d == 0) + if (d == 0 && nt == AST_Decl::NT_interface) { - d = t->look_in_inherited (sn, treat_as_ref); + d = t->look_in_inherited (sn, + treat_as_ref); } // If treat_as_ref is true and d is not 0, add d to |