name-lookup.c: New file.
* name-lookup.c: New file. * name-lookup.h: Likewise.. * decl.c (push_binding): Adjust use cxx_binding_make. (free_bindings): Move to name-lookup.c (pop_binding): Use cxx_binding_free. (binding_for_name): Tidy. * cp-tree.h: Include "name-lookup.h" (cxx_binding_make): Move to name-lookup.h (cxx_binding_clear): Likewise. (struct cxx_binding): Likewise. (LOCAL_BINDING_P): Likewise. (INHERITED_VALUE_BINDING_P): Likewise. (BINDING_SCOPE): Likewise. (BINDING_HAS_LEVEL_P): Likewise. (BINDING_VALUE): Likewise. (BINDING_TYPE): Likewise. * config-lang.in (gtfiles): Add cp/name-lookup.h * Make-lang.in (cp/name-lookup.o): New rule. (CXX_OBJS): Add cp/name-lookup.o (CXX_TREE_H): Add cp/name-lookup.h From-SVN: r65040
This commit is contained in:
parent
f3926c48ee
commit
aed81407a6
7 changed files with 176 additions and 81 deletions
|
@ -1,3 +1,26 @@
|
|||
2003-03-30 Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
* name-lookup.c: New file.
|
||||
* name-lookup.h: Likewise..
|
||||
* decl.c (push_binding): Adjust use cxx_binding_make.
|
||||
(free_bindings): Move to name-lookup.c
|
||||
(pop_binding): Use cxx_binding_free.
|
||||
(binding_for_name): Tidy.
|
||||
* cp-tree.h: Include "name-lookup.h"
|
||||
(cxx_binding_make): Move to name-lookup.h
|
||||
(cxx_binding_clear): Likewise.
|
||||
(struct cxx_binding): Likewise.
|
||||
(LOCAL_BINDING_P): Likewise.
|
||||
(INHERITED_VALUE_BINDING_P): Likewise.
|
||||
(BINDING_SCOPE): Likewise.
|
||||
(BINDING_HAS_LEVEL_P): Likewise.
|
||||
(BINDING_VALUE): Likewise.
|
||||
(BINDING_TYPE): Likewise.
|
||||
* config-lang.in (gtfiles): Add cp/name-lookup.h
|
||||
* Make-lang.in (cp/name-lookup.o): New rule.
|
||||
(CXX_OBJS): Add cp/name-lookup.o
|
||||
(CXX_TREE_H): Add cp/name-lookup.h
|
||||
|
||||
2003-03-28 Jason Merrill <jason@redhat.com>
|
||||
|
||||
PR c++/10245
|
||||
|
|
|
@ -87,7 +87,7 @@ CXX_OBJS = cp/call.o cp/decl.o cp/expr.o cp/pt.o cp/typeck2.o \
|
|||
cp/class.o cp/decl2.o cp/error.o cp/lex.o cp/parser.o cp/ptree.o cp/rtti.o \
|
||||
cp/typeck.o cp/cvt.o cp/except.o cp/friend.o cp/init.o cp/method.o \
|
||||
cp/search.o cp/semantics.o cp/tree.o cp/repo.o cp/dump.o \
|
||||
cp/optimize.o cp/mangle.o cp/cp-lang.o
|
||||
cp/optimize.o cp/mangle.o cp/cp-lang.o cp/name-lookup.o
|
||||
|
||||
# Use loose warnings for this front end.
|
||||
cp-warn = $(WERROR)
|
||||
|
@ -221,7 +221,8 @@ c++.stage4: stage4-start
|
|||
|
||||
#
|
||||
# .o: .h dependencies.
|
||||
CXX_TREE_H = $(TREE_H) cp/cp-tree.h c-common.h cp/cp-tree.def c-common.def \
|
||||
CXX_TREE_H = $(TREE_H) cp/name-lookup.h cp/cp-tree.h c-common.h \
|
||||
cp/cp-tree.def c-common.def \
|
||||
function.h varray.h $(SYSTEM_H) coretypes.h $(CONFIG_H) $(TARGET_H) \
|
||||
$(GGC_H) \
|
||||
$(srcdir)/../include/hashtab.h $(srcdir)/../include/splay-tree.h
|
||||
|
@ -274,3 +275,5 @@ cp/optimize.o: cp/optimize.c $(CXX_TREE_H) $(TM_H) rtl.h integrate.h insn-config
|
|||
cp/mangle.o: cp/mangle.c $(CXX_TREE_H) $(TM_H) toplev.h real.h
|
||||
|
||||
cp/parser.o: cp/parser.c $(CXX_TREE_H) $(TM_H) diagnostic.h gt-cp-parser.h output.h
|
||||
|
||||
cp/name-lookup.o: cp/name-lookup.c $(CXX_TREE_H)
|
||||
|
|
|
@ -34,4 +34,4 @@ stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"
|
|||
|
||||
target_libs="target-libstdc++-v3 target-gperf"
|
||||
|
||||
gtfiles="\$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/lex.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c"
|
||||
gtfiles="\$(srcdir)/cp/name-lookup.h \$(srcdir)/cp/cp-tree.h \$(srcdir)/cp/decl.h \$(srcdir)/cp/lex.h \$(srcdir)/cp/call.c \$(srcdir)/cp/decl.c \$(srcdir)/cp/decl2.c \$(srcdir)/cp/pt.c \$(srcdir)/cp/repo.c \$(srcdir)/cp/semantics.c \$(srcdir)/cp/tree.c \$(srcdir)/cp/parser.c \$(srcdir)/c-common.c \$(srcdir)/c-common.h \$(srcdir)/c-pragma.c"
|
||||
|
|
|
@ -34,6 +34,7 @@ Boston, MA 02111-1307, USA. */
|
|||
#endif
|
||||
|
||||
#include "c-common.h"
|
||||
#include "name-lookup.h"
|
||||
|
||||
struct diagnostic_context;
|
||||
|
||||
|
@ -217,38 +218,6 @@ struct diagnostic_context;
|
|||
|
||||
#define abi_version_at_least(N) \
|
||||
(flag_abi_version == 0 || flag_abi_version >= (N))
|
||||
|
||||
|
||||
/* Datatype used to temporarily save C++ bindings (for implicit
|
||||
instantiations purposes and like). Implemented in decl.c. */
|
||||
typedef struct cxx_saved_binding cxx_saved_binding;
|
||||
|
||||
/* Datatype that represents binding established by a declaration between
|
||||
a name and a C++ entity. */
|
||||
typedef struct cxx_binding cxx_binding;
|
||||
|
||||
/* (GC-)allocate a cxx_binding object. */
|
||||
#define cxx_binding_make() (ggc_alloc (sizeof (cxx_binding)))
|
||||
|
||||
/* Zero out a cxx_binding pointed to by B. */
|
||||
#define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding))
|
||||
|
||||
struct cxx_binding GTY(())
|
||||
{
|
||||
/* Link to chain together various bindings for this name. */
|
||||
cxx_binding *previous;
|
||||
/* The non-type entity this name is bound to. */
|
||||
tree value;
|
||||
/* The type entity this name is bound to. */
|
||||
tree type;
|
||||
union tree_binding_u {
|
||||
tree GTY ((tag ("0"))) scope;
|
||||
struct cp_binding_level * GTY ((tag ("1"))) level;
|
||||
} GTY ((desc ("%0.has_level"))) scope;
|
||||
unsigned has_level : 1;
|
||||
unsigned value_is_inherited : 1;
|
||||
unsigned is_local : 1;
|
||||
};
|
||||
|
||||
/* Language-dependent contents of an identifier. */
|
||||
|
||||
|
@ -297,31 +266,6 @@ struct ptrmem_cst GTY(())
|
|||
};
|
||||
typedef struct ptrmem_cst * ptrmem_cst_t;
|
||||
|
||||
/* Nonzero if this binding is for a local scope, as opposed to a class
|
||||
or namespace scope. */
|
||||
#define LOCAL_BINDING_P(NODE) ((NODE)->is_local)
|
||||
|
||||
/* Nonzero if BINDING_VALUE is from a base class of the class which is
|
||||
currently being defined. */
|
||||
#define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited)
|
||||
|
||||
/* For a binding between a name and an entity at a non-local scope,
|
||||
defines the scope where the binding is declared. (Either a class
|
||||
_TYPE node, or a NAMESPACE_DECL.) This macro should be used only
|
||||
for namespace-level bindings; on the IDENTIFIER_BINDING list
|
||||
BINDING_LEVEL is used instead. */
|
||||
#define BINDING_SCOPE(NODE) ((NODE)->scope.scope)
|
||||
|
||||
/* Nonzero if NODE has BINDING_LEVEL, rather than BINDING_SCOPE. */
|
||||
#define BINDING_HAS_LEVEL_P(NODE) ((NODE)->has_level)
|
||||
|
||||
/* This is the declaration bound to the name. Possible values:
|
||||
variable, overloaded function, namespace, template, enumerator. */
|
||||
#define BINDING_VALUE(NODE) ((NODE)->value)
|
||||
|
||||
/* If name is bound to a type, this is the type (struct, union, enum). */
|
||||
#define BINDING_TYPE(NODE) ((NODE)->type)
|
||||
|
||||
#define IDENTIFIER_GLOBAL_VALUE(NODE) \
|
||||
namespace_binding ((NODE), global_namespace)
|
||||
#define SET_IDENTIFIER_GLOBAL_VALUE(NODE, VAL) \
|
||||
|
|
|
@ -889,31 +889,16 @@ finish_scope (void)
|
|||
this is the `struct cp_binding_level' for the block. */
|
||||
#define BINDING_LEVEL(NODE) ((NODE)->scope.level)
|
||||
|
||||
/* A free list of cxx_binding nodes, connected by their
|
||||
TREE_CHAINs. */
|
||||
|
||||
static GTY((deletable (""))) cxx_binding *free_bindings;
|
||||
|
||||
/* Make DECL the innermost binding for ID. The LEVEL is the binding
|
||||
level at which this declaration is being bound. */
|
||||
|
||||
static void
|
||||
push_binding (tree id, tree decl, struct cp_binding_level* level)
|
||||
{
|
||||
cxx_binding *binding;
|
||||
|
||||
if (free_bindings)
|
||||
{
|
||||
binding = free_bindings;
|
||||
free_bindings = binding->previous;
|
||||
}
|
||||
else
|
||||
binding = cxx_binding_make ();
|
||||
cxx_binding *binding = cxx_binding_make (decl, NULL);
|
||||
|
||||
/* Now, fill in the binding information. */
|
||||
binding->previous = IDENTIFIER_BINDING (id);
|
||||
BINDING_VALUE (binding) = decl;
|
||||
BINDING_TYPE (binding) = NULL_TREE;
|
||||
BINDING_LEVEL (binding) = level;
|
||||
INHERITED_VALUE_BINDING_P (binding) = 0;
|
||||
LOCAL_BINDING_P (binding) = (level != class_binding_level);
|
||||
|
@ -1161,8 +1146,7 @@ pop_binding (tree id, tree decl)
|
|||
IDENTIFIER_BINDING (id) = binding->previous;
|
||||
|
||||
/* Add it to the free list. */
|
||||
binding->previous = free_bindings;
|
||||
free_bindings = binding;
|
||||
cxx_binding_free (binding);
|
||||
|
||||
/* Clear the BINDING_LEVEL so the garbage collector doesn't walk
|
||||
it. */
|
||||
|
@ -2084,10 +2068,8 @@ binding_for_name (tree name, tree scope)
|
|||
if (result)
|
||||
return result;
|
||||
/* Not found, make a new one. */
|
||||
result = cxx_binding_make ();
|
||||
result = cxx_binding_make (NULL, NULL);
|
||||
result->previous = IDENTIFIER_NAMESPACE_BINDINGS (name);
|
||||
BINDING_TYPE (result) = NULL_TREE;
|
||||
BINDING_VALUE (result) = NULL_TREE;
|
||||
BINDING_SCOPE (result) = scope;
|
||||
result->is_local = false;
|
||||
result->value_is_inherited = false;
|
||||
|
|
58
gcc/cp/name-lookup.c
Normal file
58
gcc/cp/name-lookup.c
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* Definitions for C++ name lookup routines.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU CC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#include "config.h"
|
||||
#include "system.h"
|
||||
#include "coretypes.h"
|
||||
#include "tm.h"
|
||||
#include "tree.h"
|
||||
#include "cp-tree.h"
|
||||
#include "name-lookup.h"
|
||||
|
||||
/* A free list of "cxx_binding"s, connected by their PREVIOUS. */
|
||||
static GTY((deletable (""))) cxx_binding *free_bindings;
|
||||
|
||||
/* (GC)-allocate a binding object with VALUE and TYPE member initialized. */
|
||||
cxx_binding *
|
||||
cxx_binding_make (tree value, tree type)
|
||||
{
|
||||
cxx_binding *binding;
|
||||
if (free_bindings)
|
||||
{
|
||||
binding = free_bindings;
|
||||
free_bindings = binding->previous;
|
||||
}
|
||||
else
|
||||
binding = ggc_alloc (sizeof (cxx_binding));
|
||||
|
||||
binding->value = value;
|
||||
binding->type = type;
|
||||
|
||||
return binding;
|
||||
}
|
||||
|
||||
/* Put BINDING back on the free list. */
|
||||
void
|
||||
cxx_binding_free (cxx_binding *binding)
|
||||
{
|
||||
binding->previous = free_bindings;
|
||||
free_bindings = binding;
|
||||
}
|
85
gcc/cp/name-lookup.h
Normal file
85
gcc/cp/name-lookup.h
Normal file
|
@ -0,0 +1,85 @@
|
|||
/* Declarations for C++ name lookup routines.
|
||||
Copyright (C) 2003 Free Software Foundation, Inc.
|
||||
Contributed by Gabriel Dos Reis <gdr@integrable-solutions.net>
|
||||
|
||||
This file is part of GNU CC.
|
||||
|
||||
GNU CC is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2, or (at your option)
|
||||
any later version.
|
||||
|
||||
GNU CC is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with GNU CC; see the file COPYING. If not, write to
|
||||
the Free Software Foundation, 59 Temple Place - Suite 330,
|
||||
Boston, MA 02111-1307, USA. */
|
||||
|
||||
#ifndef GCC_CP_NAME_LOOKUP_H
|
||||
#define GCC_CP_NAME_LOOKUP_H
|
||||
|
||||
#include "c-common.h"
|
||||
|
||||
/* Datatype used to temporarily save C++ bindings (for implicit
|
||||
instantiations purposes and like). Implemented in decl.c. */
|
||||
typedef struct cxx_saved_binding cxx_saved_binding;
|
||||
|
||||
/* Datatype that represents binding established by a declaration between
|
||||
a name and a C++ entity. */
|
||||
typedef struct cxx_binding cxx_binding;
|
||||
|
||||
/* Nonzero if this binding is for a local scope, as opposed to a class
|
||||
or namespace scope. */
|
||||
#define LOCAL_BINDING_P(NODE) ((NODE)->is_local)
|
||||
|
||||
/* Nonzero if BINDING_VALUE is from a base class of the class which is
|
||||
currently being defined. */
|
||||
#define INHERITED_VALUE_BINDING_P(NODE) ((NODE)->value_is_inherited)
|
||||
|
||||
/* For a binding between a name and an entity at a non-local scope,
|
||||
defines the scope where the binding is declared. (Either a class
|
||||
_TYPE node, or a NAMESPACE_DECL.) This macro should be used only
|
||||
for namespace-level bindings; on the IDENTIFIER_BINDING list
|
||||
BINDING_LEVEL is used instead. */
|
||||
#define BINDING_SCOPE(NODE) ((NODE)->scope.scope)
|
||||
|
||||
/* Nonzero if NODE has BINDING_LEVEL, rather than BINDING_SCOPE. */
|
||||
#define BINDING_HAS_LEVEL_P(NODE) ((NODE)->has_level)
|
||||
|
||||
/* This is the declaration bound to the name. Possible values:
|
||||
variable, overloaded function, namespace, template, enumerator. */
|
||||
#define BINDING_VALUE(NODE) ((NODE)->value)
|
||||
|
||||
/* If name is bound to a type, this is the type (struct, union, enum). */
|
||||
#define BINDING_TYPE(NODE) ((NODE)->type)
|
||||
|
||||
/* Zero out a cxx_binding pointed to by B. */
|
||||
#define cxx_binding_clear(B) memset ((B), 0, sizeof (cxx_binding))
|
||||
|
||||
struct cxx_binding GTY(())
|
||||
{
|
||||
/* Link to chain together various bindings for this name. */
|
||||
cxx_binding *previous;
|
||||
/* The non-type entity this name is bound to. */
|
||||
tree value;
|
||||
/* The type entity this name is bound to. */
|
||||
tree type;
|
||||
union tree_binding_u {
|
||||
tree GTY ((tag ("0"))) scope;
|
||||
struct cp_binding_level * GTY ((tag ("1"))) level;
|
||||
} GTY ((desc ("%0.has_level"))) scope;
|
||||
unsigned has_level : 1;
|
||||
unsigned value_is_inherited : 1;
|
||||
unsigned is_local : 1;
|
||||
};
|
||||
|
||||
extern cxx_binding *cxx_binding_make (tree, tree);
|
||||
extern void cxx_binding_free (cxx_binding *);
|
||||
|
||||
|
||||
|
||||
#endif /* GCC_CP_NAME_LOOKUP_H */
|
Loading…
Add table
Reference in a new issue