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
This commit is contained in:
Paolo Carlini 2008-07-27 15:49:12 +00:00 committed by Paolo Carlini
parent 0d52899f78
commit 448083e540
4 changed files with 56 additions and 24 deletions

View File

@ -1,3 +1,17 @@
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>
* typeck.c (inline_conversion): Remove.

View File

@ -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_unbound_class_template (tree, tree, tree, tsubst_flags_t);
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_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_throw_library_fn (tree, tree);
extern tree check_tag_decl (cp_decl_specifier_seq *);

View File

@ -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,
callers should unset TREE_NOTHROW. */
tree
static tree
build_library_fn (tree name, tree 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)
}
/* 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
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);
return fn;
}
@ -3659,7 +3665,7 @@ tree
push_void_library_fn (tree name, tree 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
@ -3668,7 +3674,7 @@ push_void_library_fn (tree name, tree parmtypes)
tree
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_NOTHROW (fn) = 0;
return fn;
@ -6169,9 +6175,10 @@ expand_static_init (tree decl, tree init)
void_list_node);
tree vfntype = build_function_type (void_type_node, argtypes);
acquire_fn = push_library_fn
(acquire_fn, build_function_type (integer_type_node, argtypes));
release_fn = push_library_fn (release_fn, vfntype);
abort_fn = push_library_fn (abort_fn, vfntype);
(acquire_fn, build_function_type (integer_type_node, argtypes),
NULL_TREE);
release_fn = push_library_fn (release_fn, vfntype, NULL_TREE);
abort_fn = push_library_fn (abort_fn, vfntype, NULL_TREE);
}
else
{

View File

@ -1,6 +1,7 @@
/* Handle exceptional things in C++.
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>
Rewritten by Mike Stump <mrs@cygnus.com>, based upon an
initial re-implementation courtesy Tad Hunt.
@ -160,6 +161,21 @@ build_exc_ptr (void)
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
copy constructor for the thrown object. */
@ -171,9 +187,8 @@ do_get_exception_ptr (void)
fn = get_identifier ("__cxa_get_exception_ptr");
if (!get_global_value_if_present (fn, &fn))
{
/* Declare void* __cxa_get_exception_ptr (void *). */
tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
/* Declare void* __cxa_get_exception_ptr (void *) throw(). */
fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
}
return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
@ -192,9 +207,8 @@ do_begin_catch (void)
fn = get_identifier ("__cxa_begin_catch");
if (!get_global_value_if_present (fn, &fn))
{
/* Declare void* __cxa_begin_catch (void *). */
tree tmp = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
/* Declare void* __cxa_begin_catch (void *) throw(). */
fn = declare_nothrow_library_fn (fn, ptr_type_node, ptr_type_node);
}
return cp_build_function_call (fn, tree_cons (NULL_TREE, build_exc_ptr (),
@ -543,9 +557,8 @@ do_allocate_exception (tree type)
fn = get_identifier ("__cxa_allocate_exception");
if (!get_global_value_if_present (fn, &fn))
{
/* Declare void *__cxa_allocate_exception(size_t). */
tree tmp = tree_cons (NULL_TREE, size_type_node, void_list_node);
fn = push_library_fn (fn, build_function_type (ptr_type_node, tmp));
/* Declare void *__cxa_allocate_exception(size_t) throw(). */
fn = declare_nothrow_library_fn (fn, ptr_type_node, size_type_node);
}
return cp_build_function_call (fn,
@ -565,9 +578,8 @@ do_free_exception (tree ptr)
fn = get_identifier ("__cxa_free_exception");
if (!get_global_value_if_present (fn, &fn))
{
/* Declare void __cxa_free_exception (void *). */
fn = push_void_library_fn (fn, tree_cons (NULL_TREE, ptr_type_node,
void_list_node));
/* Declare void __cxa_free_exception (void *) throw(). */
fn = declare_nothrow_library_fn (fn, void_type_node, ptr_type_node);
}
return cp_build_function_call (fn, tree_cons (NULL_TREE, ptr, NULL_TREE),