diff mbox

[3/3] Support dumping type bindings in lambda diagnostics.

Message ID 1376250573-13753-4-git-send-email-adam@jessamine.co.uk
State New
Headers show

Commit Message

Adam Butcher Aug. 11, 2013, 7:49 p.m. UTC
* error.c (dump_function_decl): Use standard diagnostic flow to dump a
	lambda diagnostic, albeit without stating the function name or
	duplicating the parameter spec (which is dumped as part of the type).
---
 gcc/cp/error.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

Comments

Jason Merrill Aug. 27, 2013, 4:47 p.m. UTC | #1
This patch doesn't seem to depend on the others; go ahead and apply it.

Jason
Adam Butcher Aug. 27, 2013, 6:46 p.m. UTC | #2
Hi Jason,

Was just about to compose a mail to gcc-patches...  Been busy, then 
ill, now just about ready to submit a new set of diffs.

On 27.08.2013 17:47, Jason Merrill wrote:
>
> This patch doesn't seem to depend on the others; go ahead and apply 
> it.
>
Okay.  As it stands, it means that you get an additional 'const' in 
diagnostics for lambda's not declared 'mutable'.  I didn't think this to 
be necessarily a bad thing (distinguishing between 'mutable' and 'plain' 
lambdas and pointing at the cause for possible user error attempting to 
write to by-value captures) but it's probably contentious.  Do you want 
me to ditch the 'const' output prior to pushing?

Cheers,
Adam
Jason Merrill Aug. 27, 2013, 11:55 p.m. UTC | #3
On 08/27/2013 02:46 PM, Adam Butcher wrote:
> Okay.  As it stands, it means that you get an additional 'const' in
> diagnostics for lambda's not declared 'mutable'.

Hmm, I guess it would be preferable to use 'mutable' or nothing when 
printing the lambda just like when declaring one.

Jason
diff mbox

Patch

diff --git a/gcc/cp/error.c b/gcc/cp/error.c
index 440169a..bd5f8cc 100644
--- a/gcc/cp/error.c
+++ b/gcc/cp/error.c
@@ -1374,14 +1374,7 @@  dump_function_decl (tree t, int flags)
   int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME);
   tree exceptions;
   vec<tree, va_gc> *typenames = NULL;
-
-  if (DECL_NAME (t) && LAMBDA_FUNCTION_P (t))
-    {
-      /* A lambda's signature is essentially its "type", so defer.  */
-      gcc_assert (LAMBDA_TYPE_P (DECL_CONTEXT (t)));
-      dump_type (DECL_CONTEXT (t), flags);
-      return;
-    }
+  bool lambda_p = false;
 
   flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME);
   if (TREE_CODE (t) == TEMPLATE_DECL)
@@ -1443,16 +1436,23 @@  dump_function_decl (tree t, int flags)
   else if (cname)
     {
       dump_type (cname, flags);
-      pp_cxx_colon_colon (cxx_pp);
+      if (LAMBDA_TYPE_P (cname))
+	lambda_p = true;
+      else
+	pp_cxx_colon_colon (cxx_pp);
     }
   else
     dump_scope (CP_DECL_CONTEXT (t), flags);
 
-  dump_function_name (t, flags);
+  /* A lambda's signature is essentially its "type", which has already been
+     dumped.  */
+  if (!lambda_p)
+    dump_function_name (t, flags);
 
   if (!(flags & TFF_NO_FUNCTION_ARGUMENTS))
     {
-      dump_parameters (parmtypes, flags);
+      if (!lambda_p)
+	dump_parameters (parmtypes, flags);
 
       if (TREE_CODE (fntype) == METHOD_TYPE)
 	{