From patchwork Mon Oct 10 19:32:24 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 680548 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3st9JH0yhFz9sBR for ; Tue, 11 Oct 2016 06:32:46 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qOjqv2/I; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; q=dns; s= default; b=F5nEISiUIXxcKW7xAOl97SNl2xCm5PGQL4kPWSCoD0TUR1+sUOcVI 1cdyQnMkywj9ZiRQh5Clt1HtYdseQwgAkfAlY7Yf0zo/nnNQGrS0xBnNDKB40C4r 0rZZNrm2w0PAYZ/KA+5IrrQLr40kKSyYLGt6N9A/Ww+Tm1MoiujwuE= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type:content-transfer-encoding; s=default; bh=VCXCHemcjXw0K57reQ9k3PbqCAI=; b=qOjqv2/IwirPUiyGGqpUeieUw6NW PF9FCkOJjNuHU5agn5kH8tgqZwpzp+2mA+oU63WYzu8d5ZDz6XjEdvm7YEVRn322 wn/5l3bM+Ve6v7CBi74RPb2YU9IsiXdJmhRYjZbMokln6Iiueqph8GqAve3Qz/OQ 40h08yxRNAdyydg= Received: (qmail 77509 invoked by alias); 10 Oct 2016 19:32:40 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 77488 invoked by uid 89); 10 Oct 2016 19:32:39 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Trevor, trevor, saunders, Saunders X-Spam-User: qpsmtpd, 2 recipients X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 10 Oct 2016 19:32:29 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C98B615D9; Mon, 10 Oct 2016 19:32:27 +0000 (UTC) Received: from [127.0.0.1] (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9AJWOCR019718; Mon, 10 Oct 2016 15:32:25 -0400 Subject: Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h) To: Trevor Saunders References: <1462552846-17096-1-git-send-email-dmalcolm@redhat.com> <8ce94f18-421f-9466-85cf-e17d9caee151@redhat.com> <20160506183345.GK3628@ball> Cc: David Malcolm , gcc-patches@gcc.gnu.org, jit@gcc.gnu.org From: Pedro Alves Message-ID: <5b2de202-c6bd-f8fc-3407-45a40ddfe62c@redhat.com> Date: Mon, 10 Oct 2016 20:32:24 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160506183345.GK3628@ball> Please find below a patch moving the FINAL/OVERRIDE macros to include/ansidecl.h, as I was suggesting in the earlier discussion: On 05/06/2016 07:33 PM, Trevor Saunders wrote: > On Fri, May 06, 2016 at 07:10:33PM +0100, Pedro Alves wrote: >> On 05/06/2016 06:56 PM, Pedro Alves wrote: >> I was going to suggest to put this in include/ansidecl.h, >> so that all C++ libraries / programs in binutils-gdb use the same >> thing, instead of each reinventing the wheel, and I found >> there's already something there: >> >> /* This is used to mark a class or virtual function as final. */ >> #if __cplusplus >= 201103L >> #define GCC_FINAL final >> #elif GCC_VERSION >= 4007 >> #define GCC_FINAL __final >> #else >> #define GCC_FINAL >> #endif >> >> From: >> >> https://gcc.gnu.org/ml/gcc-patches/2015-08/msg00455.html >> >> Apparently the patch that actually uses that was reverted, >> as I can't find any use. > > Yeah, I wanted to use it to work around gdb not dealing well with stuff > in the anon namespace, but somehow that broke aix, and some people > objected and I haven't gotten back to it. > >> I like your names without the GCC_ prefix better though, >> for the same reason of standardizing binutils-gdb + gcc >> on the same symbols. > > I agree, though I'm not really sure when gdb / binutils stuff will > support building as C++11. Meanwhile, GDB master is C++-only nowadays, and we support building with a C++11 compiler, provided there are C++03 fallbacks in place. I'd like to start using FINAL/OVERRIDE, and seems better to me to standardize on the same symbol names across the trees. This patch removes the existing GCC_FINAL macro, since nothing is using it. OK to apply? From: Pedro Alves Date: 2016-10-10 19:25:47 +0100 Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h So that GDB and other projects that share the top level can use them. Bootstrapped with all default languages on x86-64 Fedora 23. gcc/ChangeLog: yyyy-mm-dd Pedro Alves * coretypes.h (OVERRIDE, FINAL): Delete, moved to include/ansidecl.h. include/ChangeLog: yyyy-mm-dd Pedro Alves * ansidecl.h (GCC_FINAL): Delete. (OVERRIDE, FINAL): New, moved from gcc/coretypes.h. --- gcc/coretypes.h | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/gcc/coretypes.h b/gcc/coretypes.h index fe1e984..a9c4df9 100644 --- a/gcc/coretypes.h +++ b/gcc/coretypes.h @@ -367,31 +367,6 @@ typedef void (*gt_pointer_operator) (void *, void *); typedef unsigned char uchar; #endif -/* C++11 adds the ability to add "override" after an implementation of a - virtual function in a subclass, to: - (A) document that this is an override of a virtual function - (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch - of the type signature). - - Similarly, it allows us to add a "final" to indicate that no subclass - may subsequently override the vfunc. - - Provide OVERRIDE and FINAL as macros, allowing us to get these benefits - when compiling with C++11 support, but without requiring C++11. - - For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables - this by default (actually GNU++14). */ - -#if __cplusplus >= 201103 -/* C++11 claims to be available: use it: */ -#define OVERRIDE override -#define FINAL final -#else -/* No C++11 support; leave the macros empty: */ -#define OVERRIDE -#define FINAL -#endif - /* Most host source files will require the following headers. */ #if !defined (GENERATOR_FILE) && !defined (USED_FOR_TARGET) #include "machmode.h" diff --git a/include/ansidecl.h b/include/ansidecl.h index 6e4bfc2..ee93421 100644 --- a/include/ansidecl.h +++ b/include/ansidecl.h @@ -313,13 +313,29 @@ So instead we use the macro below and test it against specific values. */ #define ENUM_BITFIELD(TYPE) unsigned int #endif - /* This is used to mark a class or virtual function as final. */ -#if __cplusplus >= 201103L -#define GCC_FINAL final -#elif GCC_VERSION >= 4007 -#define GCC_FINAL __final +/* C++11 adds the ability to add "override" after an implementation of a + virtual function in a subclass, to: + (A) document that this is an override of a virtual function + (B) allow the compiler to issue a warning if it isn't (e.g. a mismatch + of the type signature). + + Similarly, it allows us to add a "final" to indicate that no subclass + may subsequently override the vfunc. + + Provide OVERRIDE and FINAL as macros, allowing us to get these benefits + when compiling with C++11 support, but without requiring C++11. + + For gcc, use "-std=c++11" to enable C++11 support; gcc 6 onwards enables + this by default (actually GNU++14). */ + +#if __cplusplus >= 201103 +/* C++11 claims to be available: use it: */ +#define OVERRIDE override +#define FINAL final #else -#define GCC_FINAL +/* No C++11 support; leave the macros empty: */ +#define OVERRIDE +#define FINAL #endif #ifdef __cplusplus