From patchwork Wed Aug 28 00:54:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Butcher X-Patchwork-Id: 270418 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "www.sourceware.org", Issuer "StartCom Class 1 Primary Intermediate Server CA" (not verified)) by ozlabs.org (Postfix) with ESMTPS id DA5612C007B for ; Wed, 28 Aug 2013 19:06:52 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=sfBwYUcsDhdgl0V+8UB8GinKdQOQSX5fwWhS/yfYmb9weJQMtRFIl ARnVbTkpkYoQtkahfeTblXyTtXya8LHkyVRd4XtrTUcpdUX6u0utV85O0ba1XDf/ KzErsH58eibcHXL0nRiEWd9p7AN6TvEGFVtwv91CHTU+vYeTkinhKg= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=8nT2mOCfGeygGHcXdE5ZtDE0w6c=; b=Wc0czPUl59oYxr6PGMPd cDLhXXs5DipyxBrAAoKK/k1WmWFmLmq8B34x1xZx43dYqX3505NO0n1v02oljBRM UmnVZUX6Arp+x4d05JtXrGyy2Z6/PpToYvY2mjfm8J80laMAXbHkVGNKX82o77y7 XBNf8bY6ZOUNsL9GX2uyvHE= Received: (qmail 9806 invoked by alias); 28 Aug 2013 09:06:45 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 9789 invoked by uid 89); 28 Aug 2013 09:06:44 -0000 Received: from mail-we0-f171.google.com (HELO mail-we0-f171.google.com) (74.125.82.171) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Wed, 28 Aug 2013 09:06:44 +0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.0 required=5.0 tests=ALL_TRUSTED, AWL, BAYES_00, DATE_IN_PAST_06_12, FREEMAIL_FROM, KHOP_THREADED autolearn=no version=3.3.2 X-HELO: mail-we0-f171.google.com Received: by mail-we0-f171.google.com with SMTP id p57so5017369wes.30 for ; Wed, 28 Aug 2013 02:06:41 -0700 (PDT) X-Received: by 10.194.179.98 with SMTP id df2mr678908wjc.49.1377680801024; Wed, 28 Aug 2013 02:06:41 -0700 (PDT) Received: from sphere.lan (munkyhouse.force9.co.uk. [84.92.244.81]) by mx.google.com with ESMTPSA id pn7sm3422384wic.6.1969.12.31.16.00.00 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 28 Aug 2013 02:06:40 -0700 (PDT) From: Adam Butcher To: Jason Merrill Cc: gcc-patches@gcc.gnu.org, Gabriel Dos Reis , Andrew Sutton , Adam Butcher Subject: [PATCH] Support dumping type bindings and 'mutable' qualifier in lambda diagnostics. Date: Wed, 28 Aug 2013 01:54:39 +0100 Message-Id: <1377651279-30425-1-git-send-email-adam@jessamine.co.uk> In-Reply-To: <521D3C7F.6080907@redhat.com> References: <521D3C7F.6080907@redhat.com> * 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). Rather than qualifying the diagnostic with 'const' for plain lambdas, qualify with 'mutable' if non-const. --- Okay to commit? --- gcc/cp/error.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/gcc/cp/error.c b/gcc/cp/error.c index c82a0ce..a8ca269 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -1380,14 +1380,7 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) int do_outer_scope = ! (flags & TFF_UNQUALIFIED_NAME); tree exceptions; vec *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 (pp, DECL_CONTEXT (t), flags); - return; - } + bool lambda_p = false; flags &= ~(TFF_UNQUALIFIED_NAME | TFF_TEMPLATE_NAME); if (TREE_CODE (t) == TEMPLATE_DECL) @@ -1449,21 +1442,31 @@ dump_function_decl (cxx_pretty_printer *pp, tree t, int flags) else if (cname) { dump_type (pp, cname, flags); - pp_cxx_colon_colon (pp); + if (LAMBDA_TYPE_P (cname)) + lambda_p = true; + else + pp_cxx_colon_colon (pp); } else dump_scope (pp, CP_DECL_CONTEXT (t), flags); - dump_function_name (pp, t, flags); + /* A lambda's signature is essentially its "type", which has already been + dumped. */ + if (!lambda_p) + dump_function_name (pp, t, flags); if (!(flags & TFF_NO_FUNCTION_ARGUMENTS)) { - dump_parameters (pp, parmtypes, flags); + if (!lambda_p) + dump_parameters (pp, parmtypes, flags); if (TREE_CODE (fntype) == METHOD_TYPE) { pp->padding = pp_before; - pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype)); + if (!lambda_p) + pp_cxx_cv_qualifier_seq (pp, class_of_this_parm (fntype)); + else if (!(TYPE_QUALS (class_of_this_parm (fntype)) & TYPE_QUAL_CONST)) + pp_c_ws_string (pp, "mutable"); dump_ref_qualifier (pp, fntype, flags); }