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]

[patch] Fix PR c++/23965: Bogus error message with "<type error>"


For the testcase

  template<typename T> void foo(T);

  void bar()
  {
    struct A a;
    foo(a);
  }

the we get the following error message since GCC 3.4.0:

  bug.cc: In function 'void bar()':
  bug.cc:5: error: aggregate 'A a' has incomplete type and cannot be defined
  bug.cc:6: error: no matching function for call to 'foo(<type error>)'

Although not completely bogus, the last line is not very helpful here.
Since "a" has error_mark_node as type, overload resolution just won't
work. In fact we shouldn't perform overload analysis here at all IMHO.

The following patch lets resolve_args reject arguments whose TREE_TYPE
is error_mark_node. This prevents overload resolution. (Btw, we are
already doing this for arguments of type "void".)

The patch also modifies the testcase g++.dg/template/error1.C
to refuse the bogus message.

Bootstrapped and regtested on i686-pc-linux-gnu.
Ok for mainline, 4.0 branch (once unfrozen) and 3.4 branch?

Regards,
Volker


2005-09-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/23965
	* call.c (resolve_args): Return error_mark_node on arguments
	whose TREE_TYPE is error_mark_node.

===================================================================
--- gcc/gcc/cp/call.c	6 Sep 2005 14:55:03 -0000	1.551
+++ gcc/gcc/cp/call.c	18 Sep 2005 02:16:44 -0000
@@ -2689,7 +2689,7 @@ resolve_args (tree args)
     {
       tree arg = TREE_VALUE (t);
 
-      if (arg == error_mark_node)
+      if (arg == error_mark_node || TREE_TYPE (arg) == error_mark_node)
 	return error_mark_node;
       else if (VOID_TYPE_P (TREE_TYPE (arg)))
 	{
===================================================================


2005-09-19  Volker Reichelt  <reichelt@igpm.rwth-aachen.de>

	PR c++/23965
	* g++.dg/template/error1.C: Do not accept "no matching function"
	message.

===================================================================
--- gcc/gcc/testsuite/g++.dg/template/error1.C	2 Jul 2003 09:41:52 -0000	1.1
+++ gcc/gcc/testsuite/g++.dg/template/error1.C	19 Sep 2005 13:45:55 -0000
@@ -9,5 +9,5 @@ template <class T> void make_pair(T x);
 
 void foo(){
   struct fps_chan_ID fps; // { dg-error "incomplete" "" }
-  make_pair(fps); // { dg-error "no matching function" "" }
+  make_pair(fps);         // { dg-bogus "no matching function" "" }
 }
===================================================================



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