public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: David Malcolm <dmalcolm@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH 1/8] Move FINAL and OVERRIDE from ansidecl.h to gcc-plugin.h
Date: Thu, 19 May 2022 08:32:01 -0400	[thread overview]
Message-ID: <20220519123208.3388554-1-dmalcolm@redhat.com> (raw)

As of GCC 11 onwards we have required a C++11 compiler, such as GCC 4.8
or later.  On the assumption that any such compiler correctly implements
"final" and "override", this patch removes the FINAL and OVERRIDE macros
from ansidecl.h.  It adds them back to gcc-plugins.h in case any plugins
make use of them.

Followup patches within this kit replace all uses of the macros in the
tree with the lower-case versions; I've split them up for ease of
review, but would apply them as one combined commit if approved.

gcc/ChangeLog:
	* gcc-plugin.h: Add macros OVERRIDE and FINAL.

include/ChangeLog:
	* ansidecl.h: Drop macros OVERRIDE and FINAL.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
---
 gcc/gcc-plugin.h   |  7 +++++++
 include/ansidecl.h | 41 -----------------------------------------
 2 files changed, 7 insertions(+), 41 deletions(-)

diff --git a/gcc/gcc-plugin.h b/gcc/gcc-plugin.h
index ee9aa865114..f0f3049d0ce 100644
--- a/gcc/gcc-plugin.h
+++ b/gcc/gcc-plugin.h
@@ -44,4 +44,11 @@ along with GCC; see the file COPYING3.  If not see
 #include "tree-check.h"
 #include "plugin.h"
 
+/* Versions of GCC prior to GCC 13 defined these macros in ansidecl.h
+   for C++98 compatibility.  Given that we require C++11 from GCC 11 onwards,
+   keep definitions here in case plugins made use of them.  */
+
+#define OVERRIDE override
+#define FINAL    final
+
 #endif /* GCC_PLUGIN_H */
diff --git a/include/ansidecl.h b/include/ansidecl.h
index efee5b6904b..119748deb68 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -345,47 +345,6 @@ So instead we use the macro below and test it against specific values.  */
 #define CONSTEXPR
 #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 defined __cplusplus
-# if __cplusplus >= 201103
-   /* C++11 claims to be available: use it.  Final/override were only
-      implemented in 4.7, though.  */
-#  if GCC_VERSION < 4007
-#   define OVERRIDE
-#   define FINAL
-#  else
-#   define OVERRIDE override
-#   define FINAL final
-#  endif
-# elif GCC_VERSION >= 4007
-   /* G++ 4.7 supports __final in C++98.  */
-#  define OVERRIDE
-#  define FINAL __final
-# else
-   /* No C++11 support; leave the macros empty.  */
-#  define OVERRIDE
-#  define FINAL
-# endif
-#else
-  /* No C++11 support; leave the macros empty.  */
-# define OVERRIDE
-# define FINAL
-#endif
-
 /* A macro to disable the copy constructor and assignment operator.
    When building with C++11 and above, the methods are explicitly
    deleted, causing a compile-time error if something tries to copy.
-- 
2.26.3


             reply	other threads:[~2022-05-19 12:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-19 12:32 David Malcolm [this message]
2022-05-19 12:32 ` [PATCH 2/8] libcpp: update for move of FINAL And OVERRIDE David Malcolm
2022-05-19 12:32 ` [PATCH 3/8] analyzer: update for move of FINAL and OVERRIDE David Malcolm
2022-05-19 12:32 ` [PATCH 4/8] c-family: " David Malcolm
2022-05-19 12:32 ` [PATCH 5/8] c++: " David Malcolm
2022-05-19 12:32 ` [PATCH 6/8] jit: " David Malcolm
2022-05-19 12:32 ` [PATCH 7/8] gcc: " David Malcolm
2022-05-19 12:32 ` [PATCH 8/8] aarch64: " David Malcolm
2022-05-19 12:46   ` Richard Sandiford
2022-05-19 12:35 ` [PATCH 1/8] Move FINAL and OVERRIDE from ansidecl.h to gcc-plugin.h David Malcolm
2022-05-19 12:45   ` Richard Biener
2022-05-20 14:20     ` David Malcolm
2022-05-19 12:37 ` Richard Biener
2022-05-23 23:42   ` [PATCH] libiberty: remove FINAL and OVERRIDE from ansidecl.h David Malcolm
2022-05-24  7:39     ` Alan Modra
2022-05-24 14:10       ` David Malcolm
2022-05-24 14:12         ` Richard Biener

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=20220519123208.3388554-1-dmalcolm@redhat.com \
    --to=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).