Commit 448083e5 by Paolo Carlini Committed by Paolo Carlini

decl.c (push_library_fn): Add a parameter for the exceptions that the function may throw.

2008-07-27  Paolo Carlini  <paolo.carlini@oracle.com>

	* decl.c (push_library_fn): Add a parameter for the exceptions that
	the function may throw.
	(push_void_library_fn, push_throw_library_fn, expand_static_init):
	Adjust.
	(build_library_fn): Change to static.
	* cp-tree.h: Adjust declarations.
	* except.c (declare_nothrow_library_fn): New.
	(do_get_exception_ptr, do_begin_catch, do_free_exception,
	do_allocate_exception):  Use the latter, adjust the declarations
	(ie, add empty exception-specification), consistently with the
	actual implementation in libsupc++.

From-SVN: r138189
parent 0d52899f
2008-07-27 Paolo Carlini <paolo.carlini@oracle.com>
* decl.c (push_library_fn): Add a parameter for the exceptions that
the function may throw.
(push_void_library_fn, push_throw_library_fn, expand_static_init):
Adjust.
(build_library_fn): Change to static.
* cp-tree.h: Adjust declarations.
* except.c (declare_nothrow_library_fn): New.
(do_get_exception_ptr, do_begin_catch, do_free_exception,
do_allocate_exception): Use the latter, adjust the declarations
(ie, add empty exception-specification), consistently with the
actual implementation in libsupc++.
2008-07-25 Jan Hubicka <jh@suse.cz> 2008-07-25 Jan Hubicka <jh@suse.cz>
* typeck.c (inline_conversion): Remove. * typeck.c (inline_conversion): Remove.
......
...@@ -4225,10 +4225,9 @@ extern bool check_omp_return (void); ...@@ -4225,10 +4225,9 @@ extern bool check_omp_return (void);
extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t); extern tree make_typename_type (tree, tree, enum tag_types, tsubst_flags_t);
extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t); extern tree make_unbound_class_template (tree, tree, tree, tsubst_flags_t);
extern tree check_for_out_of_scope_variable (tree); extern tree check_for_out_of_scope_variable (tree);
extern tree build_library_fn (tree, tree);
extern tree build_library_fn_ptr (const char *, tree); extern tree build_library_fn_ptr (const char *, tree);
extern tree build_cp_library_fn_ptr (const char *, tree); extern tree build_cp_library_fn_ptr (const char *, tree);
extern tree push_library_fn (tree, tree); extern tree push_library_fn (tree, tree, tree);
extern tree push_void_library_fn (tree, tree); extern tree push_void_library_fn (tree, tree);
extern tree push_throw_library_fn (tree, tree); extern tree push_throw_library_fn (tree, tree);
extern tree check_tag_decl (cp_decl_specifier_seq *); extern tree check_tag_decl (cp_decl_specifier_seq *);
......
...@@ -3590,7 +3590,7 @@ build_library_fn_1 (tree name, enum tree_code operator_code, tree type) ...@@ -3590,7 +3590,7 @@ build_library_fn_1 (tree name, enum tree_code operator_code, tree type)
We assume that such functions never throw; if this is incorrect, We assume that such functions never throw; if this is incorrect,
callers should unset TREE_NOTHROW. */ callers should unset TREE_NOTHROW. */
tree static tree
build_library_fn (tree name, tree type) build_library_fn (tree name, tree type)
{ {
tree fn = build_library_fn_1 (name, ERROR_MARK, type); tree fn = build_library_fn_1 (name, ERROR_MARK, type);
...@@ -3629,12 +3629,18 @@ build_cp_library_fn_ptr (const char* name, tree type) ...@@ -3629,12 +3629,18 @@ build_cp_library_fn_ptr (const char* name, tree type)
} }
/* Like build_library_fn, but also pushes the function so that we will /* Like build_library_fn, but also pushes the function so that we will
be able to find it via IDENTIFIER_GLOBAL_VALUE. */ be able to find it via IDENTIFIER_GLOBAL_VALUE. Also, the function
may throw exceptions listed in RAISES. */
tree tree
push_library_fn (tree name, tree type) push_library_fn (tree name, tree type, tree raises)
{ {
tree fn = build_library_fn (name, type); tree fn;
if (raises)
type = build_exception_variant (type, raises);
fn = build_library_fn (name, type);
pushdecl_top_level (fn); pushdecl_top_level (fn);
return fn; return fn;
} }
...@@ -3659,7 +3665,7 @@ tree ...@@ -3659,7 +3665,7 @@ tree
push_void_library_fn (tree name, tree parmtypes) push_void_library_fn (tree name, tree parmtypes)
{ {
tree type = build_function_type (void_type_node, parmtypes); tree type = build_function_type (void_type_node, parmtypes);
return push_library_fn (name, type); return push_library_fn (name, type, NULL_TREE);
} }
/* Like push_library_fn, but also note that this function throws /* Like push_library_fn, but also note that this function throws
...@@ -3668,7 +3674,7 @@ push_void_library_fn (tree name, tree parmtypes) ...@@ -3668,7 +3674,7 @@ push_void_library_fn (tree name, tree parmtypes)
tree tree
push_throw_library_fn (tree name, tree type) push_throw_library_fn (tree name, tree type)
{ {
tree fn = push_library_fn (name, type); tree fn = push_library_fn (name, type, NULL_TREE);
TREE_THIS_VOLATILE (fn) = 1; TREE_THIS_VOLATILE (fn) = 1;
TREE_NOTHROW (fn) = 0; TREE_NOTHROW (fn) = 0;
return fn; return fn;
...@@ -6169,9 +6175,10 @@ expand_static_init (tree decl, tree init) ...@@ -6169,9 +6175,10 @@ expand_static_init (tree decl, tree init)
void_list_node); void_list_node);
tree vfntype = build_function_type (void_type_node, argtypes); tree vfntype = build_function_type (void_type_node, argtypes);
acquire_fn = push_library_fn acquire_fn = push_library_fn
(acquire_fn, build_function_type (integer_type_node, argtypes)); (acquire_fn, build_function_type (integer_type_node, argtypes),
release_fn = push_library_fn (release_fn, vfntype); NULL_TREE);
abort_fn = push_library_fn (abort_fn, vfntype); release_fn = push_library_fn (release_fn, vfntype, NULL_TREE);
abort_fn = push_library_fn (abort_fn, vfntype, NULL_TREE);
} }
else else
{ {
......
/* Handle exceptional things in C++. /* Handle exceptional things in C++.
Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
2000, 2001, 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008
Free Software Foundation, Inc.
Contributed by Michael Tiemann <tiemann@cygnus.com> Contributed by Michael Tiemann <tiemann@cygnus.com>
Rewritten by Mike Stump <mrs@cygnus.com>, based upon an Rewritten by Mike Stump <mrs@cygnus.com>, based upon an
initial re-implementation courtesy Tad Hunt. initial re-implementation courtesy Tad Hunt.
...@@ -160,6 +161,21 @@ build_exc_ptr (void) ...@@ -160,6 +161,21 @@ build_exc_ptr (void)
return build0 (EXC_PTR_EXPR, ptr_type_node); return build0 (EXC_PTR_EXPR, ptr_type_node);
} }
/* Declare a function NAME, returning RETURN_TYPE, taking a single
parameter PARM_TYPE, with an empty exception specification.
Note that the C++ ABI document does not have a throw-specifier on
the routines declared below via this function. The declarations
are consistent with the actual implementations in libsupc++. */
static tree
declare_nothrow_library_fn (tree name, tree return_type, tree parm_type)
{
tree tmp = tree_cons (NULL_TREE, parm_type, void_list_node);
return push_library_fn (name, build_function_type (return_type, tmp),
empty_except_spec);
}
/* Build up a call to __cxa_get_exception_ptr so that we can build a /* Build up a call to __cxa_get_exception_ptr so that we can build a
copy constructor for the thrown object. */ copy constructor for the thrown object. */
...@@ -171,9 +187,8 @@ do_get_exception_ptr (void) ...@@ -171,9 +187,8 @@ do_get_exception_ptr (void)
fn = get_identifier ("__cxa_get_exception_ptr"); fn = get_identifier ("__cxa_get_exception_ptr");
if (!get_global_value_if_present (fn, &fn)) if (!get_global_value_if_present (fn, &fn))
{ {
/* Declare void* __cxa_get_exception_ptr (void *). */ /* Declare void* __cxa_get_exception_ptr (void *) throw(). */
tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
} }
return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
...@@ -192,9 +207,8 @@ do_begin_catch (void) ...@@ -192,9 +207,8 @@ do_begin_catch (void)
fn = get_identifier ("__cxa_begin_catch"); fn = get_identifier ("__cxa_begin_catch");
if (!get_global_value_if_present (fn, &fn)) if (!get_global_value_if_present (fn, &fn))
{ {
/* Declare void* __cxa_begin_catch (void *). */ /* Declare void* __cxa_begin_catch (void *) throw(). */
tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node); fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
} }
return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (), return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
...@@ -543,9 +557,8 @@ do_allocate_exception (tree type) ...@@ -543,9 +557,8 @@ do_allocate_exception (tree type)
fn = get_identifier ("__cxa_allocate_exception"); fn = get_identifier ("__cxa_allocate_exception");
if (!get_global_value_if_present (fn, &fn)) if (!get_global_value_if_present (fn, &fn))
{ {
/* Declare void *__cxa_allocate_exception(size_t). */ /* Declare void *__cxa_allocate_exception(size_t) throw(). */
tree tmp = tree_cons (NULL_TREE, size_type_node, void_list_node); fn = declare_nothrow_library_fn (fn, ptr_type_node, size_type_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
} }
return cp_build_function_call (fn, return cp_build_function_call (fn,
...@@ -565,9 +578,8 @@ do_free_exception (tree ptr) ...@@ -565,9 +578,8 @@ do_free_exception (tree ptr)
fn = get_identifier ("__cxa_free_exception"); fn = get_identifier ("__cxa_free_exception");
if (!get_global_value_if_present (fn, &fn)) if (!get_global_value_if_present (fn, &fn))
{ {
/* Declare void __cxa_free_exception (void *). */ /* Declare void __cxa_free_exception (void *) throw(). */
fn = push_void_library_fn (fn, tree_cons (NULL_TREE, ptr_type_node, fn = declare_nothrow_library_fn (fn, void_type_node, ptr_type_node);
void_list_node));
} }
return cp_build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE), return cp_build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment