aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Merrill <jason@yorick.cygnus.com>1997-11-20 22:43:54 +0000
committerJason Merrill <jason@gcc.gnu.org>1997-11-20 17:43:54 -0500
commit047f64a30c8549da45fbf192ff685957888b310a (patch)
tree0997d31bc2c133e99650cba3c6eb49dce3e4e6db
parent7bb9fb0edfa79f0a70bf3d1cb0c41982c4f79128 (diff)
downloadgcc-047f64a30c8549da45fbf192ff685957888b310a.zip
gcc-047f64a30c8549da45fbf192ff685957888b310a.tar.gz
gcc-047f64a30c8549da45fbf192ff685957888b310a.tar.bz2
method.c (build_decl_overload_real): Don't mess with global placement delete.
* method.c (build_decl_overload_real): Don't mess with global placement delete. * init.c (build_new): Check for null throw spec, not nothrow_t. * decl.c (duplicate_decls): Don't complain about different exceptions from an internal declaration. * call.c (build_op_delete_call): Fix check for member fns again. * decl2.c (import_export_decl): Interface hackery affects virtual synthesized methods. From-SVN: r16612
-rw-r--r--gcc/cp/ChangeLog15
-rw-r--r--gcc/cp/call.c4
-rw-r--r--gcc/cp/decl.c3
-rw-r--r--gcc/cp/decl2.c3
-rw-r--r--gcc/cp/init.c34
-rw-r--r--gcc/cp/method.c14
6 files changed, 51 insertions, 22 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index b123b92..f1eeae5 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,18 @@
+Thu Nov 20 14:40:17 1997 Jason Merrill <jason@yorick.cygnus.com>
+
+ * method.c (build_decl_overload_real): Don't mess with global
+ placement delete.
+
+ * init.c (build_new): Check for null throw spec, not nothrow_t.
+
+ * decl.c (duplicate_decls): Don't complain about different exceptions
+ from an internal declaration.
+
+ * call.c (build_op_delete_call): Fix check for member fns again.
+
+ * decl2.c (import_export_decl): Interface hackery affects
+ virtual synthesized methods.
+
Wed Nov 19 18:24:14 1997 Jason Merrill <jason@yorick.cygnus.com>
* decl.c (start_decl): Don't just complain about a mismatched
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index d4ecb62..4e66a30 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -5182,8 +5182,8 @@ build_op_delete_call (code, addr, size, flags)
if (fn != error_mark_node)
{
- if (TREE_PURPOSE (fns))
- /* TREE_PURPOSE is only set for lists of member functions. */
+ if (TREE_CODE (TREE_VALUE (fns)) == TREE_LIST)
+ /* Member functions. */
enforce_access (TREE_PURPOSE (TREE_VALUE (fns)), fn);
return build_function_call (fn, expr_tree_cons (NULL_TREE, addr, args));
}
diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c
index 5cda56a..d1d19c7 100644
--- a/gcc/cp/decl.c
+++ b/gcc/cp/decl.c
@@ -2769,7 +2769,8 @@ duplicate_decls (newdecl, olddecl)
TREE_TYPE (olddecl) = build_exception_variant (newtype,
TYPE_RAISES_EXCEPTIONS (oldtype));
- if ((pedantic || ! DECL_IN_SYSTEM_HEADER (olddecl))
+ if ((pedantic || (! DECL_IN_SYSTEM_HEADER (olddecl)
+ && DECL_SOURCE_LINE (olddecl) != 0))
&& flag_exceptions
&& ! compexcepttypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl)))
{
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c
index 9ee0287..3821cf3 100644
--- a/gcc/cp/decl2.c
+++ b/gcc/cp/decl2.c
@@ -2793,7 +2793,8 @@ import_export_decl (decl)
else if (DECL_FUNCTION_MEMBER_P (decl))
{
tree ctype = DECL_CLASS_CONTEXT (decl);
- if (CLASSTYPE_INTERFACE_KNOWN (ctype) && ! DECL_ARTIFICIAL (decl))
+ if (CLASSTYPE_INTERFACE_KNOWN (ctype)
+ && (! DECL_ARTIFICIAL (decl) || DECL_VINDEX (decl)))
{
DECL_NOT_REALLY_EXTERN (decl)
= ! (CLASSTYPE_INTERFACE_ONLY (ctype)
diff --git a/gcc/cp/init.c b/gcc/cp/init.c
index c5604e1..7100b565 100644
--- a/gcc/cp/init.c
+++ b/gcc/cp/init.c
@@ -2452,16 +2452,6 @@ build_new (placement, decl, init, use_global_new)
return error_mark_node;
}
- /* If the first placement arg is of type nothrow_t, it's allowed to
- return 0 on allocation failure. */
- nothrow = (placement && TREE_VALUE (placement)
- && TREE_TYPE (TREE_VALUE (placement))
- && IS_AGGR_TYPE (TREE_TYPE (TREE_VALUE (placement)))
- && (TYPE_IDENTIFIER (TREE_TYPE (TREE_VALUE (placement)))
- == get_identifier ("nothrow_t")));
-
- check_new = flag_check_new || nothrow;
-
#if 1
/* Get a little extra space to store a couple of things before the new'ed
array, if this isn't the default placement new. */
@@ -2513,6 +2503,30 @@ build_new (placement, decl, init, use_global_new)
rval = cp_convert (build_pointer_type (true_type), rval);
}
+ /* unless an allocation function is declared with an empty excep-
+ tion-specification (_except.spec_), throw(), it indicates failure to
+ allocate storage by throwing a bad_alloc exception (clause _except_,
+ _lib.bad.alloc_); it returns a non-null pointer otherwise If the allo-
+ cation function is declared with an empty exception-specification,
+ throw(), it returns null to indicate failure to allocate storage and a
+ non-null pointer otherwise.
+
+ So check for a null exception spec on the op new we just called. */
+
+ nothrow = 0;
+ if (rval)
+ {
+ /* The CALL_EXPR. */
+ tree t = TREE_OPERAND (rval, 0);
+ /* The function. */
+ t = TREE_OPERAND (TREE_OPERAND (t, 0), 0);
+ t = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (t));
+
+ if (t && TREE_VALUE (t) == NULL_TREE)
+ nothrow = 1;
+ }
+ check_new = flag_check_new || nothrow;
+
if (flag_exceptions && rval)
{
/* This must last longer so we can use it in the cleanup.
diff --git a/gcc/cp/method.c b/gcc/cp/method.c
index 0e407fe..c16f6ea 100644
--- a/gcc/cp/method.c
+++ b/gcc/cp/method.c
@@ -1117,19 +1117,17 @@ build_decl_overload_real (dname, parms, ret_type, tparms, targs,
char *name = IDENTIFIER_POINTER (dname);
/* member operators new and delete look like methods at this point. */
- if (! for_method && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST)
+ if (! for_method && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST
+ && TREE_CHAIN (parms) == void_list_node)
{
if (dname == ansi_opname[(int) DELETE_EXPR])
return get_identifier ("__builtin_delete");
else if (dname == ansi_opname[(int) VEC_DELETE_EXPR])
return get_identifier ("__builtin_vec_delete");
- else if (TREE_CHAIN (parms) == void_list_node)
- {
- if (dname == ansi_opname[(int) NEW_EXPR])
- return get_identifier ("__builtin_new");
- else if (dname == ansi_opname[(int) VEC_NEW_EXPR])
- return get_identifier ("__builtin_vec_new");
- }
+ if (dname == ansi_opname[(int) NEW_EXPR])
+ return get_identifier ("__builtin_new");
+ else if (dname == ansi_opname[(int) VEC_NEW_EXPR])
+ return get_identifier ("__builtin_vec_new");
}
OB_INIT ();