Lines Matching defs:scope

36 /* The bindings for a particular name in a particular scope.  */
110 a given scope. */
292 binding->scope = NULL;
298 bindings) in the class scope indicated by SCOPE. */
301 new_class_binding (tree name, tree value, tree type, cxx_scope *scope)
306 if (VEC_length (cp_class_binding, scope->class_shadowed))
309 old_base = VEC_index (cp_class_binding, scope->class_shadowed, 0);
310 if (VEC_reserve (cp_class_binding, gc, scope->class_shadowed, 1))
316 VEC_iterate (cp_class_binding, scope->class_shadowed, i, cb);
326 cb = VEC_quick_push (cp_class_binding, scope->class_shadowed, NULL);
329 cb = VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, NULL);
333 binding->scope = scope;
349 binding->scope = level;
404 /* BINDING records an existing declaration for a name in the current scope.
406 same scope. This is the `struct stat' hack whereby a non-typedef
412 name of an object, function, or enumerator declared in the same scope.
414 are declared in the same scope (in any order) with the same name, the
437 in a non-class scope prior declaration. In that case,
462 && binding->scope->kind != sk_class
473 In a given scope, a typedef specifier can be used to redefine
474 the name of any type declared in that scope to refer to the
481 /* There can be two block-scope declarations of the same variable,
555 /* Record a decl-node X as belonging to the current lexical scope.
557 name already seen in the same scope). IS_FRIEND is true if X is
589 scope of the current namespace, not the current
595 /* If this is the declaration for a namespace-scope function,
596 but the declaration itself is in a local scope, mark the
622 declared outside the innermost enclosing namespace scope, the
623 block scope declaration declares that same entity and
629 /* Look in block scope. */
932 and no file-scope declaration has yet been seen,
933 then if we later have a file-scope decl it must not be static. */
1030 /* Record a decl-node X as belonging to the current lexical scope. */
1047 from another scope, e.g. a static member variable. TEM may equal
1106 in scope under the ARM, but is not in scope under the ANSI/ISO
1117 /* We only care about out of scope variables. */
1189 cxx_scope_descriptor (cxx_scope *scope)
1194 "block-scope",
1195 "cleanup-scope",
1196 "try-scope",
1197 "catch-scope",
1198 "for-scope",
1199 "function-parameter-scope",
1200 "class-scope",
1201 "namespace-scope",
1202 "template-parameter-scope",
1203 "template-explicit-spec-scope"
1205 const scope_kind kind = scope->explicit_spec_p
1206 ? sk_template_spec : scope->kind;
1214 cxx_scope_debug (cxx_scope *scope, int line, const char *action)
1216 const char *desc = cxx_scope_descriptor (scope);
1217 if (scope->this_entity)
1219 scope->this_entity, (void *) scope, line);
1221 verbatim ("%s %s %p %d\n", action, desc, (void *) scope, line);
1225 scope. */
1246 push_binding_level (struct cp_binding_level *scope)
1249 scope->level_chain = current_binding_level;
1250 current_binding_level = scope;
1255 scope->binding_depth = binding_depth;
1257 cxx_scope_debug (scope, input_line, "push");
1263 /* Create a new KIND scope and make it the top of the active scopes stack.
1264 ENTITY is the scope of the associated C++ entity (namespace, class,
1270 cxx_scope *scope;
1275 scope = free_binding_level;
1276 free_binding_level = scope->level_chain;
1279 scope = GGC_NEW (cxx_scope);
1280 memset (scope, 0, sizeof (cxx_scope));
1282 scope->this_entity = entity;
1283 scope->more_cleanups_ok = true;
1287 scope->keep = true;
1291 scope->explicit_spec_p = true;
1302 scope->keep = keep_next_level_flag;
1306 NAMESPACE_LEVEL (entity) = scope;
1307 scope->static_decls =
1319 scope->kind = kind;
1321 push_binding_level (scope);
1323 return scope;
1326 /* We're about to leave current scope. Pop the top of the stack of
1327 currently active scopes. Return the enclosing scope, now active. */
1332 cxx_scope *scope = current_binding_level;
1334 if (scope->kind == sk_namespace && class_binding_level)
1337 /* We cannot leave a scope, if there are none left. */
1339 gcc_assert (!global_scope_p (scope));
1344 cxx_scope_debug (scope, input_line, "leave");
1345 if (is_class_level != (scope == class_binding_level))
1354 if (scope->has_visibility)
1359 current_binding_level = scope->level_chain;
1366 if (scope->kind != sk_namespace
1367 && scope->kind != sk_class)
1369 scope->level_chain = free_binding_level;
1371 || scope->binding_depth == binding_depth);
1372 free_binding_level = scope;
1375 /* Find the innermost enclosing class scope, and reset
1377 if (scope->kind == sk_class)
1380 for (scope = current_binding_level; scope; scope = scope->level_chain)
1381 if (scope->kind == sk_class)
1383 class_binding_level = scope;
1410 /* Return the innermost binding level that is not for a class scope. */
1426 scope, create a new binding level. */
1462 /* True if this is a namespace scope, or if we are defining a class
1463 which is itself at namespace scope, or whose enclosing class is
1485 /* Returns the kind of the innermost scope. */
1493 /* Returns true if this scope was created to store template parameters. */
1766 find_binding (cxx_scope *scope, cxx_binding *binding)
1771 if (binding->scope == scope)
1780 cxx_scope_find_binding_for_name (cxx_scope *scope, tree name)
1786 if (scope == b->scope && b->previous == NULL)
1788 return find_binding (scope, b);
1793 /* Always returns a binding for name in scope. If no binding is
1797 binding_for_name (cxx_scope *scope, tree name)
1801 result = cxx_scope_find_binding_for_name (scope, name);
1807 result->scope = scope;
1816 return NULL_TREE if this not in namespace scope (in namespace
1817 scope, a using decl might extend any previous bindings). */
1820 push_using_decl (tree scope, tree name)
1825 gcc_assert (TREE_CODE (scope) == NAMESPACE_DECL);
1828 if (USING_DECL_SCOPE (decl) == scope && DECL_NAME (decl) == name)
1834 USING_DECL_SCOPE (decl) = scope;
1879 PUSH_LOCAL: Bind DECL in the current scope, rather than at
1880 namespace scope.
1989 for (d = &IDENTIFIER_BINDING (name)->scope->names;
2020 /* Check a non-member using-declaration. Return the name and scope
2024 validate_nonmember_using_decl (tree decl, tree scope, tree name)
2029 if (TYPE_P (scope))
2031 error ("%qT is not a namespace", scope);
2034 else if (scope == error_mark_node)
2054 /* It's a nested name with template parameter dependent scope.
2066 return push_using_decl (scope, name);
2072 do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
2078 if (!qualified_lookup_using_namespace (name, scope, &decls, 0))
2105 error ("%qD is already declared in this scope", name);
2116 If a function declaration in namespace scope or block
2117 scope has the same name and the same parameter types as a
2136 this scope with the same parameter types. If both
2142 error ("%qD is already declared in this scope", name);
2150 scope. */
2176 error ("%qD is already declared in this scope", name);
2188 /* Process a using-declaration at function scope. */
2191 do_local_using_decl (tree decl, tree scope, tree name)
2196 decl = validate_nonmember_using_decl (decl, scope, name);
2207 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
2274 /* Enter the class or namespace scope indicated by T suitable for name
2275 lookup. T can be arbitrary scope, not necessary nested inside the
2276 current scope. Returns a non-null scope to pop iff pop_scope
2277 should be called later to exit this scope. */
2290 /* T is the same as the current scope. There is therefore no
2291 need to re-enter the scope. Since we are not actually
2292 pushing a new scope, our caller should not call
2300 /* Leave scope pushed by push_scope. */
2354 /* Enter the scope INNER from current scope. INNER must be a scope
2355 nested inside current scope. This works with both name lookup and
2356 pushing name into scope. In case a template parameter scope is present,
2357 namespace is pushed under the template parameter scope according to
2360 Return the former current scope suitable for pop_inner_scope. */
2373 /* Exit the current scope INNER back to scope OUTER. */
2502 /* Make the declaration of X appear in CLASS scope. */
2543 scope. If the value returned is non-NULL, and the PREVIOUS field
2547 get_class_binding (tree name, cxx_scope *scope)
2554 class_type = scope->this_entity;
2592 scope);
2593 /* This is a class-scope binding, not a block-scope binding. */
2603 /* Make the declaration(s) of X appear in CLASS scope under the name
2659 tree scope = context_for_name_lookup (x);
2660 if (TYPE_P (scope) && same_type_p (scope, current_class_type))
2671 if (!binding || binding->scope != class_binding_level)
2722 if (old_decl && binding->scope == class_binding_level)
2741 if (binding && binding->scope == class_binding_level)
2754 /* Process "using SCOPE::NAME" in a class scope. Return the
2758 do_class_using_decl (tree scope, tree name)
2779 if (!scope || !TYPE_P (scope))
2781 error ("using-declaration for non-member at class scope");
2788 error ("%<%T::%D%> names destructor", scope, name);
2791 if (constructor_name_p (name, scope))
2793 error ("%<%T::%D%> names constructor", scope, name);
2799 scope, name, current_class_type);
2803 scope_dependent_p = dependent_type_p (scope);
2834 binfo = lookup_base (current_class_type, scope, ba_any, &b_kind);
2839 error_not_base_type (scope, current_class_type);
2848 error ("no members matching %<%T::%D%> in %q#T", scope, name,
2849 scope);
2860 USING_DECL_SCOPE (value) = scope;
2868 /* Return the binding value for name in scope. */
2871 namespace_binding (tree name, tree scope)
2875 if (scope == NULL)
2876 scope = global_namespace;
2879 scope = ORIGINAL_NAMESPACE (scope);
2881 binding = cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
2886 /* Set the binding value for name in scope. */
2889 set_namespace_binding (tree name, tree scope, tree val)
2894 if (scope == NULL_TREE)
2895 scope = global_namespace;
2896 b = binding_for_name (NAMESPACE_LEVEL (scope), name);
2904 /* Set the context of a declaration to scope. Complain if we are not
2905 outside scope. */
2908 set_decl_namespace (tree decl, tree scope, bool friendp)
2913 scope = ORIGINAL_NAMESPACE (scope);
2916 if (!friendp && !is_ancestor (current_namespace, scope))
2918 decl, scope);
2919 DECL_CONTEXT (decl) = FROB_CONTEXT (scope);
2922 if (scope == current_namespace)
2931 old = lookup_qualified_name (scope, DECL_NAME (decl), false, true);
2944 if (!is_associated_namespace (scope, CP_DECL_CONTEXT (fn)))
2968 error ("%qD should have been declared inside %qD", decl, scope);
2990 /* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we
3013 nor if NAME designates the global namespace: The global scope is
3109 /* Pop from the scope of the current namespace. */
3120 /* Push into the scope of the namespace NS, even if it is deeply
3135 /* Pop back from the scope of the namespace NS, which was previously
3302 /* Process a using-declaration not appearing in class or local scope. */
3305 do_toplevel_using_decl (tree decl, tree scope, tree name)
3311 decl = validate_nonmember_using_decl (decl, scope, name);
3320 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
3383 error ("strong using only meaningful at namespace scope");
3399 /* Like pushdecl, only it places X in the global scope if appropriate.
3415 /* Like pushdecl, only it places X in the global scope if appropriate. */
3431 /* Like pushdecl, only it places X in the global scope if
3675 tree scope = initial;
3683 for (; !val; scope = CP_DECL_CONTEXT (scope))
3686 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3701 scope, flags))
3712 scope, flags))
3715 if (siter == scope) break;
3720 if (scope == global_namespace)
3736 lookup_qualified_name (tree scope, tree name, bool is_type_p, bool complain)
3741 if (TREE_CODE (scope) == NAMESPACE_DECL)
3748 if (qualified_lookup_using_namespace (name, scope, &binding, flags))
3751 else if (is_aggr_type (scope, complain))
3752 t = lookup_member (scope, name, 2, is_type_p);
3763 which have SCOPE as a common ancestor with the current scope.
3768 tree usings, tree scope, int flags)
3773 directives of scope. */
3775 if (TREE_VALUE (iter) == scope)
3793 qualified_lookup_using_namespace (tree name, tree scope,
3804 scope = ORIGINAL_NAMESPACE (scope);
3805 while (scope && result->value != error_mark_node)
3808 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3809 seen = tree_cons (scope, NULL_TREE, seen);
3817 for (usings = DECL_NAMESPACE_USING (scope); usings;
3827 if (is_associated_namespace (scope, TREE_PURPOSE (usings))
3840 scope = TREE_PURPOSE (todo);
3846 scope = TREE_PURPOSE (todo_maybe);
3851 scope = NULL_TREE; /* If there never was a todo list. */
3856 /* Return the innermost non-namespace binding for NAME from a scope
3857 containing BINDING, or, if BINDING is NULL, the current scope. If
3866 cxx_scope *scope;
3871 scope = binding->scope->level_chain;
3876 scope = current_binding_level;
3879 outer_scope = outer ? outer->scope : NULL;
3883 between the LAST_BINDING_LEVEL and the scope in which OUTER was
3886 while (scope && scope != outer_scope && scope->kind != sk_namespace)
3888 if (scope->kind == sk_class)
3892 class_binding = get_class_binding (name, scope);
3895 /* Thread this new class-scope binding onto the
3906 scope = scope->level_chain;
3912 /* Return the innermost block-scope or class-scope value binding for
3961 scope. */
4006 /* A non namespace-scope binding can only be hidden if
4031 scope. For a friend class declaration, if there is no
4033 belongs to the innermost enclosing non-class scope,
4036 provided in the innermost enclosing nonclass scope.
4044 current scope, which is not the case here. */
4096 scope is encountered.
4099 declared in the desired scope, not from inheritance, nor using
4108 lookup_type_scope (tree name, tag_scope scope)
4115 /* Look in non-namespace scope first. */
4131 && (scope != ts_current
4133 || DECL_CONTEXT (iter->type) == iter->scope->this_entity))
4135 else if ((scope != ts_current
4144 /* Look in namespace scope. */
4168 if (iter->scope == b)
4174 && scope == ts_within_enclosing_non_class)
4211 if (binding->scope == b
4317 is_associated_namespace (tree current, tree scope)
4324 if (scope == current)
4326 seen = tree_cons (scope, NULL_TREE, seen);
4327 for (t = DECL_NAMESPACE_ASSOCIATIONS (scope); t; t = TREE_CHAIN (t))
4332 scope = TREE_PURPOSE (todo);
4391 arg_assoc_namespace (struct arg_lookup *k, tree scope)
4395 if (purpose_member (scope, k->namespaces))
4397 k->namespaces = tree_cons (scope, NULL_TREE, k->namespaces);
4400 for (value = DECL_NAMESPACE_ASSOCIATIONS (scope); value;
4405 value = namespace_binding (k->name, scope);
4785 /* If this new type is being injected into a containing scope,
4802 scope, and we're not looking at a friend, push the
4803 declaration of the member class into the class scope. In the
4805 friend into global scope, if appropriate. */
4834 The pushed scope depend on the SCOPE parameter:
4836 scope.
4838 non-template-parameter scope. This case is needed for forward
4847 pushtag (tree name, tree type, tag_scope scope)
4862 && (b->explicit_spec_p || scope == ts_global))
4864 && (scope != ts_current
4885 if (scope == ts_current)
4889 to inject the newly named class into the scope
4891 scope. */
4907 if (scope == ts_within_enclosing_non_class)
4918 (type, scope == ts_within_enclosing_non_class, b);
4985 scope isn't enough, because more binding levels may be pushed. */
5074 /* Have to include the global scope, because class-scope decls