Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb@sourceware.org
Subject: Re: Go C++ only
Date: Thu, 01 Sep 2016 18:48:00 -0000	[thread overview]
Message-ID: <66f41b49-f794-47de-65ff-1f1c0f69ff75@redhat.com> (raw)
In-Reply-To: <72276a8218ef0e667097dc3fb152c518@simark.ca>

On 09/01/2016 07:33 PM, Simon Marchi wrote:
> On 2016-09-01 14:22, Pedro Alves wrote:

>>> Perhaps some precisions about the coding style, for C++-specific
>>> constructs (e.g. initializer lists).
>>
>> List initialization is C++11, so it's out, at least for now.
> 
> Oh, I meant the list of members to initialize in a constructor (the list
> after the colon), that's not C++11 I believe.  I see it's all discussed
> in the gcc coding convention page.

Ah, whooops, sorry.  So that's I think the one detail that if you look 
at gcc's code, you'll notice that in practice it deviates a little from 
what the docs say.  Most of the gcc code I looked at I think simply follows
what emacs with "c-set-style gnu" prefers, which is to indent
the initializer list by a couple spaces.  Some random examples:

class pass_parallelize_loops : public gimple_opt_pass
{
public:
  pass_parallelize_loops (gcc::context *ctxt)
    : gimple_opt_pass (pass_data_parallelize_loops, ctxt),
      oacc_kernels_p (false)
  {}

[...]

class example_base
{
 public:
  example_base ()
    : m_kind (0),
      m_a (ggc_cleared_alloc <test_struct> ())
  {}

[...]

bit_field_mode_iterator
::bit_field_mode_iterator (HOST_WIDE_INT bitsize, HOST_WIDE_INT bitpos,
			   HOST_WIDE_INT bitregion_start,
			   HOST_WIDE_INT bitregion_end,
			   unsigned int align, bool volatilep)
: m_mode (GET_CLASS_NARROWEST_MODE (MODE_INT)), m_bitsize (bitsize),
  m_bitpos (bitpos), m_bitregion_start (bitregion_start),
  m_bitregion_end (bitregion_end), m_align (align),
  m_volatilep (volatilep), m_count (0)
{


While their docs say:

"(...) place the colon of the initializer clause at the beginning of a line.

    gnuclass::gnuclass ()
    : base1 (), base2 (), member1 (), member2 (), member3 (), member4 ()
    { 
      ...
    };

I think that we should this a documentation bug, and that it's better
to follow gcc's _actual_ style in practice.  Why fight
against emacs, right?  :-)

Thanks,
Pedro Alves


  reply	other threads:[~2016-09-01 18:48 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-01 17:32 Pedro Alves
2016-09-01 17:48 ` Dmitry Samersoff
2016-09-01 18:07 ` Simon Marchi
2016-09-01 18:22   ` Pedro Alves
2016-09-01 18:33     ` Simon Marchi
2016-09-01 18:48       ` Pedro Alves [this message]
2016-09-01 18:56       ` Pedro Alves
2016-09-01 18:36     ` Andrew Pinski
2016-09-01 19:01       ` Eli Zaretskii
2016-09-01 19:07         ` Pedro Alves
2016-09-01 18:17 ` Joel Brobecker
2016-09-02 10:01   ` Yao Qi
2016-09-02 10:15     ` Pedro Alves
2016-09-02 15:34       ` Sergio Durigan Junior
2016-09-02 20:10       ` Sergio Durigan Junior

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=66f41b49-f794-47de-65ff-1f1c0f69ff75@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb@sourceware.org \
    --cc=simon.marchi@polymtl.ca \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox