From: Jason Merrill Date: Thu, 20 Nov 1997 22:42:37 +0000 (+0000) Subject: method.c (build_decl_overload_real): Don't mess with global placement delete. X-Git-Tag: releases/egcs-1.0.0~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b957dce210ea94e25024764c8781aa90a11293cb;p=thirdparty%2Fgcc.git 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: r16611 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 765d843878b8..99f18d1f8777 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,18 @@ +Thu Nov 20 14:40:17 1997 Jason Merrill + + * 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 * decl.c (start_decl): Don't just complain about a mismatched diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d4ecb62cd857..4e66a307e934 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 35a9a4b0ba2d..b60f842fa43b 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 9c2d8074e156..5716af214d1e 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 c5604e14681d..7100b565a838 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 0e407fe1ab8c..c16f6eaf02f6 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 ();