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: Wed, 27 Sep 2017 19:49:57 +0200 Message-ID: NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="001a114ac5505f77b2055a2f6d5c" X-Trace: blaine.gmane.org 1506536115 30708 195.159.176.226 (27 Sep 2017 18:15:15 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 27 Sep 2017 18:15:15 +0000 (UTC) To: 28623@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Sep 27 20:15:09 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 1dxGrS-0007N4-4E for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Sep 2017 20:15:06 +0200 Original-Received: from localhost ([::1]:55859 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxGrZ-0000X7-7h for geb-bug-gnu-emacs@m.gmane.org; Wed, 27 Sep 2017 14:15:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49847) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxGrR-0000Wc-5p for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 14:15:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxGrP-0001y8-MV for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 14:15:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:54856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxGrP-0001xw-HA for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 14:15:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dxGrP-0004lt-AF for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 14:15:03 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tadeus Prastowo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 27 Sep 2017 18:15:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 28623 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.150653608918286 (code B ref -1); Wed, 27 Sep 2017 18:15:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 27 Sep 2017 18:14:49 +0000 Original-Received: from localhost ([127.0.0.1]:35302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxGrA-0004ks-A5 for submit@debbugs.gnu.org; Wed, 27 Sep 2017 14:14:48 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:53006) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dxGTq-00048c-9O for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:43 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxGTj-0005Bz-Ez for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:36 -0400 Original-Received: from lists.gnu.org ([2001:4830:134:3::11]:48141) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dxGTi-0005Bl-W0 for submit@debbugs.gnu.org; Wed, 27 Sep 2017 13:50:35 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dxGTh-0004Oe-8Q for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:34 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dxGTf-0005AD-QX for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:33 -0400 Original-Received: from mail-it0-x232.google.com ([2607:f8b0:4001:c0b::232]:49959) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dxGTf-00059G-A5 for bug-gnu-emacs@gnu.org; Wed, 27 Sep 2017 13:50:31 -0400 Original-Received: by mail-it0-x232.google.com with SMTP id c195so8218304itb.4 for ; Wed, 27 Sep 2017 10:50:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unitn-it.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=2y4c8wbaxzFOoz36giyK2bMkv6/hvfddkHCN8eurZUs=; b=MOCFl1S8br+JzxNEgcQNOepCYfGT8ehXeizXz6VCFT4Ed96JnVrqdmvpKHrQhvTung teHEKe/yZ4VrbyjPp0LcaVHEse11vHGlWQ6GriIs+w2R0EI0Ql59HnzCRjPLNHgFL8q/ KM0TaqrwCmUmg3jgllRq5C/wW300cpsS27XaChEB3pdjj0xkXesSuL8sqLgx2NLYXLyV agPyJpioWBiSKvOOyVQT4MASwzAwoO4kLIgBveOoR60Iq2xuY8znQ6SUaOJ2PkWfDvq4 XSmH+mkhpa1yCUqWevIjID9NZnkAXcuPdwDsF9MQROMQXUDY2sEoUwpVHFzFXiF50Nmx Sm2w== 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=2y4c8wbaxzFOoz36giyK2bMkv6/hvfddkHCN8eurZUs=; b=t7hayLVeR35aJasSAxL7NsKxoQfQSMQhSG+MkZnR7FGO2GP+VK0oN11ivvV5PQ/up8 6C0+fiF/u7Ys23ESQqarglOy/irZKlOijBhtPubvSWeGJywh3wLdiaKYXtG2+aXpJKKN VMqZvbnfZMEAf9C33yUbq1lHz+dUN2gkjXf0FGtm1NpXZH6Jao1eRkORLRV8pBPhf4d+ nDAVkIpqEvMUV7Ng61QEEN9wvK03HFiyspGwbikUHAwRMnJD3YUWeiJNgA9gs/kjaX13 QA/eI5YVrSGvJZkCVrTHIz7srYcXf8Qsg6bjAg3tfDzdK9vRkKfs+zAt3qIwznY+CLOE gN7Q== X-Gm-Message-State: AHPjjUj8DP8B7VzIRphXoUHmXyHdktxcUdOkP7fI3SMRMAYjhxv5hKSw 4rNYR3HDLxOQnVsWjK9QsQbHQxLuW4f1BWxcGoiq42zA9A== X-Google-Smtp-Source: AOwi7QA/GMkuFYlggyFhQFxSspybNCPJ3Iz9xUc4oQzOTypdETpNRz37BBgtcS0hhE2w+/Bcnb3rhx0/TIDnSP5Cclc= X-Received: by 10.36.121.202 with SMTP id z193mr1936561itc.110.1506534628468; Wed, 27 Sep 2017 10:50:28 -0700 (PDT) Original-Received: by 10.2.10.197 with HTTP; Wed, 27 Sep 2017 10:49:57 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Wed, 27 Sep 2017 14:14:45 -0400 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:137508 Archived-At: --001a114ac5505f77b2055a2f6d5c Content-Type: text/plain; charset="UTF-8" The following C++14 source code, which is also attached as `mwe.cpp', shows the indentation problem: --8<------------------------------ #include #include static std::vector> fn(std::vector> data) { return { {1, 2, 3}, {4, 5, 6}, {7, 8, 9}, }; } static std::vector> fn(unsigned n, std::vector> data) { return { {n + 1, n + 2, n + 3}, {n + 4, n + 5, n + 6}, {n + 7, n + 8, n + 9}, }; } int main() { /* Expected indentation */ fn({ {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }); for (const auto &v : fn({ {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Expected indentation */ /* Problem */ fn(20, { {1, 2, 3}, {3, 4, 5}, {6, 7, 8}, }); for (const auto &v : fn(20, { {3, 4, 5}, {6, 7, 8}, {9, 10, 11}, })) { for (const auto &a : v) { std::cout << a << '\n'; } } /* End: Problem */ } --8<------------------------------ To fix the problem, I make the following patch: --8<------------------------------ diff --git a/lisp/progmodes/cc-engine.el b/lisp/progmodes/cc-engine.el index 05b391a..077e9c9 100644 --- a/lisp/progmodes/cc-engine.el +++ b/lisp/progmodes/cc-engine.el @@ -10387,6 +10387,7 @@ comment at the start of cc-engine.el for more info." (eq (char-after) ?\()) (setq braceassignp 'c++-noassign)) ((looking-at c-pre-id-bracelist-key)) + ((looking-at ",\\s *")) ((looking-at c-return-key)) ((and (looking-at c-symbol-start) (not (looking-at c-keywords-regexp))) @@ -10398,6 +10399,7 @@ comment at the start of cc-engine.el for more info." (and (c-go-up-list-backward nil lim) ; FIXME!!! Check `lim' 2016-07-12. (eq (char-after) ?\())) ((looking-at c-pre-id-bracelist-key)) + ((looking-at ",\\s *")) ((looking-at c-return-key)) (t (setq after-type-id-pos (point)) nil)))) --8<------------------------------ Any better suggestion as to how to fix the problem? Thanks. In GNU Emacs 27.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.18.9) of 2017-09-27 built on lgw01-amd64-052 Windowing system distributor 'The X.Org Foundation', version 11.0.11804000 System Description: Ubuntu 16.04.3 LTS Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Making completion list... Quit Configured using: 'configure --build=x86_64-linux-gnu --prefix=/usr '--includedir=${prefix}/include' '--mandir=${prefix}/share/man' '--infodir=${prefix}/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules '--libdir=${prefix}/lib/x86_64-linux-gnu' '--libexecdir=${prefix}/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --sharedstatedir=/var/lib --program-suffix=-snapshot --with-modules=yes --with-x=yes --with-x-toolkit=gtk3 --with-xwidgets=yes 'CFLAGS=-g -O2 -fstack-protector-strong -Wformat -Werror=format-security' 'CPPFLAGS=-Wdate-time -D_FORTIFY_SOURCE=2' 'LDFLAGS=-Wl,-Bsymbolic-functions -Wl,-z,relro'' Configured features: XPM JPEG TIFF GIF PNG RSVG IMAGEMAGICK SOUND GPM DBUS GSETTINGS NOTIFY LIBSELINUX GNUTLS LIBXML2 FREETYPE M17N_FLT LIBOTF XFT ZLIB TOOLKIT_SCROLL_BARS GTK3 X11 MODULES XWIDGETS LIBSYSTEMD LCMS2 Important settings: value of $LC_MONETARY: en_US.UTF-8 value of $LC_NUMERIC: en_US.UTF-8 value of $LC_TIME: en_US.UTF-8 value of $LANG: en_US.UTF-8 value of $XMODIFIERS: @im=ibus locale-coding-system: utf-8-unix Major mode: C++//l Minor modes in effect: tooltip-mode: t global-eldoc-mode: t electric-indent-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Load-path shadows: None found. Features: (shadow sort mail-extr emacsbug message subr-x puny seq byte-opt gv bytecomp byte-compile cconv dired dired-loaddefs format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config gnus-util rmail rmail-loaddefs mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs cl-loaddefs cl-lib elec-pair time-date mule-util tooltip eldoc electric uniquify ediff-hook vc-hooks lisp-float-type mwheel term/x-win x-win term/common-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode lisp-mode prog-mode register page menu-bar rfn-eshadow isearch timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core term/tty-colors frame cl-generic cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite charscript charprop case-table epa-hook jka-cmpr-hook help simple abbrev obarray minibuffer cl-preloaded nadvice loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote dbusbind inotify lcms2 dynamic-setting system-font-setting font-render-setting xwidget-internal move-toolbar gtk x-toolkit x multi-tty make-network-process emacs) Memory information: ((conses 16 115959 7786) (symbols 48 22648 1) (miscs 40 46 140) (strings 32 34019 980) (string-bytes 1 1013691) (vectors 16 17237) (vector-slots 8 521799 8627) (floats 8 50 155) (intervals 56 397 1) (buffers 992 13) (heap 1024 40263 1174)) -- Best regards, Tadeus --001a114ac5505f77b2055a2f6d5c Content-Type: text/x-c++src; charset="US-ASCII"; name="mwe.cpp" Content-Disposition: attachment; filename="mwe.cpp" Content-Transfer-Encoding: base64 X-Attachment-Id: f_j83bkayb0 I2luY2x1ZGUgPHZlY3Rvcj4KI2luY2x1ZGUgPGlvc3RyZWFtPgoKc3RhdGljIHN0ZDo6dmVjdG9y PHN0ZDo6dmVjdG9yPHVuc2lnbmVkPj4KZm4oc3RkOjp2ZWN0b3I8c3RkOjp2ZWN0b3I8dW5zaWdu ZWQ+PiBkYXRhKSB7CiAgcmV0dXJuIHsKICAgICAgICAgIHsxLCAyLCAzfSwKICAgICAgICAgIHs0 LCA1LCA2fSwKICAgICAgICAgIHs3LCA4LCA5fSwKICB9Owp9CgpzdGF0aWMgc3RkOjp2ZWN0b3I8 c3RkOjp2ZWN0b3I8dW5zaWduZWQ+Pgpmbih1bnNpZ25lZCBuLCBzdGQ6OnZlY3RvcjxzdGQ6OnZl Y3Rvcjx1bnNpZ25lZD4+IGRhdGEpIHsKICByZXR1cm4gewogICAgICAgICAge24gKyAxLCBuICsg MiwgbiArIDN9LAogICAgICAgICAge24gKyA0LCBuICsgNSwgbiArIDZ9LAogICAgICAgICAge24g KyA3LCBuICsgOCwgbiArIDl9LAogIH07Cn0KCmludCBtYWluKCkgewogIC8qIEV4cGVjdGVkIGlu ZGVudGF0aW9uICovCiAgZm4oewogICAgICB7MSwgMiwgM30sCiAgICAgIHszLCA0LCA1fSwKICAg ICAgezYsIDcsIDh9LAogICAgfSk7CiAgZm9yIChjb25zdCBhdXRvICZ2IDogZm4oewogICAgICAg ICAgICAgICAgICAgICAgICAgICB7MywgNCwgNX0sCiAgICAgICAgICAgICAgICAgICAgICAgICAg IHs2LCA3LCA4fSwKICAgICAgICAgICAgICAgICAgICAgICAgICAgezksIDEwLCAxMX0sCiAgICAg IH0pKSB7CiAgICBmb3IgKGNvbnN0IGF1dG8gJmEgOiB2KSB7CiAgICAgIHN0ZDo6Y291dCA8PCBh IDw8ICdcbic7CiAgICB9CiAgfQogIC8qIEVuZDogRXhwZWN0ZWQgaW5kZW50YXRpb24gKi8KCiAg LyogUHJvYmxlbSAqLwogIGZuKDIwLCB7CiAgICAgIHsxLCAyLCAzfSwKICAgICAgICB7MywgNCwg NX0sCiAgICAgICAgICB7NiwgNywgOH0sCiAgICAgICAgICAgIH0pOwogIGZvciAoY29uc3QgYXV0 byAmdiA6IGZuKDIwLCB7CiAgICAgICAgezMsIDQsIDV9LAogICAgICAgICAgezYsIDcsIDh9LAog ICAgICAgICAgICB7OSwgMTAsIDExfSwKICAgICAgICAgICAgICB9KSkgewogICAgZm9yIChjb25z dCBhdXRvICZhIDogdikgewogICAgICBzdGQ6OmNvdXQgPDwgYSA8PCAnXG4nOwogICAgfQogIH0K ICAvKiBFbmQ6IFByb2JsZW0gKi8KfQo= --001a114ac5505f77b2055a2f6d5c--