aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mark@codesourcery.com>2000-01-23 18:40:20 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>2000-01-23 18:40:20 +0000
commitbf419747e917f86ff61845ed136d5ec2386b4a8f (patch)
tree90d64c7e911431e3eb2ef805a502b9b6dff47c7f
parent5c75f60e28199fbd26221017d83b6a7750403089 (diff)
downloadgcc-bf419747e917f86ff61845ed136d5ec2386b4a8f.zip
gcc-bf419747e917f86ff61845ed136d5ec2386b4a8f.tar.gz
gcc-bf419747e917f86ff61845ed136d5ec2386b4a8f.tar.bz2
cp-tree.h (register_dtor_fn): New function.
* cp-tree.h (register_dtor_fn): New function. * decl.c (destroy_local_static): Rename to ... (register_dtor_fn): ... this. Give it external linkage. (expand_static_init): Use it. * decl2.c (do_static_initialization): Likewise, if using __cxa_atexit. (do_static_destruction): Check that __cxa_atexit is not in use. (finish_file): Don't call do_static_destruction if using __cxa_atexit. * typeck.c (convert_arguments): Restore two-message error reporting. From-SVN: r31570
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/cp-tree.h1
-rw-r--r--gcc/cp/decl.c15
-rw-r--r--gcc/cp/decl2.c27
-rw-r--r--gcc/cp/typeck.c14
5 files changed, 56 insertions, 16 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 074c0b0..88a7a2c 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,18 @@
+2000-01-23 Mark Mitchell <mark@codesourcery.com>
+
+ * cp-tree.h (register_dtor_fn): New function.
+ * decl.c (destroy_local_static): Rename to ...
+ (register_dtor_fn): ... this. Give it external linkage.
+ (expand_static_init): Use it.
+ * decl2.c (do_static_initialization): Likewise, if using
+ __cxa_atexit.
+ (do_static_destruction): Check that __cxa_atexit is not in use.
+ (finish_file): Don't call do_static_destruction if using
+ __cxa_atexit.
+
+ * typeck.c (convert_arguments): Restore two-message error
+ reporting.
+
2000-01-20 Nathan Sidwell <sidwell@codesourcery.com>
Remap dynamic cast hint values to be consistent across ABIs.
diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h
index 1af012d..a2e7aca 100644
--- a/gcc/cp/cp-tree.h
+++ b/gcc/cp/cp-tree.h
@@ -3680,6 +3680,7 @@ extern void make_rtl_for_local_static PROTO((tree));
extern int local_variable_p PROTO((tree));
extern int nonstatic_local_decl_p PROTO((tree));
extern tree declare_global_var PROTO((tree, tree));
+extern void register_dtor_fn PROTO((tree));
/* in decl2.c */
extern void init_decl2 PROTO((void));
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index bd8ba63..2471090 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -173,7 +173,6 @@ static void mark_lang_function PROTO((struct language_function *));
static void mark_stmt_tree PROTO((struct stmt_tree *));
static void save_function_data PROTO((tree));
static void check_function_type PROTO((tree));
-static void destroy_local_static PROTO((tree));
static void destroy_local_var PROTO((tree));
static void finish_constructor_body PROTO((void));
static void finish_destructor_body PROTO((void));
@@ -8054,11 +8053,11 @@ end_cleanup_fn ()
pop_from_top_level ();
}
-/* Generate code to handle the destruction of the function-scoped
- static variable DECL. */
+/* Generate code to handle the destruction of DECL, an object with
+ static storage duration. */
-static void
-destroy_local_static (decl)
+void
+register_dtor_fn (decl)
tree decl;
{
tree cleanup;
@@ -8068,6 +8067,9 @@ destroy_local_static (decl)
int saved_flag_access_control;
+ if (!TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
+ return;
+
/* Call build_cleanup before we enter the anonymous function so that
any access checks will be done relative to the current scope,
rather than the scope of the anonymous function. */
@@ -8193,8 +8195,7 @@ expand_static_init (decl, init)
/* Use atexit to register a function for destroying this static
variable. */
- if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
- destroy_local_static (decl);
+ register_dtor_fn (decl);
finish_compound_stmt (/*has_no_scope=*/0, then_clause);
finish_then_clause (if_stmt);
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 69b302a..bf0f07e 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -3204,6 +3204,11 @@ do_static_initialization (decl, init)
}
finish_expr_stmt (expr);
+ /* If we're using __cxa_atexit, register a a function that calls the
+ destructor for the object. */
+ if (flag_use_cxa_atexit)
+ register_dtor_fn (decl);
+
/* Finsh up. */
finish_static_initialization_or_destruction (sentry_if_stmt);
}
@@ -3219,10 +3224,14 @@ do_static_destruction (decl)
{
tree sentry_if_stmt;
+ /* If we're using __cxa_atexit, then destructors are registered
+ immediately after objects are initialized. */
+ my_friendly_assert (!flag_use_cxa_atexit, 20000121);
+
/* If we don't need a destructor, there's nothing to do. */
if (!TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
return;
-
+
/* Actually do the destruction. */
sentry_if_stmt = start_static_initialization_or_destruction (decl,
/*initp=*/0);
@@ -3468,10 +3477,18 @@ finish_file ()
/* Then, generate code to do all the destructions. Do these
in reverse order so that the most recently constructed
- variable is the first destroyed. */
- vars = nreverse (vars);
- for (v = vars; v; v = TREE_CHAIN (v))
- do_static_destruction (TREE_VALUE (v));
+ variable is the first destroyed. If we're using
+ __cxa_atexit, then we don't need to do this; functions
+ we're registered at initialization time to destroy the
+ local statics. */
+ if (!flag_use_cxa_atexit)
+ {
+ vars = nreverse (vars);
+ for (v = vars; v; v = TREE_CHAIN (v))
+ do_static_destruction (TREE_VALUE (v));
+ }
+ else
+ vars = NULL_TREE;
/* Finish up the static storage duration function for this
round. */
diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c
index fabece2..2a4a668 100644
--- a/gcc/cp/typeck.c
+++ b/gcc/cp/typeck.c
@@ -3120,8 +3120,11 @@ convert_arguments (typelist, values, fndecl, flags)
if (type == void_type_node)
{
if (fndecl)
- cp_error_at ("too many arguments to %s `%+#D' at this point",
- called_thing, fndecl);
+ {
+ cp_error_at ("too many arguments to %s `%+#D'", called_thing,
+ fndecl);
+ error ("at this point in file");
+ }
else
error ("too many arguments to function");
/* In case anybody wants to know if this argument
@@ -3219,8 +3222,11 @@ convert_arguments (typelist, values, fndecl, flags)
else
{
if (fndecl)
- cp_error_at ("too few arguments to %s `%+#D' at this point",
- called_thing, fndecl);
+ {
+ cp_error_at ("too few arguments to %s `%+#D'",
+ called_thing, fndecl);
+ error ("at this point in file");
+ }
else
error ("too few arguments to function");
return error_mark_list;