aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Mitchell <mmitchell@usa.net>1998-03-26 10:26:43 +0000
committerMark Mitchell <mmitchel@gcc.gnu.org>1998-03-26 10:26:43 +0000
commit734e8cc58d21461977376ab50dbe4bb7fb845dbc (patch)
tree9cdea081ec25a3df69ca00e4a7953aaa984c5608
parent17b75c9182d0201a0cc1362c5f0ab1fcddb02c5d (diff)
downloadgcc-734e8cc58d21461977376ab50dbe4bb7fb845dbc.zip
gcc-734e8cc58d21461977376ab50dbe4bb7fb845dbc.tar.gz
gcc-734e8cc58d21461977376ab50dbe4bb7fb845dbc.tar.bz2
call.c (build_object_call): Complain about ambiguous operator(), rather that crashing.
* call.c (build_object_call): Complain about ambiguous operator(), rather that crashing. (build_new_op): Likewise. (build_op_delete_call): Likewise. From-SVN: r18839
-rw-r--r--gcc/cp/ChangeLog7
-rw-r--r--gcc/cp/call.c23
-rw-r--r--gcc/testsuite/g++.old-deja/g++.other/ambig1.C28
3 files changed, 55 insertions, 3 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 7e66527..a7ad337 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -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
diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 8db795b..880fce4 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -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
index 0000000..04e4afa
--- /dev/null
+++ b/gcc/testsuite/g++.old-deja/g++.other/ambig1.C
@@ -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
+}
+