From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tadeus Prastowo Newsgroups: gmane.emacs.bugs Subject: bug#28623: 27.0.50; lisp/progmodes/cc-engine.el incorrect indentation of C++14 curly-brace initializer list Date: Mon, 6 Nov 2017 23:46:26 +0100 Message-ID: References: <20171004181552.GA15562@ACM> <20171011203221.GB7384@ACM> <20171104195639.GA5384@ACM> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Trace: blaine.gmane.org 1510008494 2321 195.159.176.226 (6 Nov 2017 22:48:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 6 Nov 2017 22:48:14 +0000 (UTC) Cc: John Wiegley , 28623@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Nov 06 23:48:10 2017 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBqBe-0000R8-Eo for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Nov 2017 23:48:10 +0100 Original-Received: from localhost ([::1]:50560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBqBl-0000vU-Um for geb-bug-gnu-emacs@m.gmane.org; Mon, 06 Nov 2017 17:48:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:39935) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBqBb-0000uo-Od for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 17:48:09 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBqBa-0007Cy-KS for bug-gnu-emacs@gnu.org; Mon, 06 Nov 2017 17:48:07 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:46126) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBqBV-0007AX-RP; Mon, 06 Nov 2017 17:48:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eBqBV-0005Py-KK; Mon, 06 Nov 2017 17:48:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Tadeus Prastowo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 06 Nov 2017 22:48:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 28623 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 28623-submit@debbugs.gnu.org id=B28623.151000842620758 (code B ref 28623); Mon, 06 Nov 2017 22:48:01 +0000 Original-Received: (at 28623) by debbugs.gnu.org; 6 Nov 2017 22:47:06 +0000 Original-Received: from localhost ([127.0.0.1]:54807 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBqAb-0005Ok-PG for submit@debbugs.gnu.org; Mon, 06 Nov 2017 17:47:06 -0500 Original-Received: from mail-io0-f177.google.com ([209.85.223.177]:55502) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBqAY-0005O8-Pb for 28623@debbugs.gnu.org; Mon, 06 Nov 2017 17:47:03 -0500 Original-Received: by mail-io0-f177.google.com with SMTP id p186so95467ioe.12 for <28623@debbugs.gnu.org>; Mon, 06 Nov 2017 14:47:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unitn-it.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=AhpF7xU889wLy/uKXlMfjlk9IqHy9QYzI63Tr0j2Yss=; b=X0UlS+GwjiRUDMLGkujsYLQ56iREPcuhJMeb2mKR2YBlWtSP5fUEbjOmLKbBOx1oOB RajxGklpgzPp35DC0RR1AGGu5nYv9TzgRaz5Er/8c+ukO22zrZEffFodFcpD0D7L5gRh +yqqxdaM1kVMtjQE1EU8Y8EoOQFBk5T27vmD9lTT+4nWTvBs8nT9LCIsoWxoa6M/Wuoh o73nBs2ZgkGmhpnwCimmQM7BGbusS74ZIQfqz4r/+1tPuia3ZNZKUefV+adF99+A4Qqv OzFb6lsF7zFVwiAP+WNhwdU0DmEMl4RISRcXZZYhQwrEBt8bGIIjhqo9yH7L1jgYawNt iFqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=AhpF7xU889wLy/uKXlMfjlk9IqHy9QYzI63Tr0j2Yss=; b=e3SnqpDD8DRMFfvUA/ImFs5/hp20bqPUNljNnlcBwxpPYsZuRkv6Rfab6xe1cVEz5V Ns83R2HW+QAekOOjpVV6K3KM5DL6J1I979rjkF1MQAIqGYAw/hof8F3P/yyhm3/PT3+2 t1WPsIlO1ZQkeAHLOCZ+tPJVGZJ1lECPBRXouE1aWsM4oZVynaR90vOEFQVbbeXLjms6 oeA6yOv/UYK/K1qBaQw1NHDx8TfQk7n8s3M0ls+gEOlnIdtahlqlu6tejp9mMrb9UKej /k4/GZpiD4TxGLn3aDj3kDCGL6wwEIPk0C2zPtrxqhjJEK+q8OJAFKjdXUbbY6IMWHqk g2qg== X-Gm-Message-State: AJaThX4Vkd8I6ulMHbcQwWEquIvDgu0ggvnxRUslrCKYB5wsglXoB+z7 69DZvq68fQgWP/NzB+4gtxFGXCUudfaSbTa1BjLb X-Google-Smtp-Source: ABhQp+Qr129DTaTGGy9C8d/mN7sE93abwgksbjsxTM3/je41k540Ln3IqB1fS59+zxQyAJDwr3fm8LlPQdJrmo69mKs= X-Received: by 10.107.82.6 with SMTP id g6mr21137295iob.253.1510008416549; Mon, 06 Nov 2017 14:46:56 -0800 (PST) Original-Received: by 10.2.6.2 with HTTP; Mon, 6 Nov 2017 14:46:26 -0800 (PST) In-Reply-To: <20171104195639.GA5384@ACM> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:139533 Archived-At: Hi Alan! On Sat, Nov 4, 2017 at 8:56 PM, Alan Mackenzie wrote: > Hello, Tadeus. > > On Thu, Oct 12, 2017 at 13:38:56 +0200, Tadeus Prastowo wrote: >> Hi Alan! > >> On Wed, Oct 11, 2017 at 10:32 PM, Alan Mackenzie wrote: >> > Hello, Tadeus. > >> [...] > >> > I'm sorry is been a week without any communication from me. The reason >> > is I've run into problems with other related cases. For example, in > >> > 1. auto bad4 = f <3> ( >> > 2. {3, 4}, > >> > L2 needs to be parsed as an arglist-intro and indented as shown. It's >> > actually being parsed as a brace-list-open with anchor point on "auto". > >> > What's confusing me is the confusion between a brace list being >> > recognised by its context (which is what >> > c-looking-at-or-maybe-in-bracelist mostly does) and by its content. The >> > {3, 4} above is a brace list by its content but not by its context. >> > However, it's being wrongly recognised as a by-context brace list, hence >> > is being parsed and indented wrongly. > >> > I'm not going to have much time to sort this out over the next week or >> > two, so please bear with me. I haven't forgotten about this. > >> Thanks for sharing the problem with me. I will also look into the >> matter during this weekend. Hopefully I can come up with a good >> solution :) Sorry that I did not manage to spare the last three weekends to look into the problem :( > I think I've solved this, though it's been perhaps the most difficult bug > in CC Mode for some years. Each time I thought I'd nailed it, some > awkward test case would misbehave. Thank you very much for working on it. > Anyhow, would you please try the patch below, which should apply cleanly > to either the emacs-26 branch or master. It is not finished; for example > I've still got to amend several comments. Nevertheless I think it's > working. I look forward to hearing of any problems which are still in > this patch, or of a report that it seems to be working. The patch applied to master cleanly. Against the mwe.cpp I sent the other day, the patch works fine. But, it does not work with the following one: -- 8< ---------------------------------- int main() { /* Indentation produced by my patch the other day */ fn({ {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }, { {1, 3}, {4, 5}, {7, 8}, }); for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, }, { {1, 3}, {4, 5}, {7, 8}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Indentation produced by my patch the other day */ /* Problem observed using your patch */ fn({ {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }, { {1, 3}, {4, 5}, {7, 8}, }); for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, }, { {1, 3}, {4, 5}, {7, 8}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Problem observed using your patch */ } -- 8< ---------------------------------- Additionally, I would argue that compared to the one produced by my patch demonstrated above, the following indentation would be even better: for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, }, { {1, 3}, {4, 5}, {7, 8}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } Please let me know what you think about that. > If you have nothing against it, I intend to put your test file (or bits > of it) into a new file in the CC Mode test suite. Yes, that is okay. [...] > -- > Alan Mackenzie (Nuremberg, Germany). -- Best regards, Tadeus