Deleted Added
full compact
name-lookup.c (259563) name-lookup.c (260932)
1/* Definitions for C++ name lookup routines.
2 Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by

--- 28 unchanged lines hidden (view full) ---

37
38struct scope_binding {
39 tree value;
40 tree type;
41};
42#define EMPTY_SCOPE_BINDING { NULL_TREE, NULL_TREE }
43
44static cxx_scope *innermost_nonclass_level (void);
1/* Definitions for C++ name lookup routines.
2 Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published by

--- 28 unchanged lines hidden (view full) ---

37
38struct scope_binding {
39 tree value;
40 tree type;
41};
42#define EMPTY_SCOPE_BINDING { NULL_TREE, NULL_TREE }
43
44static cxx_scope *innermost_nonclass_level (void);
45static tree select_decl (const struct scope_binding *, int);
46static cxx_binding *binding_for_name (cxx_scope *, tree);
47static tree lookup_name_innermost_nonclass_level (tree);
48static tree push_overloaded_decl (tree, int, bool);
49static bool lookup_using_namespace (tree, struct scope_binding *, tree,
50 tree, int);
51static bool qualified_lookup_using_namespace (tree, tree,
52 struct scope_binding *, int);
53static tree lookup_type_current_level (tree);

--- 2041 unchanged lines hidden (view full) ---

2095 return;
2096
2097 if (!decls.value && !decls.type)
2098 {
2099 error ("%qD not declared", name);
2100 return;
2101 }
2102
45static cxx_binding *binding_for_name (cxx_scope *, tree);
46static tree lookup_name_innermost_nonclass_level (tree);
47static tree push_overloaded_decl (tree, int, bool);
48static bool lookup_using_namespace (tree, struct scope_binding *, tree,
49 tree, int);
50static bool qualified_lookup_using_namespace (tree, tree,
51 struct scope_binding *, int);
52static tree lookup_type_current_level (tree);

--- 2041 unchanged lines hidden (view full) ---

2094 return;
2095
2096 if (!decls.value && !decls.type)
2097 {
2098 error ("%qD not declared", name);
2099 return;
2100 }
2101
2102 /* LLVM LOCAL begin mainline */
2103 /* Shift the old and new bindings around so we're comparing class and
2104 enumeration names to each other. */
2105 if (oldval && DECL_IMPLICIT_TYPEDEF_P (oldval))
2106 {
2107 oldtype = oldval;
2108 oldval = NULL_TREE;
2109 }
2110
2111 if (decls.value && DECL_IMPLICIT_TYPEDEF_P (decls.value))
2112 {
2113 decls.type = decls.value;
2114 decls.value = NULL_TREE;
2115 }
2116 /* LLVM LOCAL end mainline */
2117
2103 /* It is impossible to overload a built-in function; any explicit
2104 declaration eliminates the built-in declaration. So, if OLDVAL
2105 is a built-in, then we can just pretend it isn't there. */
2106 if (oldval
2107 && TREE_CODE (oldval) == FUNCTION_DECL
2108 && DECL_ANTICIPATED (oldval)
2109 && !DECL_HIDDEN_FRIEND_P (oldval))
2110 oldval = NULL_TREE;
2111
2118 /* It is impossible to overload a built-in function; any explicit
2119 declaration eliminates the built-in declaration. So, if OLDVAL
2120 is a built-in, then we can just pretend it isn't there. */
2121 if (oldval
2122 && TREE_CODE (oldval) == FUNCTION_DECL
2123 && DECL_ANTICIPATED (oldval)
2124 && !DECL_HIDDEN_FRIEND_P (oldval))
2125 oldval = NULL_TREE;
2126
2112 /* Check for using functions. */
2113 if (decls.value && is_overloaded_fn (decls.value))
2127 /* LLVM LOCAL begin mainline */
2128 if (decls.value)
2114 {
2129 {
2115 tree tmp, tmp1;
2116
2117 if (oldval && !is_overloaded_fn (oldval))
2130 /* Check for using functions. */
2131 if (is_overloaded_fn (decls.value))
2118 {
2132 {
2119 if (!DECL_IMPLICIT_TYPEDEF_P (oldval))
2120 error ("%qD is already declared in this scope", name);
2121 oldval = NULL_TREE;
2122 }
2133 tree tmp, tmp1;
2123
2134
2124 *newval = oldval;
2125 for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
2126 {
2127 tree new_fn = OVL_CURRENT (tmp);
2135 if (oldval && !is_overloaded_fn (oldval))
2136 {
2137 error ("%qD is already declared in this scope", name);
2138 oldval = NULL_TREE;
2139 }
2128
2140
2129 /* [namespace.udecl]
2130
2131 If a function declaration in namespace scope or block
2132 scope has the same name and the same parameter types as a
2133 function introduced by a using declaration the program is
2134 ill-formed. */
2135 for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1))
2141 *newval = oldval;
2142 for (tmp = decls.value; tmp; tmp = OVL_NEXT (tmp))
2136 {
2143 {
2137 tree old_fn = OVL_CURRENT (tmp1);
2144 tree new_fn = OVL_CURRENT (tmp);
2138
2145
2139 if (new_fn == old_fn)
2140 /* The function already exists in the current namespace. */
2141 break;
2142 else if (OVL_USED (tmp1))
2143 continue; /* this is a using decl */
2144 else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
2145 TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
2146 /* [namespace.udecl]
2147
2148 If a function declaration in namespace scope or block
2149 scope has the same name and the same parameter types as a
2150 function introduced by a using declaration the program is
2151 ill-formed. */
2152 for (tmp1 = oldval; tmp1; tmp1 = OVL_NEXT (tmp1))
2146 {
2153 {
2147 gcc_assert (!DECL_ANTICIPATED (old_fn)
2148 || DECL_HIDDEN_FRIEND_P (old_fn));
2154 tree old_fn = OVL_CURRENT (tmp1);
2149
2155
2150 /* There was already a non-using declaration in
2151 this scope with the same parameter types. If both
2152 are the same extern "C" functions, that's ok. */
2153 if (decls_match (new_fn, old_fn))
2156 if (new_fn == old_fn)
2157 /* The function already exists in the current namespace. */
2154 break;
2158 break;
2155 else
2159 else if (OVL_USED (tmp1))
2160 continue; /* this is a using decl */
2161 else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (new_fn)),
2162 TYPE_ARG_TYPES (TREE_TYPE (old_fn))))
2156 {
2163 {
2157 error ("%qD is already declared in this scope", name);
2158 break;
2164 gcc_assert (!DECL_ANTICIPATED (old_fn)
2165 || DECL_HIDDEN_FRIEND_P (old_fn));
2166
2167 /* There was already a non-using declaration in
2168 this scope with the same parameter types. If both
2169 are the same extern "C" functions, that's ok. */
2170 if (decls_match (new_fn, old_fn))
2171 break;
2172 else
2173 {
2174 error ("%qD is already declared in this scope", name);
2175 break;
2176 }
2159 }
2160 }
2177 }
2178 }
2161 }
2162
2179
2163 /* If we broke out of the loop, there's no reason to add
2164 this function to the using declarations for this
2165 scope. */
2166 if (tmp1)
2167 continue;
2180 /* If we broke out of the loop, there's no reason to add
2181 this function to the using declarations for this
2182 scope. */
2183 if (tmp1)
2184 continue;
2168
2185
2169 /* If we are adding to an existing OVERLOAD, then we no
2170 longer know the type of the set of functions. */
2171 if (*newval && TREE_CODE (*newval) == OVERLOAD)
2172 TREE_TYPE (*newval) = unknown_type_node;
2173 /* Add this new function to the set. */
2174 *newval = build_overload (OVL_CURRENT (tmp), *newval);
2175 /* If there is only one function, then we use its type. (A
2176 using-declaration naming a single function can be used in
2177 contexts where overload resolution cannot be
2178 performed.) */
2179 if (TREE_CODE (*newval) != OVERLOAD)
2180 {
2181 *newval = ovl_cons (*newval, NULL_TREE);
2182 TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp));
2186 /* If we are adding to an existing OVERLOAD, then we no
2187 longer know the type of the set of functions. */
2188 if (*newval && TREE_CODE (*newval) == OVERLOAD)
2189 TREE_TYPE (*newval) = unknown_type_node;
2190 /* Add this new function to the set. */
2191 *newval = build_overload (OVL_CURRENT (tmp), *newval);
2192 /* If there is only one function, then we use its type. (A
2193 using-declaration naming a single function can be used in
2194 contexts where overload resolution cannot be
2195 performed.) */
2196 if (TREE_CODE (*newval) != OVERLOAD)
2197 {
2198 *newval = ovl_cons (*newval, NULL_TREE);
2199 TREE_TYPE (*newval) = TREE_TYPE (OVL_CURRENT (tmp));
2200 }
2201 OVL_USED (*newval) = 1;
2183 }
2202 }
2184 OVL_USED (*newval) = 1;
2185 }
2203 }
2204 else
2205 {
2206 *newval = decls.value;
2207 if (oldval && !decls_match (*newval, oldval))
2208 error ("%qD is already declared in this scope", name);
2209 }
2186 }
2187 else
2210 }
2211 else
2212 *newval = oldval;
2213
2214 if (decls.type && TREE_CODE (decls.type) == TREE_LIST)
2188 {
2215 {
2189 *newval = decls.value;
2190 if (oldval && !decls_match (*newval, oldval))
2191 error ("%qD is already declared in this scope", name);
2216 error ("reference to %qD is ambiguous", name);
2217 print_candidates (decls.type);
2192 }
2218 }
2193
2194 *newtype = decls.type;
2195 if (oldtype && *newtype && !same_type_p (oldtype, *newtype))
2219 else
2196 {
2220 {
2197 error ("using declaration %qD introduced ambiguous type %qT",
2198 name, oldtype);
2199 return;
2221 *newtype = decls.type;
2222 if (oldtype && *newtype && !decls_match (oldtype, *newtype))
2223 error ("%qD is already declared in this scope", name);
2200 }
2224 }
2225
2226 /* If *newval is empty, shift any class or enumeration name down. */
2227 if (!*newval)
2228 {
2229 *newval = *newtype;
2230 *newtype = NULL_TREE;
2231 }
2232 /* LLVM LOCAL end mainline */
2201}
2202
2203/* Process a using-declaration at function scope. */
2204
2205void
2206do_local_using_decl (tree decl, tree scope, tree name)
2207{
2208 tree oldval, oldtype, newval, newtype;

--- 1277 unchanged lines hidden (view full) ---

3486/* This should return an error not all definitions define functions.
3487 It is not an error if we find two functions with exactly the
3488 same signature, only if these are selected in overload resolution.
3489 old is the current set of bindings, new the freshly-found binding.
3490 XXX Do we want to give *all* candidates in case of ambiguity?
3491 XXX In what way should I treat extern declarations?
3492 XXX I don't want to repeat the entire duplicate_decls here */
3493
2233}
2234
2235/* Process a using-declaration at function scope. */
2236
2237void
2238do_local_using_decl (tree decl, tree scope, tree name)
2239{
2240 tree oldval, oldtype, newval, newtype;

--- 1277 unchanged lines hidden (view full) ---

3518/* This should return an error not all definitions define functions.
3519 It is not an error if we find two functions with exactly the
3520 same signature, only if these are selected in overload resolution.
3521 old is the current set of bindings, new the freshly-found binding.
3522 XXX Do we want to give *all* candidates in case of ambiguity?
3523 XXX In what way should I treat extern declarations?
3524 XXX I don't want to repeat the entire duplicate_decls here */
3525
3526/* LLVM LOCAL begin mainline */
3494static void
3527static void
3495ambiguous_decl (tree name, struct scope_binding *old, cxx_binding *new,
3496 int flags)
3528ambiguous_decl (struct scope_binding *old, cxx_binding *new, int flags)
3497{
3498 tree val, type;
3499 gcc_assert (old != NULL);
3529{
3530 tree val, type;
3531 gcc_assert (old != NULL);
3532
3533 /* Copy the type. */
3534 type = new->type;
3535 if (LOOKUP_NAMESPACES_ONLY (flags)
3536 || (type && hidden_name_p (type) && !(flags & LOOKUP_HIDDEN)))
3537 type = NULL_TREE;
3538
3500 /* Copy the value. */
3501 val = new->value;
3502 if (val)
3539 /* Copy the value. */
3540 val = new->value;
3541 if (val)
3503 switch (TREE_CODE (val))
3504 {
3505 case TEMPLATE_DECL:
3506 /* If we expect types or namespaces, and not templates,
3507 or this is not a template class. */
3508 if ((LOOKUP_QUALIFIERS_ONLY (flags)
3509 && !DECL_CLASS_TEMPLATE_P (val))
3510 || hidden_name_p (val))
3511 val = NULL_TREE;
3512 break;
3513 case TYPE_DECL:
3514 if (LOOKUP_NAMESPACES_ONLY (flags) || hidden_name_p (val))
3515 val = NULL_TREE;
3516 break;
3517 case NAMESPACE_DECL:
3518 if (LOOKUP_TYPES_ONLY (flags))
3519 val = NULL_TREE;
3520 break;
3521 case FUNCTION_DECL:
3522 /* Ignore built-in functions that are still anticipated. */
3523 if (LOOKUP_QUALIFIERS_ONLY (flags) || hidden_name_p (val))
3524 val = NULL_TREE;
3525 break;
3526 default:
3527 if (LOOKUP_QUALIFIERS_ONLY (flags))
3528 val = NULL_TREE;
3529 }
3542 {
3543 if (hidden_name_p (val) && !(flags & LOOKUP_HIDDEN))
3544 val = NULL_TREE;
3545 else
3546 switch (TREE_CODE (val))
3547 {
3548 case TEMPLATE_DECL:
3549 /* If we expect types or namespaces, and not templates,
3550 or this is not a template class. */
3551 if ((LOOKUP_QUALIFIERS_ONLY (flags)
3552 && !DECL_CLASS_TEMPLATE_P (val)))
3553 val = NULL_TREE;
3554 break;
3555 case TYPE_DECL:
3556 if (LOOKUP_NAMESPACES_ONLY (flags)
3557 || (type && (flags & LOOKUP_PREFER_TYPES)))
3558 val = NULL_TREE;
3559 break;
3560 case NAMESPACE_DECL:
3561 if (LOOKUP_TYPES_ONLY (flags))
3562 val = NULL_TREE;
3563 break;
3564 case FUNCTION_DECL:
3565 /* Ignore built-in functions that are still anticipated. */
3566 if (LOOKUP_QUALIFIERS_ONLY (flags))
3567 val = NULL_TREE;
3568 break;
3569 default:
3570 if (LOOKUP_QUALIFIERS_ONLY (flags))
3571 val = NULL_TREE;
3572 }
3573 }
3530
3574
3575 /* If val is hidden, shift down any class or enumeration name. */
3576 if (!val)
3577 {
3578 val = type;
3579 type = NULL_TREE;
3580 }
3581
3582/* LLVM LOCAL end mainline */
3531 if (!old->value)
3532 old->value = val;
3533 else if (val && val != old->value)
3534 {
3535 if (is_overloaded_fn (old->value) && is_overloaded_fn (val))
3536 old->value = merge_functions (old->value, val);
3537 else
3538 {
3539 old->value = tree_cons (NULL_TREE, old->value,
3583 if (!old->value)
3584 old->value = val;
3585 else if (val && val != old->value)
3586 {
3587 if (is_overloaded_fn (old->value) && is_overloaded_fn (val))
3588 old->value = merge_functions (old->value, val);
3589 else
3590 {
3591 old->value = tree_cons (NULL_TREE, old->value,
3540 build_tree_list (NULL_TREE, new->value));
3592 build_tree_list (NULL_TREE, val));
3541 TREE_TYPE (old->value) = error_mark_node;
3542 }
3543 }
3593 TREE_TYPE (old->value) = error_mark_node;
3594 }
3595 }
3544 /* ... and copy the type. */
3545 type = new->type;
3546 if (LOOKUP_NAMESPACES_ONLY (flags))
3547 type = NULL_TREE;
3596
3597 /* LLVM LOCAL begin mainline */
3548 if (!old->type)
3549 old->type = type;
3550 else if (type && old->type != type)
3551 {
3598 if (!old->type)
3599 old->type = type;
3600 else if (type && old->type != type)
3601 {
3552 if (flags & LOOKUP_COMPLAIN)
3553 {
3554 error ("%qD denotes an ambiguous type",name);
3555 error ("%J first type here", TYPE_MAIN_DECL (old->type));
3556 error ("%J other type here", TYPE_MAIN_DECL (type));
3557 }
3602 old->type = tree_cons (NULL_TREE, old->type,
3603 build_tree_list (NULL_TREE, type));
3604 TREE_TYPE (old->type) = error_mark_node;
3558 }
3605 }
3606 /* LLVM LOCAL end mainline */
3559}
3560
3561/* Return the declarations that are members of the namespace NS. */
3562
3563tree
3564cp_namespace_decls (tree ns)
3565{
3566 return NAMESPACE_LEVEL (ns)->names;

--- 72 unchanged lines hidden (view full) ---

3639 n = build_overload (OVL_CURRENT (o), n);
3640 fns = n;
3641 }
3642 }
3643
3644 return fns;
3645}
3646
3607}
3608
3609/* Return the declarations that are members of the namespace NS. */
3610
3611tree
3612cp_namespace_decls (tree ns)
3613{
3614 return NAMESPACE_LEVEL (ns)->names;

--- 72 unchanged lines hidden (view full) ---

3687 n = build_overload (OVL_CURRENT (o), n);
3688 fns = n;
3689 }
3690 }
3691
3692 return fns;
3693}
3694
3647/* Select the right _DECL from multiple choices. */
3648
3649static tree
3650select_decl (const struct scope_binding *binding, int flags)
3651{
3652 tree val;
3653 val = binding->value;
3654
3655 timevar_push (TV_NAME_LOOKUP);
3656 if (LOOKUP_NAMESPACES_ONLY (flags))
3657 {
3658 /* We are not interested in types. */
3659 if (val && (TREE_CODE (val) == NAMESPACE_DECL
3660 || TREE_CODE (val) == TREE_LIST))
3661 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
3662 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, NULL_TREE);
3663 }
3664
3665 /* If looking for a type, or if there is no non-type binding, select
3666 the value binding. */
3667 if (binding->type && (!val || (flags & LOOKUP_PREFER_TYPES)))
3668 val = binding->type;
3669 /* Don't return non-types if we really prefer types. */
3670 else if (val && LOOKUP_TYPES_ONLY (flags)
3671 && ! DECL_DECLARES_TYPE_P (val))
3672 val = NULL_TREE;
3673
3674 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
3675}
3676
3677/* Unscoped lookup of a global: iterate over current namespaces,
3678 considering using-directives. */
3679
3680static tree
3681unqualified_namespace_lookup (tree name, int flags)
3682{
3683 tree initial = current_decl_namespace ();
3684 tree scope = initial;
3685 tree siter;
3686 struct cp_binding_level *level;
3687 tree val = NULL_TREE;
3695/* Unscoped lookup of a global: iterate over current namespaces,
3696 considering using-directives. */
3697
3698static tree
3699unqualified_namespace_lookup (tree name, int flags)
3700{
3701 tree initial = current_decl_namespace ();
3702 tree scope = initial;
3703 tree siter;
3704 struct cp_binding_level *level;
3705 tree val = NULL_TREE;
3688 struct scope_binding binding = EMPTY_SCOPE_BINDING;
3689
3690 timevar_push (TV_NAME_LOOKUP);
3691
3692 for (; !val; scope = CP_DECL_CONTEXT (scope))
3693 {
3706
3707 timevar_push (TV_NAME_LOOKUP);
3708
3709 for (; !val; scope = CP_DECL_CONTEXT (scope))
3710 {
3711 struct scope_binding binding = EMPTY_SCOPE_BINDING;
3694 cxx_binding *b =
3695 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3696
3697 if (b)
3712 cxx_binding *b =
3713 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3714
3715 if (b)
3698 {
3699 if (b->value
3700 && ((flags & LOOKUP_HIDDEN) || !hidden_name_p (b->value)))
3701 binding.value = b->value;
3702 binding.type = b->type;
3703 }
3716 /* LLVM LOCAL mainline */
3717 ambiguous_decl (&binding, b, flags);
3704
3705 /* Add all _DECLs seen through local using-directives. */
3706 for (level = current_binding_level;
3707 level->kind != sk_namespace;
3708 level = level->level_chain)
3709 if (!lookup_using_namespace (name, &binding, level->using_directives,
3710 scope, flags))
3711 /* Give up because of error. */

--- 8 unchanged lines hidden (view full) ---

3720 DECL_NAMESPACE_USING (siter),
3721 scope, flags))
3722 /* Give up because of error. */
3723 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
3724 if (siter == scope) break;
3725 siter = CP_DECL_CONTEXT (siter);
3726 }
3727
3718
3719 /* Add all _DECLs seen through local using-directives. */
3720 for (level = current_binding_level;
3721 level->kind != sk_namespace;
3722 level = level->level_chain)
3723 if (!lookup_using_namespace (name, &binding, level->using_directives,
3724 scope, flags))
3725 /* Give up because of error. */

--- 8 unchanged lines hidden (view full) ---

3734 DECL_NAMESPACE_USING (siter),
3735 scope, flags))
3736 /* Give up because of error. */
3737 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, error_mark_node);
3738 if (siter == scope) break;
3739 siter = CP_DECL_CONTEXT (siter);
3740 }
3741
3728 val = select_decl (&binding, flags);
3742 val = binding.value;
3729 if (scope == global_namespace)
3730 break;
3731 }
3732 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
3733}
3734
3735/* Look up NAME (an IDENTIFIER_NODE) in SCOPE (either a NAMESPACE_DECL
3736 or a class TYPE). If IS_TYPE_P is TRUE, then ignore non-type

--- 13 unchanged lines hidden (view full) ---

3750 if (TREE_CODE (scope) == NAMESPACE_DECL)
3751 {
3752 struct scope_binding binding = EMPTY_SCOPE_BINDING;
3753
3754 flags |= LOOKUP_COMPLAIN;
3755 if (is_type_p)
3756 flags |= LOOKUP_PREFER_TYPES;
3757 if (qualified_lookup_using_namespace (name, scope, &binding, flags))
3743 if (scope == global_namespace)
3744 break;
3745 }
3746 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val);
3747}
3748
3749/* Look up NAME (an IDENTIFIER_NODE) in SCOPE (either a NAMESPACE_DECL
3750 or a class TYPE). If IS_TYPE_P is TRUE, then ignore non-type

--- 13 unchanged lines hidden (view full) ---

3764 if (TREE_CODE (scope) == NAMESPACE_DECL)
3765 {
3766 struct scope_binding binding = EMPTY_SCOPE_BINDING;
3767
3768 flags |= LOOKUP_COMPLAIN;
3769 if (is_type_p)
3770 flags |= LOOKUP_PREFER_TYPES;
3771 if (qualified_lookup_using_namespace (name, scope, &binding, flags))
3758 t = select_decl (&binding, flags);
3772 t = binding.value;
3759 }
3760 else if (is_aggr_type (scope, complain))
3761 t = lookup_member (scope, name, 2, is_type_p);
3762
3763 if (!t)
3764 return error_mark_node;
3765 return t;
3766}

--- 16 unchanged lines hidden (view full) ---

3783 for (iter = usings; iter; iter = TREE_CHAIN (iter))
3784 if (TREE_VALUE (iter) == scope)
3785 {
3786 tree used = ORIGINAL_NAMESPACE (TREE_PURPOSE (iter));
3787 cxx_binding *val1 =
3788 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (used), name);
3789 /* Resolve ambiguities. */
3790 if (val1)
3773 }
3774 else if (is_aggr_type (scope, complain))
3775 t = lookup_member (scope, name, 2, is_type_p);
3776
3777 if (!t)
3778 return error_mark_node;
3779 return t;
3780}

--- 16 unchanged lines hidden (view full) ---

3797 for (iter = usings; iter; iter = TREE_CHAIN (iter))
3798 if (TREE_VALUE (iter) == scope)
3799 {
3800 tree used = ORIGINAL_NAMESPACE (TREE_PURPOSE (iter));
3801 cxx_binding *val1 =
3802 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (used), name);
3803 /* Resolve ambiguities. */
3804 if (val1)
3791 ambiguous_decl (name, val, val1, flags);
3805 /* LLVM LOCAL mainline */
3806 ambiguous_decl (val, val1, flags);
3792 }
3793 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val->value != error_mark_node);
3794}
3795
3796/* [namespace.qual]
3797 Accepts the NAME to lookup and its qualifying SCOPE.
3798 Returns the name/type pair found into the cxx_binding *RESULT,
3799 or false on error. */

--- 12 unchanged lines hidden (view full) ---

3812 /* Look through namespace aliases. */
3813 scope = ORIGINAL_NAMESPACE (scope);
3814 while (scope && result->value != error_mark_node)
3815 {
3816 cxx_binding *binding =
3817 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3818 seen = tree_cons (scope, NULL_TREE, seen);
3819 if (binding)
3807 }
3808 POP_TIMEVAR_AND_RETURN (TV_NAME_LOOKUP, val->value != error_mark_node);
3809}
3810
3811/* [namespace.qual]
3812 Accepts the NAME to lookup and its qualifying SCOPE.
3813 Returns the name/type pair found into the cxx_binding *RESULT,
3814 or false on error. */

--- 12 unchanged lines hidden (view full) ---

3827 /* Look through namespace aliases. */
3828 scope = ORIGINAL_NAMESPACE (scope);
3829 while (scope && result->value != error_mark_node)
3830 {
3831 cxx_binding *binding =
3832 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3833 seen = tree_cons (scope, NULL_TREE, seen);
3834 if (binding)
3820 ambiguous_decl (name, result, binding, flags);
3835 /* LLVM LOCAL mainline */
3836 ambiguous_decl (result, binding, flags);
3821
3822 /* Consider strong using directives always, and non-strong ones
3823 if we haven't found a binding yet. ??? Shouldn't we consider
3824 non-strong ones if the initial RESULT is non-NULL, but the
3825 binding in the given namespace is? */
3826 for (usings = DECL_NAMESPACE_USING (scope); usings;
3827 usings = TREE_CHAIN (usings))
3828 /* If this was a real directive, and we have not seen it. */

--- 1382 unchanged lines hidden ---
3837
3838 /* Consider strong using directives always, and non-strong ones
3839 if we haven't found a binding yet. ??? Shouldn't we consider
3840 non-strong ones if the initial RESULT is non-NULL, but the
3841 binding in the given namespace is? */
3842 for (usings = DECL_NAMESPACE_USING (scope); usings;
3843 usings = TREE_CHAIN (usings))
3844 /* If this was a real directive, and we have not seen it. */

--- 1382 unchanged lines hidden ---