From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Jianbin Kang Newsgroups: gmane.emacs.bugs Subject: bug#47468: 27.1; cc-mode: Got incorrect indentaton for C++ lambda function. Date: Mon, 29 Mar 2021 20:47:52 +0800 Message-ID: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000d90a6305beac4a6b" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35259"; mail-complaints-to="usenet@ciao.gmane.io" To: 47468@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Mar 29 16:46:15 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lQt9h-000931-Nj for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Mar 2021 16:46:13 +0200 Original-Received: from localhost ([::1]:40814 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lQt9g-0001Pt-NU for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 29 Mar 2021 10:46:12 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:43562) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQt9W-0001PZ-U0 for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 10:46:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37670) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQt9W-0001Hm-MM for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 10:46:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lQt9W-0000aZ-Kc for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 10:46:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Jianbin Kang Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 29 Mar 2021 14:46:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 47468 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.16170291182200 (code B ref -1); Mon, 29 Mar 2021 14:46:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 29 Mar 2021 14:45:18 +0000 Original-Received: from localhost ([127.0.0.1]:49216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQt8m-0000ZP-Ju for submit@debbugs.gnu.org; Mon, 29 Mar 2021 10:45:18 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:42212) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lQrJP-0005ta-Cl for submit@debbugs.gnu.org; Mon, 29 Mar 2021 08:48:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40396) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lQrJP-000251-3y for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 08:48:07 -0400 Original-Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]:33645) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lQrJN-0005LC-EK for bug-gnu-emacs@gnu.org; Mon, 29 Mar 2021 08:48:06 -0400 Original-Received: by mail-pf1-x42b.google.com with SMTP id x26so9845073pfn.0 for ; Mon, 29 Mar 2021 05:48:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=HoboZmopz6Vvjx1GCFSQm1MWubTeC1Wfvjj0xKIIU3E=; b=cFklAcK22CQkf9tDVd2BRqCLycSc8N3QhpCyjqy2wEMgxeu7VfL5zNozKta6cLOKHN fxXyM1S+K2EOK5kb4NEEqQFPiPrU9bcWpuT9QOyQPvyr9g6MuPa5EAnhhVR5Bveetojr 3AxPUq/U5c4hYywjlrrOznMpP/avskR9czYhS9DtpQlp5Iql3yjQXhnspajdWUMNs2ko GtpasAmnWRKJAp/i9d7SzUP/7MJgoA1yQ+E9YPhyZypCjMWkkyS7ZmF4vveY8Aa9am3H D5SvMNe7RfPg3+J3jlBLFXkoNFVp8k5RzRcfCpf21BKS6Qq/br2ccfc+5wgWqAIBBMNf QkFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=HoboZmopz6Vvjx1GCFSQm1MWubTeC1Wfvjj0xKIIU3E=; b=fFDQCIjJojK29FZc4vA6gD3RWYQdfiMWMHGINg2ddrJ1oY/+8QFLGQ9ntSIWtpU4UF PbmXjn4V/2HXL7xFapQL0dydWUV784m5kmvWiyCQcY5U2oHpMHJkncXcb616wDqvF054 9Usi3JW3fud9UKB3/AvczoO1uSx+AD+qy04nlCez0O5VKT8welbkqqV/lfyda6F5APgg ckvdI6znPpYJFwM792izhj26lA88q7l8g/38BLGTckTN1hXvt7lElBsfFCvidqGpNj+Y BZAWK0mnxziyomxCUFQ5AvP9CPHdCQOKVz1+7AXFCOpP+syVeln5dpVawrINWGJG2ejy Y0cA== X-Gm-Message-State: AOAM531gvLvDTlKjw4yWvNspiakaGCG1TOq4iyk0sJTh2/UcansZpedy mcK075lW4EwXRLo9rVYgXJBqgwLOVjL2TIwAET4CSkwIPDPjsA== X-Google-Smtp-Source: ABdhPJziNN8rNeWrImOTFnlKBfDjYhRSc8S5nw6awDpPkos/g7q1G9yjT+hTuDMclS0+ta3D+rLx/Uk2bjPqgLr/Q90= X-Received: by 2002:a63:e80a:: with SMTP id s10mr23900151pgh.380.1617022082941; Mon, 29 Mar 2021 05:48:02 -0700 (PDT) Received-SPF: pass client-ip=2607:f8b0:4864:20::42b; envelope-from=kjbmail@gmail.com; helo=mail-pf1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 29 Mar 2021 10:45:14 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:203241 Archived-At: --000000000000d90a6305beac4a6b Content-Type: text/plain; charset="UTF-8" The c++ file to reproduce it: ```c++ #include #include struct PP { const char * name; }; static void print(const char *name, std::function f) { f(name); } int main(int argc, char *argv[]) { PP A = { "Jim" }; PP *a = &A; print(A.name, [](const char *name) { printf("%s\n", name); // Syntactic ((inlambda) ... }); print(a->name, [=](const char *name) { printf("%s\n", name); // Syntactic((arglist-cont-nonempty ... }); return 0; } ``` If I put cursor in lambda body of first print call, and run 'c-show-syntactic-information', it shows 'Syntactic analysis: ((inlambda) (defun-block-intro 258))', which is correct and I get good indentation. But in second print call, I get 'Syntactic analysis: ((arglist-cont-nonempty 337 342) (statement-block-intro 337))' and the indentation is bad. My emacs version is 27.1. I can reproduce the problem in both Linux and Windows with 'emacs -Q'. --000000000000d90a6305beac4a6b Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

The c++ file to reproduce it:
```c++
#include &l= t;stdio.h>
#include <functional>

struct PP {
=C2=A0 = =C2=A0 const char * =C2=A0 =C2=A0 =C2=A0 =C2=A0name;
};

static vo= id print(const char *name, std::function<void(const char *)> f)
{<= br>=C2=A0 =C2=A0 f(name);
}

int main(int argc, char *argv[])
{=
=C2=A0 =C2=A0 PP A =3D { "Jim" };
=C2=A0 =C2=A0 PP *a =3D = &A;

=C2=A0 =C2=A0 print(A.name, [](const char *name) {
=C2=A0= =C2=A0 =C2=A0 =C2=A0 printf("%s\n", name); =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 // Syntactic ((inlambda) ...
=C2=A0 =C2=A0 });
=C2=A0 = =C2=A0 print(a->name, [=3D](const char *name) {
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 printf("%s\n", name); =C2=A0 =C2=A0 =C2=A0 /= / Syntactic((arglist-cont-nonempty ...
=C2=A0 =C2=A0 =C2=A0 =C2=A0 });
=C2=A0 =C2=A0 return 0;
}

```

If I put cursor in lam= bda body of first print call, and run 'c-show-syntactic-information'= ;, it shows 'Syntactic analysis: ((inlambda) (defun-block-intro 258))&#= 39;, which is correct and I get good indentation.

But in second prin= t call, I get 'Syntactic analysis:
((arglist-cont-nonempty 337 342) = (statement-block-intro 337))' and the
indentation is bad.

My = emacs version is 27.1. I can reproduce the problem in both Linux and Window= s with 'emacs -Q'.



--000000000000d90a6305beac4a6b--