Lines Matching refs:scope

36 /* The bindings for a particular name in a particular scope.  */
127 a given scope. */
309 binding->scope = NULL;
315 bindings) in the class scope indicated by SCOPE. */
318 new_class_binding (tree name, tree value, tree type, cxx_scope *scope)
323 cb = VEC_safe_push (cp_class_binding, gc, scope->class_shadowed, NULL);
327 binding->scope = scope;
342 binding->scope = level;
399 /* BINDING records an existing declaration for a name in the current scope.
401 same scope. This is the `struct stat' hack whereby a non-typedef
407 name of an object, function, or enumerator declared in the same scope.
409 are declared in the same scope (in any order) with the same name, the
432 in a non-class scope prior declaration. In that case,
457 && binding->scope->kind != sk_class
468 In a given scope, a typedef specifier can be used to redefine
469 the name of any type declared in that scope to refer to the
476 /* There can be two block-scope declarations of the same variable,
550 /* Record a decl-node X as belonging to the current lexical scope.
552 name already seen in the same scope). IS_FRIEND is true if X is
584 scope of the current namespace, not the current
590 /* If this is the declaration for a namespace-scope function,
591 but the declaration itself is in a local scope, mark the
617 declared outside the innermost enclosing namespace scope, the
618 block scope declaration declares that same entity and
624 /* Look in block scope. */
927 and no file-scope declaration has yet been seen,
928 then if we later have a file-scope decl it must not be static. */
1025 /* Record a decl-node X as belonging to the current lexical scope. */
1042 from another scope, e.g. a static member variable. TEM may equal
1101 in scope under the ARM, but is not in scope under the ANSI/ISO
1112 /* We only care about out of scope variables. */
1184 cxx_scope_descriptor (cxx_scope *scope)
1189 "block-scope",
1190 "cleanup-scope",
1191 "try-scope",
1192 "catch-scope",
1193 "for-scope",
1194 "function-parameter-scope",
1195 "class-scope",
1196 "namespace-scope",
1197 "template-parameter-scope",
1198 "template-explicit-spec-scope"
1200 const scope_kind kind = scope->explicit_spec_p
1201 ? sk_template_spec : scope->kind;
1209 cxx_scope_debug (cxx_scope *scope, int line, const char *action)
1211 const char *desc = cxx_scope_descriptor (scope);
1212 if (scope->this_entity)
1214 scope->this_entity, (void *) scope, line);
1216 verbatim ("%s %s %p %d\n", action, desc, (void *) scope, line);
1220 scope. */
1241 push_binding_level (struct cp_binding_level *scope)
1244 scope->level_chain = current_binding_level;
1245 current_binding_level = scope;
1250 scope->binding_depth = binding_depth;
1252 cxx_scope_debug (scope, input_line, "push");
1258 /* Create a new KIND scope and make it the top of the active scopes stack.
1259 ENTITY is the scope of the associated C++ entity (namespace, class,
1265 cxx_scope *scope;
1270 scope = free_binding_level;
1271 free_binding_level = scope->level_chain;
1274 scope = GGC_NEW (cxx_scope);
1275 memset (scope, 0, sizeof (cxx_scope));
1277 scope->this_entity = entity;
1278 scope->more_cleanups_ok = true;
1282 scope->keep = true;
1286 scope->explicit_spec_p = true;
1297 scope->keep = keep_next_level_flag;
1301 NAMESPACE_LEVEL (entity) = scope;
1302 scope->static_decls =
1314 scope->kind = kind;
1316 push_binding_level (scope);
1318 return scope;
1321 /* We're about to leave current scope. Pop the top of the stack of
1322 currently active scopes. Return the enclosing scope, now active. */
1327 cxx_scope *scope = current_binding_level;
1329 if (scope->kind == sk_namespace && class_binding_level)
1332 /* We cannot leave a scope, if there are none left. */
1334 gcc_assert (!global_scope_p (scope));
1339 cxx_scope_debug (scope, input_line, "leave");
1340 if (is_class_level != (scope == class_binding_level))
1349 if (scope->has_visibility)
1354 current_binding_level = scope->level_chain;
1361 if (scope->kind != sk_namespace
1362 && scope->kind != sk_class)
1364 scope->level_chain = free_binding_level;
1366 || scope->binding_depth == binding_depth);
1367 free_binding_level = scope;
1370 /* Find the innermost enclosing class scope, and reset
1372 if (scope->kind == sk_class)
1375 for (scope = current_binding_level; scope; scope = scope->level_chain)
1376 if (scope->kind == sk_class)
1378 class_binding_level = scope;
1405 /* Return the innermost binding level that is not for a class scope. */
1421 scope, create a new binding level. */
1457 /* True if this is a namespace scope, or if we are defining a class
1458 which is itself at namespace scope, or whose enclosing class is
1480 /* Returns the kind of the innermost scope. */
1488 /* Returns true if this scope was created to store template parameters. */
1761 find_binding (cxx_scope *scope, cxx_binding *binding)
1766 if (binding->scope == scope)
1775 cxx_scope_find_binding_for_name (cxx_scope *scope, tree name)
1781 if (scope == b->scope && b->previous == NULL)
1783 return find_binding (scope, b);
1788 /* Always returns a binding for name in scope. If no binding is
1792 binding_for_name (cxx_scope *scope, tree name)
1796 result = cxx_scope_find_binding_for_name (scope, name);
1802 result->scope = scope;
1813 return NULL_TREE if this not in namespace scope (in namespace
1814 scope, a using decl might extend any previous bindings). */
1817 push_using_decl (tree scope, tree name)
1822 gcc_assert (TREE_CODE (scope) == NAMESPACE_DECL);
1825 if (USING_DECL_SCOPE (decl) == scope && DECL_NAME (decl) == name)
1831 USING_DECL_SCOPE (decl) = scope;
1876 PUSH_LOCAL: Bind DECL in the current scope, rather than at
1877 namespace scope.
1986 for (d = &IDENTIFIER_BINDING (name)->scope->names;
2017 /* Check a non-member using-declaration. Return the name and scope
2021 validate_nonmember_using_decl (tree decl, tree scope, tree name)
2026 if (TYPE_P (scope))
2028 error ("%qT is not a namespace", scope);
2031 else if (scope == error_mark_node)
2051 /* It's a nested name with template parameter dependent scope.
2063 return push_using_decl (scope, name);
2069 do_nonmember_using_decl (tree scope, tree name, tree oldval, tree oldtype,
2075 if (!qualified_lookup_using_namespace (name, scope, &decls, 0))
2120 error ("%qD is already declared in this scope", name);
2131 If a function declaration in namespace scope or block
2132 scope has the same name and the same parameter types as a
2151 this scope with the same parameter types. If both
2157 error ("%qD is already declared in this scope", name);
2165 scope. */
2191 error ("%qD is already declared in this scope", name);
2206 error ("%qD is already declared in this scope", name);
2218 /* Process a using-declaration at function scope. */
2221 do_local_using_decl (tree decl, tree scope, tree name)
2226 decl = validate_nonmember_using_decl (decl, scope, name);
2237 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
2304 /* Enter the class or namespace scope indicated by T suitable for name
2305 lookup. T can be arbitrary scope, not necessary nested inside the
2306 current scope. Returns a non-null scope to pop iff pop_scope
2307 should be called later to exit this scope. */
2320 /* T is the same as the current scope. There is therefore no
2321 need to re-enter the scope. Since we are not actually
2322 pushing a new scope, our caller should not call
2330 /* Leave scope pushed by push_scope. */
2384 /* Enter the scope INNER from current scope. INNER must be a scope
2385 nested inside current scope. This works with both name lookup and
2386 pushing name into scope. In case a template parameter scope is present,
2387 namespace is pushed under the template parameter scope according to
2390 Return the former current scope suitable for pop_inner_scope. */
2403 /* Exit the current scope INNER back to scope OUTER. */
2535 /* Make the declaration of X appear in CLASS scope. */
2576 scope. If the value returned is non-NULL, and the PREVIOUS field
2580 get_class_binding (tree name, cxx_scope *scope)
2587 class_type = scope->this_entity;
2625 scope);
2626 /* This is a class-scope binding, not a block-scope binding. */
2636 /* Make the declaration(s) of X appear in CLASS scope under the name
2692 tree scope = context_for_name_lookup (x);
2693 if (TYPE_P (scope) && same_type_p (scope, current_class_type))
2704 if (!binding || binding->scope != class_binding_level)
2755 if (old_decl && binding->scope == class_binding_level)
2774 if (binding && binding->scope == class_binding_level)
2787 /* Process "using SCOPE::NAME" in a class scope. Return the
2791 do_class_using_decl (tree scope, tree name)
2812 if (!scope || !TYPE_P (scope))
2814 error ("using-declaration for non-member at class scope");
2821 error ("%<%T::%D%> names destructor", scope, name);
2824 if (constructor_name_p (name, scope))
2826 error ("%<%T::%D%> names constructor", scope, name);
2832 scope, name, current_class_type);
2836 scope_dependent_p = dependent_type_p (scope);
2867 binfo = lookup_base (current_class_type, scope, ba_any, &b_kind);
2872 error_not_base_type (scope, current_class_type);
2881 error ("no members matching %<%T::%D%> in %q#T", scope, name,
2882 scope);
2893 USING_DECL_SCOPE (value) = scope;
2901 /* Return the binding value for name in scope. */
2904 namespace_binding (tree name, tree scope)
2908 if (scope == NULL)
2909 scope = global_namespace;
2912 scope = ORIGINAL_NAMESPACE (scope);
2914 binding = cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
2919 /* Set the binding value for name in scope. */
2922 set_namespace_binding (tree name, tree scope, tree val)
2927 if (scope == NULL_TREE)
2928 scope = global_namespace;
2929 b = binding_for_name (NAMESPACE_LEVEL (scope), name);
2937 /* Set the context of a declaration to scope. Complain if we are not
2938 outside scope. */
2941 set_decl_namespace (tree decl, tree scope, bool friendp)
2946 scope = ORIGINAL_NAMESPACE (scope);
2949 if (!friendp && !is_ancestor (current_namespace, scope))
2951 decl, scope);
2952 DECL_CONTEXT (decl) = FROB_CONTEXT (scope);
2955 if (scope == current_namespace)
2964 old = lookup_qualified_name (scope, DECL_NAME (decl), false, true);
2977 if (!is_associated_namespace (scope, CP_DECL_CONTEXT (fn)))
3001 error ("%qD should have been declared inside %qD", decl, scope);
3023 /* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we
3046 nor if NAME designates the global namespace: The global scope is
3138 /* Pop from the scope of the current namespace. */
3149 /* Push into the scope of the namespace NS, even if it is deeply
3164 /* Pop back from the scope of the namespace NS, which was previously
3331 /* Process a using-declaration not appearing in class or local scope. */
3334 do_toplevel_using_decl (tree decl, tree scope, tree name)
3340 decl = validate_nonmember_using_decl (decl, scope, name);
3349 do_nonmember_using_decl (scope, name, oldval, oldtype, &newval, &newtype);
3412 error ("strong using only meaningful at namespace scope");
3428 /* Like pushdecl, only it places X in the global scope if appropriate.
3444 /* Like pushdecl, only it places X in the global scope if appropriate. */
3460 /* Like pushdecl, only it places X in the global scope if
3690 tree scope = initial;
3697 for (; !val; scope = CP_DECL_CONTEXT (scope))
3701 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3712 scope, flags))
3723 scope, flags))
3726 if (siter == scope) break;
3731 if (scope == global_namespace)
3747 lookup_qualified_name (tree scope, tree name, bool is_type_p, bool complain)
3752 if (TREE_CODE (scope) == NAMESPACE_DECL)
3759 if (qualified_lookup_using_namespace (name, scope, &binding, flags))
3762 else if (is_aggr_type (scope, complain))
3763 t = lookup_member (scope, name, 2, is_type_p);
3774 which have SCOPE as a common ancestor with the current scope.
3779 tree usings, tree scope, int flags)
3784 directives of scope. */
3786 if (TREE_VALUE (iter) == scope)
3805 qualified_lookup_using_namespace (tree name, tree scope,
3816 scope = ORIGINAL_NAMESPACE (scope);
3817 while (scope && result->value != error_mark_node)
3820 cxx_scope_find_binding_for_name (NAMESPACE_LEVEL (scope), name);
3821 seen = tree_cons (scope, NULL_TREE, seen);
3830 for (usings = DECL_NAMESPACE_USING (scope); usings;
3840 if (is_associated_namespace (scope, TREE_PURPOSE (usings))
3853 scope = TREE_PURPOSE (todo);
3859 scope = TREE_PURPOSE (todo_maybe);
3864 scope = NULL_TREE; /* If there never was a todo list. */
3869 /* Return the innermost non-namespace binding for NAME from a scope
3870 containing BINDING, or, if BINDING is NULL, the current scope. If
3879 cxx_scope *scope;
3884 scope = binding->scope->level_chain;
3889 scope = current_binding_level;
3892 outer_scope = outer ? outer->scope : NULL;
3896 between the LAST_BINDING_LEVEL and the scope in which OUTER was
3899 while (scope && scope != outer_scope && scope->kind != sk_namespace)
3901 if (scope->kind == sk_class)
3905 class_binding = get_class_binding (name, scope);
3908 /* Thread this new class-scope binding onto the
3919 scope = scope->level_chain;
3925 /* Return the innermost block-scope or class-scope value binding for
3974 scope. */
4019 /* A non namespace-scope binding can only be hidden if
4044 scope. For a friend class declaration, if there is no
4046 belongs to the innermost enclosing non-class scope,
4049 provided in the innermost enclosing nonclass scope.
4057 current scope, which is not the case here. */
4109 scope is encountered.
4112 declared in the desired scope, not from inheritance, nor using
4121 lookup_type_scope (tree name, tag_scope scope)
4128 /* Look in non-namespace scope first. */
4144 && (scope != ts_current
4146 || DECL_CONTEXT (iter->type) == iter->scope->this_entity))
4148 else if ((scope != ts_current
4157 /* Look in namespace scope. */
4181 if (iter->scope == b)
4187 && scope == ts_within_enclosing_non_class)
4224 if (binding->scope == b
4330 is_associated_namespace (tree current, tree scope)
4337 if (scope == current)
4339 seen = tree_cons (scope, NULL_TREE, seen);
4340 for (t = DECL_NAMESPACE_ASSOCIATIONS (scope); t; t = TREE_CHAIN (t))
4345 scope = TREE_PURPOSE (todo);
4404 arg_assoc_namespace (struct arg_lookup *k, tree scope)
4408 if (purpose_member (scope, k->namespaces))
4410 k->namespaces = tree_cons (scope, NULL_TREE, k->namespaces);
4413 for (value = DECL_NAMESPACE_ASSOCIATIONS (scope); value;
4418 value = namespace_binding (k->name, scope);
4800 /* If this new type is being injected into a containing scope,
4817 scope, and we're not looking at a friend, push the
4818 declaration of the member class into the class scope. In the
4820 friend into global scope, if appropriate. */
4849 The pushed scope depend on the SCOPE parameter:
4851 scope.
4853 non-template-parameter scope. This case is needed for forward
4862 pushtag (tree name, tree type, tag_scope scope)
4877 && (b->explicit_spec_p || scope == ts_global))
4879 && (scope != ts_current
4900 if (scope == ts_current)
4904 to inject the newly named class into the scope
4906 scope. */
4922 if (scope == ts_within_enclosing_non_class)
4933 (type, scope == ts_within_enclosing_non_class, b);
5000 scope isn't enough, because more binding levels may be pushed. */
5089 /* Have to include the global scope, because class-scope decls