Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: gdb-patches@sourceware.org
Subject: [PATCH 0/3] enum_flags: Fix problems and add comprehensive unit tests
Date: Fri, 04 Nov 2016 03:23:00 -0000	[thread overview]
Message-ID: <1478229738-24469-1-git-send-email-palves@redhat.com> (raw)

Recently, while working on making symfile_add_flags and objfile->flags
strongly typed [1], I noticed a few enum_flags issues, like this
failing to compile:

  symfile_add_flags add_flags = (SYMFILE_MAINLINE
                                 | current_inferior ()->symfile_flags);

while the form that landed in master does compile:

  symfile_add_flags add_flags = (current_inferior ()->symfile_flags
                                 | SYMFILE_MAINLINE);
  
This series started out by wanting to fix that, but it ended up fixing
a bunch more, and adding comprehensive enum_flags unit tests along the
way.  Writing the tests in turn exposed more problems.  Rinse, repeat.

The enum_flags methods and global operators are made constexpr where
possible, and then C++11's deleted functions are used to remove
overloads that should not compile.  The unit tests then build on
SFINAE + decltype + constexpr to check that mixing enum flags types
incorrectly would really fail to compile.

This series makes use of C++11 extensively: decltype, constexpr,
=delete/=default, typedef -> type alias / using, static_assert, and
more.

[1] https://sourceware.org/ml/gdb-patches/2016-10/msg00715.html

Pedro Alves (3):
  enum_flags: Use C++11 std::underlying_type
  enum_flags: Fix problems and add comprehensive unit tests
  enum_flags: Fix ternary operator and remove implicit convertion to raw
    enum

 gdb/Makefile.in               |   2 +-
 gdb/btrace.c                  |   4 +-
 gdb/common/enum-flags.h       | 251 ++++++++++++-------
 gdb/compile/compile-c-types.c |   2 +-
 gdb/enum-flags-selftests.c    | 557 ++++++++++++++++++++++++++++++++++++++++++
 gdb/go-exp.y                  |   2 +-
 gdb/record-btrace.c           |  10 +-
 gdb/selftest.h                |  11 +
 8 files changed, 738 insertions(+), 101 deletions(-)
 create mode 100644 gdb/enum-flags-selftests.c

-- 
2.5.5


             reply	other threads:[~2016-11-04  3:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-04  3:23 Pedro Alves [this message]
2016-11-04  3:23 ` [PATCH 3/3] enum_flags: Fix ternary operator and remove implicit convertion to raw enum Pedro Alves
2016-11-04  3:23 ` [PATCH 1/3] enum_flags: Use C++11 std::underlying_type Pedro Alves
2016-11-05  2:28   ` Simon Marchi
2016-11-04  3:23 ` [PATCH 2/3] enum_flags: Fix problems and add comprehensive unit tests Pedro Alves
2016-11-05  2:47   ` Simon Marchi
2016-11-05  3:05   ` Simon Marchi
2016-11-07 13:33 ` [PATCH 0/3] " Luis Machado

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=1478229738-24469-1-git-send-email-palves@redhat.com \
    --to=palves@redhat.com \
    --cc=gdb-patches@sourceware.org \
    /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