This is the mail archive of the 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]

PATCH method call on undefined class

Here is a patch to gcc/cp/call.c which changes the error message to
something more informative, if you try to invoke a method on an
incomplete type.
Here's a test program
class A;

void Foo(A *a)
  int g = a->m;
Currently the diagnostic on the first two calls are
	incomplete.ii:5: no matching function for call to `A::Fn ()'
the new diagnostic is
	incomplete.ii:5: invalid use of undefined type `class A'
the final call implicit cast to in, already gives this diagnostic

Somewhat more informative don't you think?

Dr Nathan Sidwell :: Computer Science Department :: Bristol University
      You can up the bandwidth, but you can't up the speed of light

Mon Sep  7 12:30:05 BST 1998  Nathan Sidwell  <>

	* call.c (build_new_method_call): Issue 'incomplete type' error,
	if class is not defined.

Index: gcc/cp/call.c
RCS file: /egcs/carton/cvsfiles/egcs/gcc/cp/call.c,v
retrieving revision
diff -b -c -3 -p -r1.92.2.6 call.c
*** call.c	1998/07/28 14:00:08
--- call.c	1998/09/07 11:29:38
*************** build_new_method_call (instance, name, a
*** 3672,3677 ****
--- 3672,3680 ----
	/* XXX will LOOKUP_SPECULATIVELY be needed when this is done?  */
	return NULL_TREE;
+       if (TYPE_SIZE (basetype) == 0)
+ 	incomplete_type_error (instance_ptr, basetype);
+       else
	cp_error ("no matching function for call to `%T::%D (%A)%V'", basetype,
		pretty_name, user_args, TREE_TYPE (TREE_TYPE (instance_ptr)));
	print_z_candidates (candidates);

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