Hello,

I noticed when writing the patch that assumes operator new doesn't return 0 that without including <new> we weren't setting operator_new_flag on the implicit declaration of operator new.

Bootstrap+testsuite on x86_64-unknown-linux-gnu.

2013-10-04  Marc Glisse  <marc.gli...@inria.fr>

        PR c++/19476
gcc/cp/
        * decl.c (cxx_init_decl_processing): Set operator_new_flag.

gcc/testsuite/
        * g++.dg/tree-ssa/pr19476-5.C: New file.
        * g++.dg/tree-ssa/pr19476-1.C: Mention pr19476-5.C.

--
Marc Glisse
Index: cp/decl.c
===================================================================
--- cp/decl.c   (revision 203181)
+++ cp/decl.c   (working copy)
@@ -3793,22 +3793,22 @@ cxx_init_decl_processing (void)
     init_attributes ();
     extvisattr = build_tree_list (get_identifier ("externally_visible"),
                                  NULL_TREE);
     newattrs = tree_cons (get_identifier ("alloc_size"),
                          build_tree_list (NULL_TREE, integer_one_node),
                          extvisattr);
     newtype = cp_build_type_attribute_variant (ptr_ftype_sizetype, newattrs);
     newtype = build_exception_variant (newtype, new_eh_spec);
     deltype = cp_build_type_attribute_variant (void_ftype_ptr, extvisattr);
     deltype = build_exception_variant (deltype, empty_except_spec);
-    push_cp_library_fn (NEW_EXPR, newtype, 0);
-    push_cp_library_fn (VEC_NEW_EXPR, newtype, 0);
+    DECL_IS_OPERATOR_NEW (push_cp_library_fn (NEW_EXPR, newtype, 0)) = 1;
+    DECL_IS_OPERATOR_NEW (push_cp_library_fn (VEC_NEW_EXPR, newtype, 0)) = 1;
     global_delete_fndecl = push_cp_library_fn (DELETE_EXPR, deltype, 
ECF_NOTHROW);
     push_cp_library_fn (VEC_DELETE_EXPR, deltype, ECF_NOTHROW);
 
     nullptr_type_node = make_node (NULLPTR_TYPE);
     TYPE_SIZE (nullptr_type_node) = bitsize_int (GET_MODE_BITSIZE (ptr_mode));
     TYPE_SIZE_UNIT (nullptr_type_node) = size_int (GET_MODE_SIZE (ptr_mode));
     TYPE_UNSIGNED (nullptr_type_node) = 1;
     TYPE_PRECISION (nullptr_type_node) = GET_MODE_BITSIZE (ptr_mode);
     SET_TYPE_MODE (nullptr_type_node, ptr_mode);
     record_builtin_type (RID_MAX, "decltype(nullptr)", nullptr_type_node);
Index: testsuite/g++.dg/tree-ssa/pr19476-1.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr19476-1.C       (revision 203181)
+++ testsuite/g++.dg/tree-ssa/pr19476-1.C       (working copy)
@@ -1,13 +1,14 @@
 /* { dg-do compile } */
 /* { dg-options "-O -fdump-tree-ccp1" } */
 
+// See pr19476-5.C for a version without including <new>.
 #include <new>
 
 int f(){
   return 33 + (0 == new(std::nothrow) int);
 }
 int g(){
   return 42 + (0 == new int[50]);
 }
 
 /* { dg-final { scan-tree-dump     "return 42" "ccp1" } } */
Index: testsuite/g++.dg/tree-ssa/pr19476-5.C
===================================================================
--- testsuite/g++.dg/tree-ssa/pr19476-5.C       (revision 0)
+++ testsuite/g++.dg/tree-ssa/pr19476-5.C       (working copy)
@@ -0,0 +1,11 @@
+/* { dg-do compile } */
+/* { dg-options "-O -fdump-tree-ccp1" } */
+
+// See pr19476-1.C for a version that includes <new>.
+
+int g(){
+  return 42 + (0 == new int[50]);
+}
+
+/* { dg-final { scan-tree-dump     "return 42" "ccp1" } } */
+/* { dg-final { cleanup-tree-dump "ccp1" } } */

Property changes on: testsuite/g++.dg/tree-ssa/pr19476-5.C
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision URL
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property

Reply via email to