diff mbox

[C++] PR c++/67846

Message ID 562E6C87.1040301@oracle.com
State New
Headers show

Commit Message

Paolo Carlini Oct. 26, 2015, 6:10 p.m. UTC
Hi,

in mainline this ICE on invalid doesn't exist anymore but we may want to 
avoid issuing the additional redundant "error: cannot convert ‘A::foo’ 
from type ‘void (A::)()’ to type ‘void (A::*)()’" and/or make the error 
message more informative by printing the member used invalidly. Tested 
x86_64-linux.

Thanks, Paolo.

///////////////////////
/cp
2015-10-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67846
	* parser.c (cp_parser_lambda_body): Check lambda_return_type
	return value.
	* typeck2.c (cxx_incomplete_type_diagnostic): Print member or
	member function used invalidly.

/testsuite
2015-10-26  Paolo Carlini  <paolo.carlini@oracle.com>

	PR c++/67846
	* g++.dg/cpp0x/lambda/lambda-ice15.C: New.

Comments

Paolo Carlini Nov. 5, 2015, 3:41 p.m. UTC | #1
Hi,

pinging this (admittedly minor) issue...

On 10/26/2015 07:10 PM, Paolo Carlini wrote:
> Hi,
>
> in mainline this ICE on invalid doesn't exist anymore but we may want 
> to avoid issuing the additional redundant "error: cannot convert 
> ‘A::foo’ from type ‘void (A::)()’ to type ‘void (A::*)()’" and/or make 
> the error message more informative by printing the member used 
> invalidly. Tested x86_64-linux.

     https://gcc.gnu.org/ml/gcc-patches/2015-10/msg02795.html

Thanks,
Paolo.
diff mbox

Patch

Index: cp/parser.c
===================================================================
--- cp/parser.c	(revision 229351)
+++ cp/parser.c	(working copy)
@@ -9892,7 +9892,12 @@  cp_parser_lambda_body (cp_parser* parser, tree lam
 	if (cp_parser_parse_definitely (parser))
 	  {
 	    if (!processing_template_decl)
-	      apply_deduced_return_type (fco, lambda_return_type (expr));
+	      {
+		tree type = lambda_return_type (expr);
+		apply_deduced_return_type (fco, type);
+		if (type == error_mark_node)
+		  expr = error_mark_node;
+	      }
 
 	    /* Will get error here if type not deduced yet.  */
 	    finish_return_stmt (expr);
Index: cp/typeck2.c
===================================================================
--- cp/typeck2.c	(revision 229351)
+++ cp/typeck2.c	(working copy)
@@ -517,12 +517,12 @@  cxx_incomplete_type_diagnostic (const_tree value,
 	if (DECL_FUNCTION_MEMBER_P (member)
 	    && ! flag_ms_extensions)
 	  emit_diagnostic (diag_kind, input_location, 0,
-			   "invalid use of member function "
-			   "(did you forget the %<()%> ?)");
+			   "invalid use of member function %qD "
+			   "(did you forget the %<()%> ?)", member);
 	else
 	  emit_diagnostic (diag_kind, input_location, 0,
-			   "invalid use of member "
-			   "(did you forget the %<&%> ?)");
+			   "invalid use of member %qD "
+			   "(did you forget the %<&%> ?)", member);
       }
       break;
 
Index: testsuite/g++.dg/cpp0x/lambda/lambda-ice15.C
===================================================================
--- testsuite/g++.dg/cpp0x/lambda/lambda-ice15.C	(revision 0)
+++ testsuite/g++.dg/cpp0x/lambda/lambda-ice15.C	(working copy)
@@ -0,0 +1,10 @@ 
+// PR c++/67846
+// { dg-do compile { target c++11 } }
+
+class A
+{
+  void foo ()
+  {
+    [=] { return foo; };  // { dg-error "invalid use of member function" }
+  }
+};