re PR c++/15967 (ICE on ambiguous operator new in class hierarchy)
authorGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 15 Jun 2004 01:46:21 +0000 (01:46 +0000)
committerGiovanni Bajo <giovannibajo@gcc.gnu.org>
Tue, 15 Jun 2004 01:46:21 +0000 (01:46 +0000)
PR c++/15967
* search.c (lookup_field): Propagate the ambiguity list.
(lookup_fnfields): Likewise.

PR c++/15967
* g++.dg/lookup/crash3.C: New test.

From-SVN: r83158

gcc/cp/ChangeLog
gcc/cp/search.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/lookup/crash3.C [new file with mode: 0644]

index 7148f222edcf0414bf45aecb5fe94e62662e0f62..1fc8ec0fbab93e23c56b14d0369aa1a55f6027a1 100644 (file)
@@ -1,3 +1,9 @@
+2004-06-14  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/15967
+       * search.c (lookup_field): Propagate the ambiguity list.
+       (lookup_fnfields): Likewise.
+
 2004-06-14  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/15947
index 5f4c91c3ec0beaffc0956cd91223dba2662a77be..ca86b13dedba6091e4254773696237fe554668aa 100644 (file)
@@ -1332,8 +1332,9 @@ lookup_field (tree xbasetype, tree name, int protect, bool want_type)
 {
   tree rval = lookup_member (xbasetype, name, protect, want_type);
   
-  /* Ignore functions.  */
-  if (rval && BASELINK_P (rval))
+  /* Ignore functions, but propagate the ambiguity list.  */
+  if (!error_operand_p (rval)
+      && (rval && BASELINK_P (rval)))
     return NULL_TREE;
 
   return rval;
@@ -1347,8 +1348,9 @@ lookup_fnfields (tree xbasetype, tree name, int protect)
 {
   tree rval = lookup_member (xbasetype, name, protect, /*want_type=*/false);
 
-  /* Ignore non-functions.  */
-  if (rval && !BASELINK_P (rval))
+  /* Ignore non-functions, but propagate the ambiguity list.  */
+  if (!error_operand_p (rval)
+      && (rval && !BASELINK_P (rval)))
     return NULL_TREE;
 
   return rval;
index 7ec7738ddee4861fcc6d73f06b864dccaace80b7..79a8417552664b89b6376ac1d71055fe58b7f1d1 100644 (file)
@@ -1,3 +1,8 @@
+2004-06-14  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
+
+       PR c++/15967
+       * g++.dg/lookup/crash3.C: New test.
+
 2004-06-14  Giovanni Bajo  <giovannibajo@gcc.gnu.org>
 
        PR c++/15947
diff --git a/gcc/testsuite/g++.dg/lookup/crash3.C b/gcc/testsuite/g++.dg/lookup/crash3.C
new file mode 100644 (file)
index 0000000..ef025fa
--- /dev/null
@@ -0,0 +1,15 @@
+// { dg-do compile }
+// Contributed by Wolfgang Wieser <wwieser at gmx dot de>
+// PR c++/15967: ICE with ambiguous operator new
+
+typedef unsigned int size_t; 
+
+struct A { void *operator new(size_t s){} };  // { dg-error "operator new" }
+struct B { void *operator new(size_t s){} };  // { dg-error "operator new" }
+
+struct C : A,B {}; 
+
+int crash() 
+{
+  C *c=new C();   // { dg-error "ambiguous" }
+}