]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
call.c (build_object_call): Complain about ambiguous operator(), rather that crashing.
authorMark Mitchell <mmitchell@usa.net>
Thu, 26 Mar 1998 10:26:43 +0000 (10:26 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Thu, 26 Mar 1998 10:26:43 +0000 (10:26 +0000)
* call.c (build_object_call): Complain about ambiguous operator(),
rather that crashing.
(build_new_op): Likewise.
(build_op_delete_call): Likewise.

From-SVN: r18839

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/g++.old-deja/g++.other/ambig1.C [new file with mode: 0644]

index 7e665274fb994220fa2fed74443beaed93a642f1..a7ad3374308f4ba1c322b1afbc3fc7568db2d76a 100644 (file)
@@ -1,3 +1,10 @@
+Thu Mar 26 10:24:05 1998  Mark Mitchell  <mmitchell@usa.net>
+
+       * call.c (build_object_call): Complain about ambiguous operator(),
+       rather that crashing.
+       (build_new_op): Likewise.
+       (build_op_delete_call): Likewise.
+
 Thu Mar 26 10:23:24 1998  Mark Mitchell  <mmitchell@usa.net>
 
        * cvt.c (perform_qualification_conversions): Use comp_target_types
index 8db795bf8c393750e044f630f231adeca370abcf..880fce419ae81bde991265f314a0bbbd2565bacc 100644 (file)
@@ -2288,7 +2288,9 @@ build_object_call (obj, args)
       return error_mark_node;
     }
 
-  fns = lookup_fnfields (TYPE_BINFO (type), ansi_opname [CALL_EXPR], 0);
+  fns = lookup_fnfields (TYPE_BINFO (type), ansi_opname [CALL_EXPR], 1);
+  if (fns == error_mark_node)
+    return error_mark_node;
 
   args = resolve_args (args);
 
@@ -2568,7 +2570,11 @@ build_new_op (code, flags, arg1, arg2, arg3)
     }
 
   if (IS_AGGR_TYPE (TREE_TYPE (arg1)))
-    fns = lookup_fnfields (TYPE_BINFO (TREE_TYPE (arg1)), fnname, 0);
+    {
+      fns = lookup_fnfields (TYPE_BINFO (TREE_TYPE (arg1)), fnname, 1);
+      if (fns == error_mark_node)
+       return fns;
+    }
   else
     fns = NULL_TREE;
 
@@ -2862,7 +2868,18 @@ build_op_delete_call (code, addr, size, flags)
   fnname = ansi_opname[code];
 
   if (IS_AGGR_TYPE (type) && ! (flags & LOOKUP_GLOBAL))
-    fns = lookup_fnfields (TYPE_BINFO (type), fnname, 0);
+    /* In [class.free]
+
+       If the result of the lookup is ambiguous or inaccessible, or if
+       the lookup selects a placement deallocation function, the
+       program is ill-formed.
+  
+       Therefore, we ask lookup_fnfields to complain ambout ambiguity.  */
+    {
+      fns = lookup_fnfields (TYPE_BINFO (type), fnname, 1);
+      if (fns == error_mark_node)
+       return error_mark_node;
+    }
   else
     fns = NULL_TREE;
 
diff --git a/gcc/testsuite/g++.old-deja/g++.other/ambig1.C b/gcc/testsuite/g++.old-deja/g++.other/ambig1.C
new file mode 100644 (file)
index 0000000..04e4afa
--- /dev/null
@@ -0,0 +1,28 @@
+// Build don't link:
+
+struct A {
+  int operator ++();
+  void operator ()();
+  void operator delete(void*);
+};
+
+struct B {
+  int operator ++(int);
+  void operator ()();
+  void operator delete(void*);
+  void f();
+};
+
+struct C : public A, public B {
+};
+
+void f()
+{
+  C c;
+  C* cp;
+  
+  delete cp; // ERROR - ambiguous
+  c(); // ERROR - ambiguous
+  c++; // ERROR - ambiguous
+}
+