From patchwork Fri Oct 14 16:23:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pedro Alves X-Patchwork-Id: 16509 Received: (qmail 79825 invoked by alias); 14 Oct 2016 16:24:05 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 79608 invoked by uid 89); 14 Oct 2016 16:24:03 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2382, vfunc, claims 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; Fri, 14 Oct 2016 16:23:53 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (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 44F034DD6E; Fri, 14 Oct 2016 16:23:52 +0000 (UTC) Received: from cascais.lan (ovpn01.gateway.prod.ext.ams2.redhat.com [10.39.146.11]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u9EGNoUX018448; Fri, 14 Oct 2016 12:23:51 -0400 From: Pedro Alves To: gdb-patches@sourceware.org Cc: binutils@sourceware.org Subject: [pushed 1/2] Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h Date: Fri, 14 Oct 2016 17:23:48 +0100 Message-Id: <1476462229-27007-2-git-send-email-palves@redhat.com> In-Reply-To: <1476462229-27007-1-git-send-email-palves@redhat.com> References: <1476462229-27007-1-git-send-email-palves@redhat.com> So that GDB and other projects that share the top level can use them. Bootstrapped with all default languages + jit on x86-64 Fedora 23. gcc/ChangeLog: 2016-10-14 Pedro Alves * coretypes.h (OVERRIDE, FINAL): Delete, moved to include/ansidecl.h. include/ChangeLog: 2016-10-14 Pedro Alves * ansidecl.h (GCC_FINAL): Delete. (OVERRIDE, FINAL): New, moved from gcc/coretypes.h. --- include/ChangeLog | 5 +++++ include/ansidecl.h | 28 ++++++++++++++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/include/ChangeLog b/include/ChangeLog index 6f68130..bdff2dd 100644 --- a/include/ChangeLog +++ b/include/ChangeLog @@ -1,3 +1,8 @@ +2016-10-14 Pedro Alves + + * ansidecl.h (GCC_FINAL): Delete. + (OVERRIDE, FINAL): New, moved from gcc/coretypes.h. + 2016-10-14 Claudiu Zissulescu * opcode/arc.h (ARC_OPCODE_ARCV2): New define. diff --git a/include/ansidecl.h b/include/ansidecl.h index 18b7821..7dd7baa 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