This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[mainline] C++ PATCH: debug function-prototype-scope
- From: Gabriel Dos Reis <gdr at integrable-solutions dot net>
- To: gcc-patches at gcc dot gnu dot org
- Cc: mark at codesourcery dot com, jason at redhat dot com
- Date: 31 May 2003 20:47:20 +0200
- Subject: [mainline] C++ PATCH: debug function-prototype-scope
- Organization: Integrable Solutions
Hi,
This patch enables debugging for function prototype scope. While
preparing this patch, I realized that in
push_inline_template_parms_recursive, we're forgetting to set the
scope kind marker for the template paremeters scope. Fixed thusly.
Ideally, there should be a very small set of functions that directly
access current_binding_level. That will be addressed in future
patches.
Bootstrapped and regtested on an i686-pc-linux-gnu.
OK?
-- Gaby
2003-05-31 Gabriel Dos Reis <gdr@integrable-solutions.net>
* decl.c (cxx_pushlevel): New function.
(maybe_push_cleanup_level): Use it.
(begin_scope): Likewise.
(initial_push_namespace_scope): Likewise.
(pushlevel): Wrap arount cxx_pushlevel.
(cxx_push_function_prototype_scope): New function.
(start_function): Use it.
(start_method): Likewise.
* pt.c (push_inline_template_parms_recursive): Use begin_scope
instead of pushlevel.
Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.1059
diff -p -r1.1059 decl.c
*** decl.c 31 May 2003 12:53:41 -0000 1.1059
--- decl.c 31 May 2003 18:39:12 -0000
*************** resume_binding_level (struct cp_binding_
*** 643,648 ****
--- 643,671 ----
binding_depth++;
}
}
+
+ /* Push a binding coutour that may be TAG_TRANSPARENT and return
+ the corresponding cxx_scope object. */
+ static inline cxx_scope *
+ cxx_pushlevel (bool tag_transparent)
+ {
+ if (cfun && !doing_semantic_analysis_p ())
+ return current_binding_level;
+
+ push_binding_level (make_cxx_scope (tag_transparent, keep_next_level_flag));
+ keep_next_level_flag = 0;
+ return current_binding_level;
+ }
+
+ /* Push a binding contour for the function-prototype-scope of FUN. */
+ static inline void
+ cxx_push_function_prototype_scope (tree fun)
+ {
+ cxx_scope *scope = cxx_pushlevel (false);
+ scope->parm_flag = true;
+ scope->this_entity = fun;
+ }
+
/* Nonzero if we are currently in the global binding level. */
*************** set_class_shadows (tree shadows)
*** 824,834 ****
void
pushlevel (int tag_transparent)
{
! if (cfun && !doing_semantic_analysis_p ())
! return;
!
! push_binding_level (make_cxx_scope (tag_transparent, keep_next_level_flag));
! keep_next_level_flag = 0;
}
/* We're defining an object of type TYPE. If it needs a cleanup, but
--- 847,853 ----
void
pushlevel (int tag_transparent)
{
! cxx_pushlevel (tag_transparent);
}
/* We're defining an object of type TYPE. If it needs a cleanup, but
*************** maybe_push_cleanup_level (tree type)
*** 842,848 ****
&& current_binding_level->more_cleanups_ok == 0)
{
keep_next_level (2);
! pushlevel (1);
clear_last_expr ();
add_scope_stmt (/*begin_p=*/1, /*partial_p=*/1);
}
--- 861,867 ----
&& current_binding_level->more_cleanups_ok == 0)
{
keep_next_level (2);
! cxx_pushlevel (true);
clear_last_expr ();
add_scope_stmt (/*begin_p=*/1, /*partial_p=*/1);
}
*************** maybe_push_cleanup_level (tree type)
*** 854,860 ****
void
begin_scope (scope_kind sk)
{
! pushlevel (0);
switch (sk)
{
--- 873,879 ----
void
begin_scope (scope_kind sk)
{
! cxx_scope *scope = cxx_pushlevel (false);
switch (sk)
{
*************** begin_scope (scope_kind sk)
*** 862,884 ****
break;
case sk_try:
! current_binding_level->is_try_scope = 1;
break;
case sk_catch:
! current_binding_level->is_catch_scope = 1;
break;
case sk_for:
! current_binding_level->is_for_scope = 1;
break;
case sk_template_spec:
! current_binding_level->template_spec_p = 1;
/* Fall through. */
case sk_template_parms:
! current_binding_level->template_parms_p = 1;
break;
default:
--- 881,903 ----
break;
case sk_try:
! scope->is_try_scope = 1;
break;
case sk_catch:
! scope->is_catch_scope = 1;
break;
case sk_for:
! scope->is_for_scope = 1;
break;
case sk_template_spec:
! scope->template_spec_p = 1;
/* Fall through. */
case sk_template_parms:
! scope->template_parms_p = 1;
break;
default:
*************** static void
*** 2010,2019 ****
initial_push_namespace_scope (tree ns)
{
tree name = DECL_NAME (ns);
! cxx_scope *scope;
!
! pushlevel (0);
! scope = current_binding_level;
scope->namespace_p = true;
scope->type_decls = binding_table_new (name == std_identifier
? NAMESPACE_STD_HT_SIZE
--- 2029,2035 ----
initial_push_namespace_scope (tree ns)
{
tree name = DECL_NAME (ns);
! cxx_scope *scope = cxx_pushlevel (false);
scope->namespace_p = true;
scope->type_decls = binding_table_new (name == std_identifier
? NAMESPACE_STD_HT_SIZE
*************** start_function (tree declspecs, tree dec
*** 13622,13629 ****
DECL_INTERFACE_KNOWN (decl1) = 1;
}
! pushlevel (0);
! current_binding_level->parm_flag = 1;
++function_depth;
--- 13638,13644 ----
DECL_INTERFACE_KNOWN (decl1) = 1;
}
! cxx_push_function_prototype_scope (decl1);
++function_depth;
*************** start_method (tree declspecs, tree decla
*** 14200,14207 ****
cp_finish_decl (fndecl, NULL_TREE, NULL_TREE, 0);
/* Make a place for the parms */
! pushlevel (0);
! current_binding_level->parm_flag = 1;
DECL_IN_AGGR_P (fndecl) = 1;
return fndecl;
--- 14215,14221 ----
cp_finish_decl (fndecl, NULL_TREE, NULL_TREE, 0);
/* Make a place for the parms */
! cxx_push_function_prototype_scope (fndecl);
DECL_IN_AGGR_P (fndecl) = 1;
return fndecl;
Index: pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.696
diff -p -r1.696 pt.c
*** pt.c 31 May 2003 12:13:30 -0000 1.696
--- pt.c 31 May 2003 18:39:17 -0000
*************** push_inline_template_parms_recursive (pa
*** 408,414 ****
parms, current_template_parms);
TEMPLATE_PARMS_FOR_INLINE (current_template_parms) = 1;
! pushlevel (0);
for (i = 0; i < TREE_VEC_LENGTH (parms); ++i)
{
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
--- 408,415 ----
parms, current_template_parms);
TEMPLATE_PARMS_FOR_INLINE (current_template_parms) = 1;
! begin_scope (TREE_VEC_LENGTH (parms) == 0
! ? sk_template_spec : sk_template_parms);
for (i = 0; i < TREE_VEC_LENGTH (parms); ++i)
{
tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));