FreeBSD/contrib/gcc/cp/name-lookup.c
/* Look up NAME for type used in elaborated name specifier in
   the scopes given by SCOPE.  SCOPE can be either TS_CURRENT or
   TS_WITHIN_ENCLOSING_NON_CLASS.  Although not implied by the
   name, more scopes are checked if cleanup or template parameter
   scope is encountered.

   Unlike lookup_name_real, we make sure that NAME is actually
   declared in the desired scope, not from inheritance, nor using
   directive.  For using declaration, there is DR138 still waiting
   to be resolved.  Hidden name coming from an earlier friend
   declaration is also returned.

   A TYPE_DECL best matching the NAME is returned.  Catching error
   and issuing diagnostics are caller's responsibility.  */
Look up NAME for type used in elaborated name specifier in
the scopes given by SCOPE.  SCOPE can be either TS_CURRENT or
TS_WITHIN_ENCLOSING_NON_CLASS.  Although not implied by the
name, more scopes are checked if cleanup or template parameter
scope is encountered.

Unlike lookup_name_real, we make sure that NAME is actually
declared in the desired scope, not from inheritance, nor using
directive.  For using declaration, there is DR138 still waiting
to be resolved.  Hidden name coming from an earlier friend
declaration is also returned.

A TYPE_DECL best matching the NAME is returned.  Catching error
and issuing diagnostics are caller's responsibility.
Look up NAME for type used in elaborated name specifier in the scopes given by SCOPE . SCOPE can be either TS_CURRENT or TS_WITHIN_ENCLOSING_NON_CLASS . Although not implied by the name more scopes are checked if cleanup or template parameter scope is encountered . Unlike lookup_name_real we make sure that NAME is actually declared in the desired scope not from inheritance nor using directive . For using declaration there is DR138 still waiting to be resolved . Hidden name coming from an earlier friend declaration is also returned . A TYPE_DECL best matching the NAME is returned . Catching error and issuing diagnostics are caller ' s responsibility .
tree
lookup_type_scope (tree name, tag_scope scope)
{
  cxx_binding *iter = NULL;
  tree val = NULL_TREE;
  timevar_push (TV_NAME_LOOKUP);
  if (current_binding_level->kind != sk_namespace)
    iter = outer_binding (name, NULL,  true);
  for (; iter; iter = outer_binding (name, iter,  true))
    {
      if (qualify_lookup (iter->type, LOOKUP_PREFER_TYPES)
	  && (scope != ts_current
	      || LOCAL_BINDING_P (iter)
	      || DECL_CONTEXT (iter->type) == iter->scope->this_entity))
	val = iter->type;
      else if ((scope != ts_current
		|| !INHERITED_VALUE_BINDING_P (iter))
	       && qualify_lookup (iter->value, LOOKUP_PREFER_TYPES))
	val = iter->value;
      if (val)
	break;
    }
  if (!val)
    {
      iter = cxx_scope_find_binding_for_name
	       (NAMESPACE_LEVEL (current_decl_namespace ()), name);
      if (iter)
	{
	  if (qualify_lookup (iter->type, LOOKUP_PREFER_TYPES))
	    val = iter->type;
	  else if (qualify_lookup (iter->value, LOOKUP_PREFER_TYPES))
	    val = iter->value;
	}
    }
  if (val)
    {
      struct cp_binding_level *b = current_binding_level;
      while (b)
	{
	  if (iter->scope == b)
	    POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
	  if (b->kind == sk_cleanup || b->kind == sk_template_parms)
	    b = b->level_chain;
	  else if (b->kind == sk_class
		   && scope == ts_within_enclosing_non_class)
	    b = b->level_chain;
	  else
	    break;
	}
    }
  POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
}
tree lookup_type_scope ( tree name , tag_scope scope ) { cxx_binding * iter = NULL ; tree val = NULL_TREE ; timevar_push ( TV_NAME_LOOKUP ) ; if ( current_binding_level -> kind != sk_namespace ) iter = outer_binding ( name , NULL , true ) ; for ( ; iter ; iter = outer_binding ( name , iter , true ) ) { if ( qualify_lookup ( iter -> type , LOOKUP_PREFER_TYPES ) && ( scope != ts_current || LOCAL_BINDING_P ( iter ) || DECL_CONTEXT ( iter -> type ) == iter -> scope -> this_entity ) ) val = iter -> type ; else if ( ( scope != ts_current || ! INHERITED_VALUE_BINDING_P ( iter ) ) && qualify_lookup ( iter -> value , LOOKUP_PREFER_TYPES ) ) val = iter -> value ; if ( val ) break ; } if ( ! val ) { iter = cxx_scope_find_binding_for_name ( NAMESPACE_LEVEL ( current_decl_namespace ( ) ) , name ) ; if ( iter ) { if ( qualify_lookup ( iter -> type , LOOKUP_PREFER_TYPES ) ) val = iter -> type ; else if ( qualify_lookup ( iter -> value , LOOKUP_PREFER_TYPES ) ) val = iter -> value ; } } if ( val ) { struct cp_binding_level * b = current_binding_level ; while ( b ) { if ( iter -> scope == b ) POP_TIMEVAR_AND_RETURN ( TV_NAME_LOOKUP , val ) ; if ( b -> kind == sk_cleanup || b -> kind == sk_template_parms ) b = b -> level_chain ; else if ( b -> kind == sk_class && scope == ts_within_enclosing_non_class ) b = b -> level_chain ; else break ; } } POP_TIMEVAR_AND_RETURN ( TV_NAME_LOOKUP , NULL_TREE ) ; }
Look up NAME for type used in elaborated name specifier in
the scopes given by SCOPE.
Look up NAME for type used in elaborated name specifier in the scopes given by SCOPE .
/* Look in non-namespace scope first.  */ /*class_p=*/ /*class_p=*/ /* Check if this is the kind of thing we're looking for.
	 If SCOPE is TS_CURRENT, also make sure it doesn't come from
	 base class.  For ITER->VALUE, we can simply use
	 INHERITED_VALUE_BINDING_P.  For ITER->TYPE, we have to use
	 our own check.

	 We check ITER->TYPE before ITER->VALUE in order to handle
	   typedef struct C {} C;
	 correctly.  */ /* Look in namespace scope.  */ /* If this is the kind of thing we're looking for, we're done.  */ /* Type found, check if it is in the allowed scopes, ignoring cleanup
     and template parameter scopes.  */