This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++ PATCH: Reorganize function-call machinery




--On Friday, August 02, 2002 09:33:00 AM +0100 Jason Merrill <jason@redhat.com> wrote:

This patch changes the error message for this testcase

  struct A { int f (); };
  struct B { int f (); };
  struct C: public A, public B { };

  int main ()
  {
    C* cp;
    cp->f();
  }

Please fix.
Tested on i686-pc-linux-gnu, applied on the mainline.

--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com

2002-08-02 Mark Mitchell <mark@codesourcery.com>

* call.c (build_method_call): Issue a more helpful error message
about ambiguous method names.

Index: call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.325
diff -c -p -r1.325 call.c
*** call.c 2 Aug 2002 11:57:21 -0000 1.325
--- call.c 2 Aug 2002 18:47:48 -0000
*************** build_method_call (instance, name, parms
*** 545,555 ****
else if (DECL_P (name))
name = DECL_NAME (name);
if (has_template_args)
! fn = lookup_fnfields (object_type, name, /*protect=*/0);
else
! fn = lookup_member (object_type, name, /*protect=*/0,
! /*want_type=*/0);

/* If the name could not be found, issue an error. */
if (!fn)
{
--- 545,561 ----
else if (DECL_P (name))
name = DECL_NAME (name);
if (has_template_args)
! fn = lookup_fnfields (object_type, name, /*protect=*/2);
else
! fn = lookup_member (object_type, name, /*protect=*/2, /*want_type=*/0);

+ if (fn && TREE_CODE (fn) == TREE_LIST && !BASELINK_P (fn))
+ {
+ error ("request for member `%D' is ambiguous", name);
+ print_candidates (fn);
+ return error_mark_node;
+ }
+
/* If the name could not be found, issue an error. */
if (!fn)
{


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]