re PR c++/29001 (ICE on invalid return from operator new)
authorPaolo Carlini <pcarlini@suse.de>
Tue, 24 Jul 2007 11:08:27 +0000 (11:08 +0000)
committerPaolo Carlini <paolo@gcc.gnu.org>
Tue, 24 Jul 2007 11:08:27 +0000 (11:08 +0000)
/cp
2007-07-24  Paolo Carlini  <pcarlini@suse.de>

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

2007-07-24  Paolo Carlini  <pcarlini@suse.de>

PR c++/32561
* decl.c (redeclaration_error_message): Call DECL_ANON_UNION_VAR_P
only on VAR_DECL.

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

PR c++/29001
* g++.dg/init/new22.C: New.

2007-07-24  Paolo Carlini  <pcarlini@suse.de>

PR c++/32561
* g++.dg/template/crash67.C: New.

From-SVN: r126873

gcc/cp/ChangeLog
gcc/cp/decl.c
gcc/cp/typeck.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/new22.C [new file with mode: 0644]
gcc/testsuite/g++.dg/template/crash67.C [new file with mode: 0644]

index 39da6aa..f0ea30b 100644 (file)
@@ -1,3 +1,15 @@
+2007-07-24  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/29001
+       * typeck.c (check_return_expr): Do not pass a null argument
+       to null_ptr_cst_p.
+
+2007-07-24  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32561
+       * decl.c (redeclaration_error_message): Call DECL_ANON_UNION_VAR_P
+       only on VAR_DECL.
+
 2007-07-22  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/32839
index 8b6684c..e3c70a5 100644 (file)
@@ -2195,8 +2195,8 @@ redeclaration_error_message (tree newdecl, tree olddecl)
           union { int i; };
 
           is invalid.  */
-      if (DECL_ANON_UNION_VAR_P (newdecl)
-         || DECL_ANON_UNION_VAR_P (olddecl))
+      if ((TREE_CODE (newdecl) == VAR_DECL && DECL_ANON_UNION_VAR_P (newdecl))
+         || (TREE_CODE (olddecl) == VAR_DECL && DECL_ANON_UNION_VAR_P (olddecl)))
        return "redeclaration of %q#D";
       /* If at least one declaration is a reference, there is no
         conflict.  For example:
index 7a1a725..51deeb2 100644 (file)
@@ -6639,7 +6639,7 @@ check_return_expr (tree retval, bool *no_warning)
        || 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))
+      && 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 486bc88..08d34cd 100644 (file)
@@ -1,3 +1,13 @@
+2007-07-24  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/29001
+       * g++.dg/init/new22.C: New.
+
+2007-07-24  Paolo Carlini  <pcarlini@suse.de>
+
+       PR c++/32561
+       * g++.dg/template/crash67.C: New.
+
 2007-07-24  Dorit Nuzman  <dorit@il.ibm.com>
 
        * lib/target-support.exp (check_effective_target_natural_alignment): 
diff --git a/gcc/testsuite/g++.dg/init/new22.C b/gcc/testsuite/g++.dg/init/new22.C
new file mode 100644 (file)
index 0000000..2ce51ff
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/29001
+
+void* operator new (__SIZE_TYPE__) { return; } // { dg-error "with no value" }
diff --git a/gcc/testsuite/g++.dg/template/crash67.C b/gcc/testsuite/g++.dg/template/crash67.C
new file mode 100644 (file)
index 0000000..c80f4fb
--- /dev/null
@@ -0,0 +1,3 @@
+// PR c++/32561
+
+template<int N, int N> struct A; // { dg-error "redefinition|declared" }