OSDN Git Service

PR c++/22508
authorreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Aug 2005 17:03:33 +0000 (17:03 +0000)
committerreichelt <reichelt@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 8 Aug 2005 17:03:33 +0000 (17:03 +0000)
* init.c (build_new_1): Check for empty candidate list.

* g++.dg/init/new13.C: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@102863 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/cp/ChangeLog
gcc/cp/init.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/init/new13.C [new file with mode: 0644]

index 6220be6..f8ca474 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-08  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22508
+       * init.c (build_new_1): Check for empty candidate list.
+
 2005-08-06  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
 
        PR c++/23191
index 9383e92..a2fcc1f 100644 (file)
@@ -1918,6 +1918,11 @@ build_new_1 (tree exp)
          args = tree_cons (NULL_TREE, size, placement);
          /* Do name-lookup to find the appropriate operator.  */
          fns = lookup_fnfields (elt_type, fnname, /*protect=*/2);
+         if (fns == NULL_TREE)
+           {
+             error ("no suitable %qD found in class %qT", fnname, elt_type);
+             return error_mark_node;
+           }
          if (TREE_CODE (fns) == TREE_LIST)
            {
              error ("request for member %qD is ambiguous", fnname);
index 77cf633..4a79bf8 100644 (file)
@@ -1,3 +1,8 @@
+2005-08-08  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>
+
+       PR c++/22508
+       * g++.dg/init/new13.C: New test.
+
 2005-08-08  Nathan Sidwell  <nathan@codesourcery.com>
 
        PR c++/21166
diff --git a/gcc/testsuite/g++.dg/init/new13.C b/gcc/testsuite/g++.dg/init/new13.C
new file mode 100644 (file)
index 0000000..3563c48
--- /dev/null
@@ -0,0 +1,11 @@
+// PR c++/22508
+// ICE on invalid operator new
+// Origin: Flash Sheridan  <flash@pobox.com>
+// { dg-do compile }
+
+struct A
+{
+  void* operator new(__SIZE_TYPE__) throw(X);  // { dg-error "" }
+};
+
+A* p = new A;                                  // { dg-error "no suitable" }