This is the mail archive of the mailing list for the GDB project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Go C++ only

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
  pass_parallelize_loops (gcc::context *ctxt)
    : gimple_opt_pass (pass_data_parallelize_loops, ctxt),
      oacc_kernels_p (false)


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


::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?  :-)

Pedro Alves

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]