From: Mark Mitchell Date: Thu, 26 Mar 1998 10:26:43 +0000 (+0000) Subject: call.c (build_object_call): Complain about ambiguous operator(), rather that crashing. X-Git-Tag: prereleases/egcs-1.1-prerelease~1949 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=734e8cc58d21461977376ab50dbe4bb7fb845dbc;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7e665274fb99..a7ad3374308f 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +Thu Mar 26 10:24:05 1998 Mark Mitchell + + * 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 * cvt.c (perform_qualification_conversions): Use comp_target_types diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 8db795bf8c39..880fce419ae8 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 000000000000..04e4afa1205b --- /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 +} +