From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101492 invoked by alias); 7 Nov 2016 13:33:42 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 101478 invoked by uid 89); 7 Nov 2016 13:33:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*r:0800, Hx-languages-length:2233, policy X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 07 Nov 2016 13:33:31 +0000 Received: from svr-orw-mbx-03.mgc.mentorg.com ([147.34.90.203]) by relay1.mentorg.com with esmtp id 1c3k3E-0005Oc-7N from Luis_Gustavo@mentor.com ; Mon, 07 Nov 2016 05:33:28 -0800 Received: from [172.30.3.90] (147.34.91.1) by svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Mon, 7 Nov 2016 05:33:25 -0800 Subject: Re: [PATCH 0/3] enum_flags: Fix problems and add comprehensive unit tests References: <1478229738-24469-1-git-send-email-palves@redhat.com> To: Pedro Alves , Reply-To: Luis Machado From: Luis Machado Message-ID: <1673e9c0-cccc-e1e8-877a-d5387d768eb4@codesourcery.com> Date: Mon, 07 Nov 2016 13:33:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1478229738-24469-1-git-send-email-palves@redhat.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) To svr-orw-mbx-03.mgc.mentorg.com (147.34.90.203) X-IsSubscribed: yes X-SW-Source: 2016-11/txt/msg00134.txt.bz2 On 11/03/2016 10:22 PM, Pedro Alves wrote: > 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 > It is a bit more general, but i thought i'd throw this out there. Do we have a policy for new unit tests, how they should be created and if/when they should be a replacement for .exp tests? Anything that gets us further away from dejagnu/expect-based testing is a win in my opinion. If we can get unit tests to cover part or most of that, even better.