diff options
author | Gabriel Dos Reis <gdr@integrable-solutions.net> | 2003-05-29 17:25:04 +0000 |
---|---|---|
committer | Gabriel Dos Reis <gdr@gcc.gnu.org> | 2003-05-29 17:25:04 +0000 |
commit | f37e2274d0e63bf9b4e499721e8ece99f4bcd6d2 (patch) | |
tree | 500f2d4ef0a681c82b21570f053a436e87e0ebda | |
parent | 833e1a77244310aad1be0a548c871705de725edc (diff) | |
download | gcc-f37e2274d0e63bf9b4e499721e8ece99f4bcd6d2.zip gcc-f37e2274d0e63bf9b4e499721e8ece99f4bcd6d2.tar.gz gcc-f37e2274d0e63bf9b4e499721e8ece99f4bcd6d2.tar.bz2 |
decl.c (ENABLE_SCOPE_CHECKING): Rename from DEBUG_BINDING_LEVELS.
* decl.c (ENABLE_SCOPE_CHECKING): Rename from DEBUG_BINDING_LEVELS.
(binding_depth): Unconditionally define.
(is_class_level): Likewise.
(indent): Likewise. Take an indenting parameter.
(push_binding_level): Remove conditional definittion.
(pop_binding_level): Likewise.
(suspend_binding_level): Likewise.
(resume_binding_level): Likewise.
(pushlevel): Likewise.
(pushlevel_class): Likewise.
(poplevel_class): Likewise.
(pop_everything): Likewise.
From-SVN: r67226
-rw-r--r-- | gcc/cp/ChangeLog | 15 | ||||
-rw-r--r-- | gcc/cp/decl.c | 146 |
2 files changed, 84 insertions, 77 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index b364298..3071e2b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,18 @@ +2003-05-29 Gabriel Dos Reis <gdr@integrable-solutions.net> + + * decl.c (ENABLE_SCOPE_CHECKING): Rename from DEBUG_BINDING_LEVELS. + (binding_depth): Unconditionally define. + (is_class_level): Likewise. + (indent): Likewise. Take an indenting parameter. + (push_binding_level): Remove conditional definittion. + (pop_binding_level): Likewise. + (suspend_binding_level): Likewise. + (resume_binding_level): Likewise. + (pushlevel): Likewise. + (pushlevel_class): Likewise. + (poplevel_class): Likewise. + (pop_everything): Likewise. + 2003-05-27 Gabriel Dos Reis <gdr@integrable-solutions.net> * name-lookup.h (global_scope_p): New macro. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index b6a2153..ec302ae 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -148,10 +148,6 @@ static tree next_initializable_field (tree); static tree reshape_init (tree, tree *); static tree build_typename_type (tree, tree, tree); -#if defined (DEBUG_BINDING_LEVELS) -static void indent (void); -#endif - /* Erroneous argument lists can use this *IFF* they do not modify it. */ tree error_mark_list; @@ -448,19 +444,23 @@ static int keep_next_level_flag; static GTY(()) tree incomplete_vars; -#if defined(DEBUG_BINDING_LEVELS) +#ifndef ENABLE_SCOPE_CHECKING +# define ENABLE_SCOPE_CHECKING 0 +#else +# define ENABLE_SCOPE_CHECKING 1 +#endif + static int binding_depth = 0; static int is_class_level = 0; static void -indent (void) +indent (int depth) { - register unsigned i; + int i; - for (i = 0; i < binding_depth*2; i++) + for (i = 0; i < depth * 2; i++) putc (' ', stderr); } -#endif /* defined(DEBUG_BINDING_LEVELS) */ static tree pushdecl_with_scope (tree, struct cp_binding_level *); @@ -478,14 +478,16 @@ push_binding_level (struct cp_binding_level *newlevel, newlevel->more_cleanups_ok = 1; newlevel->keep = keep; -#if defined(DEBUG_BINDING_LEVELS) - newlevel->binding_depth = binding_depth; - indent (); - fprintf (stderr, "push %s level 0x%08x line %d\n", - (is_class_level) ? "class" : "block", newlevel, input_line); - is_class_level = 0; - binding_depth++; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + { + newlevel->binding_depth = binding_depth; + indent (binding_depth); + verbatim ("push %s level %p line %d\n", + (is_class_level) ? "class" : "block", + (void *) newlevel, input_line); + is_class_level = 0; + binding_depth++; + } } /* Find the innermost enclosing class scope, and reset @@ -511,19 +513,20 @@ pop_binding_level (void) /* Cannot pop a level, if there are none left to pop. */ my_friendly_assert (!global_scope_p (current_binding_level), 20030527); /* Pop the current level, and free the structure for reuse. */ -#if defined(DEBUG_BINDING_LEVELS) - binding_depth--; - indent (); - fprintf (stderr, "pop %s level 0x%08x line %d\n", - (is_class_level) ? "class" : "block", - current_binding_level, input_line); - if (is_class_level != (current_binding_level == class_binding_level)) - { - indent (); - fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n"); - } - is_class_level = 0; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + { + indent (--binding_depth); + verbatim ("pop %s level %p line %d\n", + (is_class_level) ? "class" : "block", + (void*) current_binding_level, input_line); + if (is_class_level != (current_binding_level == class_binding_level)) + { + indent (binding_depth); + verbatim ("XXX is_class_level != (current_binding_level " + "== class_binding_level)\n"); + } + is_class_level = 0; + } { register struct cp_binding_level *level = current_binding_level; current_binding_level = current_binding_level->level_chain; @@ -532,10 +535,9 @@ pop_binding_level (void) level->type_decls = NULL; else binding_table_free (level->type_decls); -#if 0 /* defined(DEBUG_BINDING_LEVELS) */ - if (level->binding_depth != binding_depth) - abort (); -#endif /* defined(DEBUG_BINDING_LEVELS) */ + my_friendly_assert (!ENABLE_SCOPE_CHECKING + || level->binding_depth == binding_depth, + 20030529); free_binding_level = level; find_class_binding_level (); } @@ -551,19 +553,20 @@ suspend_binding_level (void) /* Cannot suspend a level, if there are none left to suspend. */ my_friendly_assert (!global_scope_p (current_binding_level), 20030527); /* Suspend the current level. */ -#if defined(DEBUG_BINDING_LEVELS) - binding_depth--; - indent (); - fprintf (stderr, "suspend %s level 0x%08x line %d\n", - (is_class_level) ? "class" : "block", - current_binding_level, input_line); - if (is_class_level != (current_binding_level == class_binding_level)) - { - indent (); - fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n"); - } - is_class_level = 0; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + { + indent (--binding_depth); + verbatim ("suspend %s level %p line %d\n", + (is_class_level) ? "class" : "block", + (void *) current_binding_level, input_line); + if (is_class_level != (current_binding_level == class_binding_level)) + { + indent (binding_depth); + verbatim ("XXX is_class_level != (current_binding_level " + "== class_binding_level)\n"); + } + is_class_level = 0; + } current_binding_level = current_binding_level->level_chain; find_class_binding_level (); } @@ -577,14 +580,15 @@ resume_binding_level (struct cp_binding_level* b) /* Also, resuming a non-directly nested namespace is a no-no. */ my_friendly_assert(b->level_chain == current_binding_level, 386); current_binding_level = b; -#if defined(DEBUG_BINDING_LEVELS) - b->binding_depth = binding_depth; - indent (); - fprintf (stderr, "resume %s level 0x%08x line %d\n", - (is_class_level) ? "class" : "block", b, input_line); - is_class_level = 0; - binding_depth++; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + { + b->binding_depth = binding_depth; + indent (binding_depth); + verbatim ("resume %s level %p line %d\n", + (is_class_level) ? "class" : "block", b, input_line); + is_class_level = 0; + binding_depth++; + } } /* Create a new `struct cp_binding_level'. */ @@ -789,11 +793,7 @@ pushlevel (int tag_transparent) return; /* Reuse or create a struct for this binding level. */ -#if defined(DEBUG_BINDING_LEVELS) - if (0) -#else /* !defined(DEBUG_BINDING_LEVELS) */ - if (free_binding_level) -#endif /* !defined(DEBUG_BINDING_LEVELS) */ + if (!ENABLE_SCOPE_CHECKING && free_binding_level) { newlevel = free_binding_level; free_binding_level = free_binding_level->level_chain; @@ -1553,11 +1553,7 @@ pushlevel_class (void) register struct cp_binding_level *newlevel; /* Reuse or create a struct for this binding level. */ -#if defined(DEBUG_BINDING_LEVELS) - if (0) -#else /* !defined(DEBUG_BINDING_LEVELS) */ - if (free_binding_level) -#endif /* !defined(DEBUG_BINDING_LEVELS) */ + if (!ENABLE_SCOPE_CHECKING && free_binding_level) { newlevel = free_binding_level; free_binding_level = free_binding_level->level_chain; @@ -1565,9 +1561,8 @@ pushlevel_class (void) else newlevel = make_binding_level (); -#if defined(DEBUG_BINDING_LEVELS) - is_class_level = 1; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + is_class_level = 1; push_binding_level (newlevel, 0, 0); @@ -1644,9 +1639,8 @@ poplevel_class (void) /* Now, pop out of the binding level which we created up in the `pushlevel_class' routine. */ -#if defined(DEBUG_BINDING_LEVELS) - is_class_level = 1; -#endif /* defined(DEBUG_BINDING_LEVELS) */ + if (ENABLE_SCOPE_CHECKING) + is_class_level = 1; pop_binding_level (); timevar_pop (TV_NAME_LOOKUP); @@ -2361,9 +2355,8 @@ identifier_type_value (tree id) void pop_everything (void) { -#ifdef DEBUG_BINDING_LEVELS - fprintf (stderr, "XXX entering pop_everything ()\n"); -#endif + if (ENABLE_SCOPE_CHECKING) + verbatim ("XXX entering pop_everything ()\n"); while (!toplevel_bindings_p ()) { if (current_binding_level->parm_flag == 2) @@ -2371,9 +2364,8 @@ pop_everything (void) else poplevel (0, 0, 0); } -#ifdef DEBUG_BINDING_LEVELS - fprintf (stderr, "XXX leaving pop_everything ()\n"); -#endif + if (ENABLE_SCOPE_CHECKING) + verbatim ("XXX leaving pop_everything ()\n"); } /* The type TYPE is being declared. If it is a class template, or a |