summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-03 19:29:51 +0000
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>2003-01-03 19:29:51 +0000
commit81010c9762bdeb5c579ba06d25abdf5adeb2d680 (patch)
treeed397435e12ce43cd81067953111919e1628866f
parent6b5829b61cf7053380511862ae06533462bc2a3d (diff)
downloadgcc-81010c9762bdeb5c579ba06d25abdf5adeb2d680.tar.gz
* c-common.c (finish_fname_decls): Put the DECL_STMTs inside the
outermost scope. * c-decl.c (c_make_fname_decl): Push the decls there, too. cp/ * decl.c (cp_make_fname_decl): Push the decls inside the outermost scope. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@60848 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/c-common.c23
-rw-r--r--gcc/c-decl.c12
-rw-r--r--gcc/cp/ChangeLog5
-rw-r--r--gcc/cp/decl.c10
5 files changed, 46 insertions, 10 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index df4f2b16116..37c1db7e3fc 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,9 @@
+2003-01-02 Jason Merrill <jason@redhat.com>
+
+ * c-common.c (finish_fname_decls): Put the DECL_STMTs inside the
+ outermost scope.
+ * c-decl.c (c_make_fname_decl): Push the decls there, too.
+
2003-01-03 Kazu Hirata <kazu@cs.umass.edu>
* config/h8300/h8300-protos.h: Add a prototype for
diff --git a/gcc/c-common.c b/gcc/c-common.c
index 79502d2fde8..12cacab3d55 100644
--- a/gcc/c-common.c
+++ b/gcc/c-common.c
@@ -1050,13 +1050,18 @@ finish_fname_decls ()
if (body)
{
- /* They were called into existence, so add to statement tree. */
- body = chainon (body,
- TREE_CHAIN (DECL_SAVED_TREE (current_function_decl)));
- body = build_stmt (COMPOUND_STMT, body);
-
- COMPOUND_STMT_NO_SCOPE (body) = 1;
- TREE_CHAIN (DECL_SAVED_TREE (current_function_decl)) = body;
+ /* They were called into existence, so add to statement tree. Add
+ the DECL_STMTs inside the outermost scope. */
+ tree *p = &DECL_SAVED_TREE (current_function_decl);
+ /* Skip the dummy EXPR_STMT and any EH_SPEC_BLOCK. */
+ while (TREE_CODE (*p) != COMPOUND_STMT)
+ p = &TREE_CHAIN (*p);
+ p = &COMPOUND_BODY (*p);
+ if (TREE_CODE (*p) == SCOPE_STMT)
+ p = &TREE_CHAIN (*p);
+
+ body = chainon (body, *p);
+ *p = body;
}
for (ix = 0; fname_vars[ix].decl; ix++)
@@ -1079,7 +1084,7 @@ finish_fname_decls ()
saved_function_name_decls = stack;
}
-/* Return the text name of the current function, suitable prettified
+/* Return the text name of the current function, suitably prettified
by PRETTY_P. */
const char *
@@ -1163,7 +1168,7 @@ fname_decl (rid, id)
}
if (!ix && !current_function_decl)
pedwarn_with_decl (decl, "`%s' is not defined outside of function scope");
-
+
return decl;
}
diff --git a/gcc/c-decl.c b/gcc/c-decl.c
index 8c86bc0d87a..fde8c482e12 100644
--- a/gcc/c-decl.c
+++ b/gcc/c-decl.c
@@ -2545,6 +2545,18 @@ c_make_fname_decl (id, type_dep)
DECL_INITIAL (decl) = init;
TREE_USED (decl) = 1;
+
+ if (current_function_decl)
+ {
+ /* Add the decls to the outermost block. */
+ struct binding_level *b = current_binding_level;
+ struct binding_level *old = b;
+ while (b->level_chain->parm_flag == 0)
+ b = b->level_chain;
+ current_binding_level = b;
+ pushdecl (decl);
+ current_binding_level = old;
+ }
finish_decl (decl, init, NULL_TREE);
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 9be11475fd9..dad9680fe90 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,8 @@
+2003-01-02 Jason Merrill <jason@redhat.com>
+
+ * decl.c (cp_make_fname_decl): Push the decls inside the
+ outermost scope.
+
2003-01-03 Nathan Sidwell <nathan@codesourcery.com>
PR c++/45, c++/3784
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index aaf426294e1..ed200092777 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -6656,7 +6656,7 @@ cp_make_fname_decl (id, type_dep)
tree init = cp_fname_init (name);
tree decl = build_decl (VAR_DECL, id, TREE_TYPE (init));
- /* As we don't push the decl here, we must set the context. */
+ /* As we're using pushdecl_with_scope, we must set the context. */
DECL_CONTEXT (decl) = current_function_decl;
DECL_PRETTY_FUNCTION_P (decl) = type_dep;
@@ -6667,6 +6667,14 @@ cp_make_fname_decl (id, type_dep)
TREE_USED (decl) = 1;
+ if (current_function_decl)
+ {
+ struct cp_binding_level *b = current_binding_level;
+ while (b->level_chain->parm_flag == 0)
+ b = b->level_chain;
+ pushdecl_with_scope (decl, b);
+ }
+
cp_finish_decl (decl, init, NULL_TREE, LOOKUP_ONLYCONVERTING);
return decl;