cp-tree.h (binding_for_name): Move to name-lookup.h Adjust prototype.
[gcc.git] / gcc / cp / name-lookup.h
1 /* Declarations for C++ name lookup routines.
2 Copyright (C) 2003 Free Software Foundation, Inc.
3 Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
4
5 This file is part of GCC.
6
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #ifndef GCC_CP_NAME_LOOKUP_H
23 #define GCC_CP_NAME_LOOKUP_H
24
25 #include "c-common.h"
26
27 /* Datatype used to temporarily save C++ bindings (for implicit
28 instantiations purposes and like). Implemented in decl.c. */
29 typedef struct cxx_saved_binding cxx_saved_binding;
30
31 /* Datatype that represents binding established by a declaration between
32 a name and a C++ entity. */
33 typedef struct cxx_binding cxx_binding;
34
35 /* The datatype used to implement C++ scope. */
36 typedef struct cp_binding_level cxx_scope;
37
38 /* Nonzero if this binding is for a local scope, as opposed to a class
39 or namespace scope. */
40 #define LOCAL_BINDING_P(NODE) ((NODE)->is_local)
41
42 /* Nonzero if BINDING_VALUE is from a base class of the class which is
43 currently being defined. */
44 #define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited)
45
46 /* For a binding between a name and an entity at a non-local scope,
47 defines the scope where the binding is declared. (Either a class
48 _TYPE node, or a NAMESPACE_DECL.). */
49 #define BINDING_SCOPE(NODE) ((NODE)->scope)
50
51 /* This is the declaration bound to the name. Possible values:
52 variable, overloaded function, namespace, template, enumerator. */
53 #define BINDING_VALUE(NODE) ((NODE)->value)
54
55 /* If name is bound to a type, this is the type (struct, union, enum). */
56 #define BINDING_TYPE(NODE) ((NODE)->type)
57
58 /* Zero out a cxx_binding pointed to by B. */
59 #define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding))
60
61 struct cxx_binding GTY(())
62 {
63 /* Link to chain together various bindings for this name. */
64 cxx_binding *previous;
65 /* The non-type entity this name is bound to. */
66 tree value;
67 /* The type entity this name is bound to. */
68 tree type;
69 /* The scope at which this binding was made. */
70 cxx_scope *scope;
71 unsigned value_is_inherited : 1;
72 unsigned is_local : 1;
73 };
74
75 extern cxx_binding *cxx_binding_make (tree, tree);
76 extern void cxx_binding_free (cxx_binding *);
77 \f
78
79 extern cxx_binding *cxx_scope_find_binding_for_name (cxx_scope *, tree);
80 extern cxx_binding *binding_for_name (cxx_scope *, tree);
81 \f
82 extern tree namespace_binding (tree, tree);
83 extern void set_namespace_binding (tree, tree, tree);
84
85 #endif /* GCC_CP_NAME_LOOKUP_H */