all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Kangas <stefan@marxist.se>
To: Alan Mackenzie <acm@muc.de>
Cc: Simon <turner25@gmail.com>, 19867@debbugs.gnu.org
Subject: bug#19867: c++-mode indentation issues with C++1x initializer lists
Date: Mon, 23 Nov 2020 09:14:43 -0500	[thread overview]
Message-ID: <CADwFkmmJDuTmrt=APD0ZB8YQzoNY5JqG2ffDq2omA085sXZKRw@mail.gmail.com> (raw)
In-Reply-To: <CAN1q39UD+_g9VQNCHKanbQvWt9mVWSHJQjZxsMC=VJ7JGG5wPQ@mail.gmail.com> (Simon's message of "Sat, 14 Feb 2015 12:50:31 -0500")

Simon <turner25@gmail.com> 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<int> 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 <vector>
#include <functional>

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<ABC> 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! */
  }
}





      parent reply	other threads:[~2020-11-23 14:14 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-14 17:50 bug#19867: c++-mode indentation issues with C++1x initializer lists Simon
2015-02-16 19:09 ` Glenn Morris
2015-02-16 19:29   ` Simon
2015-02-16 21:38     ` Daniel Colascione
2015-02-17 19:23     ` Glenn Morris
2015-02-17 19:39       ` Simon
2015-02-16 21:03   ` Daniel Colascione
2020-11-23 14:14 ` Stefan Kangas [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADwFkmmJDuTmrt=APD0ZB8YQzoNY5JqG2ffDq2omA085sXZKRw@mail.gmail.com' \
    --to=stefan@marxist.se \
    --cc=19867@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=turner25@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.