This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C++ Patch] PR 29001


Hi,

tested x86_64-linux. Ok for mainline?

Paolo.

///////////////
/cp
2007-07-13  Paolo Carlini  <pcarlini@suse.de>

	PR c++/29001
	* typeck.c (check_return_expr): Do not pass a null argument
	to null_ptr_cst_p.

/testsuite
2007-07-13  Paolo Carlini  <pcarlini@suse.de>

	PR c++/29001
	* g++.dg/init/new22.C: New.
Index: testsuite/g++.dg/init/new22.C
===================================================================
*** testsuite/g++.dg/init/new22.C	(revision 0)
--- testsuite/g++.dg/init/new22.C	(revision 0)
***************
*** 0 ****
--- 1,3 ----
+ // PR c++/29001
+ 
+ void* operator new (__SIZE_TYPE__) { return; } // { dg-error "with no value" }
Index: cp/typeck.c
===================================================================
*** cp/typeck.c	(revision 126592)
--- cp/typeck.c	(working copy)
*************** check_return_expr (tree retval, bool *no
*** 6643,6649 ****
         || DECL_OVERLOADED_OPERATOR_P (current_function_decl) == VEC_NEW_EXPR)
        && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
        && ! flag_check_new
!       && null_ptr_cst_p (retval))
      warning (0, "%<operator new%> must not return NULL unless it is "
  	     "declared %<throw()%> (or -fcheck-new is in effect)");
  
--- 6643,6649 ----
         || DECL_OVERLOADED_OPERATOR_P (current_function_decl) == VEC_NEW_EXPR)
        && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
        && ! flag_check_new
!       && retval && null_ptr_cst_p (retval))
      warning (0, "%<operator new%> must not return NULL unless it is "
  	     "declared %<throw()%> (or -fcheck-new is in effect)");
  

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]