From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Kangas Newsgroups: gmane.emacs.bugs Subject: bug#19867: c++-mode indentation issues with C++1x initializer lists Date: Mon, 23 Nov 2020 09:14:43 -0500 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="17904"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Simon , 19867@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Nov 23 15:35:10 2020 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 1khCvu-0004Wo-3d for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Nov 2020 15:35:10 +0100 Original-Received: from localhost ([::1]:60772 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1khCvt-0005lK-4n for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 23 Nov 2020 09:35:09 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1khCcQ-0003Ci-FZ for bug-gnu-emacs@gnu.org; Mon, 23 Nov 2020 09:15:02 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38043) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1khCcQ-0007rt-42; Mon, 23 Nov 2020 09:15:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1khCcP-0001tn-TS; Mon, 23 Nov 2020 09:15:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Kangas Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 23 Nov 2020 14:15:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 19867 X-GNU-PR-Package: emacs,cc-mode Original-Received: via spool by 19867-submit@debbugs.gnu.org id=B19867.16061408947268 (code B ref 19867); Mon, 23 Nov 2020 14:15:01 +0000 Original-Received: (at 19867) by debbugs.gnu.org; 23 Nov 2020 14:14:54 +0000 Original-Received: from localhost ([127.0.0.1]:49589 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khCcH-0001tA-RQ for submit@debbugs.gnu.org; Mon, 23 Nov 2020 09:14:54 -0500 Original-Received: from mail-ej1-f48.google.com ([209.85.218.48]:35443) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1khCcF-0001sw-5A for 19867@debbugs.gnu.org; Mon, 23 Nov 2020 09:14:52 -0500 Original-Received: by mail-ej1-f48.google.com with SMTP id f23so23522774ejk.2 for <19867@debbugs.gnu.org>; Mon, 23 Nov 2020 06:14:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:in-reply-to:references:user-agent :mime-version:date:message-id:subject:to:cc; bh=Jq1YMdOgM7YUrV63nkIIrPrxgmNSeAhHS03iiy8rEGM=; b=bQMmEsLs87vtwyguZzaUmF4SK9x400RVoSpGJ8TKYzamJB2OGaO2dnLVas1iNfaNKU OxeVA+hPDvfVV4CN8wklomPq3WF2vjg3Be/PQxgu/CnnqVBw3+Pn/181PXfo8P2bLOzy 9YcdI/A+9jNEUAQblQLd3Om7RizdqH3uHGfvbZyQz2U/ZrbBI78Pkla5BWLOiDtmzR2d ZQnFPJS2D3cGhFjXDbOF0+2M+5AzbXWsFI3XDejA2DLv2Vawew613C06+E+M/gDTI8gI /dEMK//097wu5lIPym98mCyckFrb6v7Ae2za9kx+KnRV8RxFR0wuZKqLRBtdinCVpKAu vhTA== X-Gm-Message-State: AOAM533hUEEQl9bGAf4fMxQOZ3JMl/x71zl0mmNByaCCK/j8UVQtVeU1 Wu+xvGeZmPv0NTqPlGoZG7VgdAmFNaUShh72F/k= X-Google-Smtp-Source: ABdhPJxfW6n4KPdEdDw56h6xMYhxRh6ys7+62H0E6HwfvUQcOiBGa2q0riUeHTnJIMs36I+g7C388x48wopFhnoAbfA= X-Received: by 2002:a17:906:614a:: with SMTP id p10mr25880210ejl.312.1606140885400; Mon, 23 Nov 2020 06:14:45 -0800 (PST) Original-Received: from 753933720722 named unknown by gmailapi.google.com with HTTPREST; Mon, 23 Nov 2020 09:14:43 -0500 In-Reply-To: (Simon's message of "Sat, 14 Feb 2015 12:50:31 -0500") 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:193916 Archived-At: Simon writes: > Initializer lists use curly braces, but their contents do not indent properly with emacs' c++-mode. > In short, one may use an initializer list to declare and initialize a vector of integers as such: > std::vector Foo( { 1, 2, 3, 4, 5 } ); > > Problems arise when the elements of the list span on multiple line and it gets even worse when the elements are lambda-expressions > and nested initializer lists. > The following code illustrate most cases and related situations. The code below compiles without error or warning with gcc 4.8.3. I had a look at the fairly long example provided here, and AFAICT, the indentation is incorrect in the below cases (trimmed down from the original). Some of the examples of incorrect indentation were already fixed. Alan, could you perhaps take a look at this and see if this is something that is fixable? Thanks in advance. #include #include namespace emacs_initlist_indentation_bug { struct DEF { int d, // e, // indented from "int" + 2 f; // }; struct GHI { int // g, // indented from "int" +0 h, // indented from "int" + 2 i; // }; void f4 (int a, int b, int c) { std::vector abcList2( // Source of alignment for closing ")" below {{a+6, b+6, c+6} } // ); /* Somehow, this one aligns with first line's comment position!! */ } lambda_initlist_bug.push_back( // [](int p) // OK, text-book indentation { // return p+p; // } // ); /* Aligned with first comment! */ } }