diff mbox

[C++] PR 51223

Message ID 4F1DF5A9.6060500@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Jan. 24, 2012, 12:04 a.m. UTC
Hi,

another diagnostic regression, a little subtler than the last one.

In this case, besides the final ICE (which was already there in 4.5), we 
also have a regression vs 4.6 in the error messages produced before it, 
that is, we have (see PR):

bug.cc:3:18: error: 'i' has incomplete type
bug.cc:3:19: error: invalid use of 'void'
bug.cc: In function 'void bar()':
bug.cc:8:11: error: call to 'A A::foo(<type error>)' uses the default argument
for parameter 1, which is not yet defined
bug.cc: At global scope:
bug.cc:11:15: error: 'i' has incomplete type
bug.cc:11:16: error: invalid use of 'void'
bug.cc: In function 'void bar()':
bug.cc:8:11: internal compiler error: tree check: expected class 'type', have
'exceptional' (error_mark) in useless_type_conversion_p, at tree-ssa.c:1460
Please submit a full bug report, [etc.]


which become, after the patch (note the confusing errors for line 8):

bug.cc:3:18: error: ‘i’ has incomplete type
bug.cc:3:18: error: invalid use of ‘void’
bug.cc:11:15: error: ‘i’ has incomplete type
bug.cc:11:16: error: invalid use of ‘void’


I checked that the error messages produced by Icc are quite similar, but 
2 single errors are produced instead of 2 pairs, saying that a parameter 
cannot have void type (if we wanted, it would be easy to do something 
similar by replacing the cxx_incomplete_type_error call in grokparms 
with just an error + couple of tweaks to the testsuite)

Tested x86_64-linux.

Paolo.

/////////////////////////////
/cp
2012-01-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51223
	* call.c (build_over_call): Check for error_mark_node as
	TREE_VALUE when default arguments are processed.

/testsuite
2012-01-23  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/51223
	* g++.dg/parse/crash58.C: New.

Comments

Jason Merrill Jan. 24, 2012, 2:12 a.m. UTC | #1
OK.

Jason
diff mbox

Patch

Index: testsuite/g++.dg/parse/crash58.C
===================================================================
--- testsuite/g++.dg/parse/crash58.C	(revision 0)
+++ testsuite/g++.dg/parse/crash58.C	(revision 0)
@@ -0,0 +1,16 @@ 
+// PR c++/51223
+
+struct A
+{
+  A foo(void i = 0);  // { dg-error "incomplete type|invalid use" }
+};
+
+void bar()
+{
+  A().foo();
+}
+
+A A::foo(void i)  // { dg-error "incomplete type|invalid use" }
+{
+  return A();
+}
Index: cp/call.c
===================================================================
--- cp/call.c	(revision 183449)
+++ cp/call.c	(working copy)
@@ -6581,9 +6581,14 @@  build_over_call (struct z_candidate *cand, int fla
 
   /* Default arguments */
   for (; parm && parm != void_list_node; parm = TREE_CHAIN (parm), i++)
-    argarray[j++] = convert_default_arg (TREE_VALUE (parm),
-					 TREE_PURPOSE (parm),
-					 fn, i - is_method);
+    {
+      if (TREE_VALUE (parm) == error_mark_node)
+	return error_mark_node;
+      argarray[j++] = convert_default_arg (TREE_VALUE (parm),
+					   TREE_PURPOSE (parm),
+					   fn, i - is_method);
+    }
+
   /* Ellipsis */
   for (; arg_index < VEC_length (tree, args); ++arg_index)
     {