public inbox for jit@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00 [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h David Malcolm
@ 2016-01-01  0:00 ` Pedro Alves
  2016-01-01  0:00   ` Jason Merrill
  2016-01-01  0:00   ` Pedro Alves
  2016-01-01  0:00 ` [PATCH 2/2] jit: use FINAL and OVERRIDE throughout David Malcolm
  2016-01-01  0:00 ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Jakub Jelinek
  2 siblings, 2 replies; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm, gcc-patches, jit

On 05/06/2016 05:40 PM, David Malcolm wrote:
> +#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
> +

Is there a reason this is preferred over using override/final in
the sources directly, and then define them away as empty
on pre-C++11?

I mean:

#if __cplusplus < 201103
# define override
# define final
#endif

then use override/final throughout instead of OVERRIDE/FINAL.

If building gcc as a C++11 program is supported, then it
won't be possible to use these names as symbols for
anything else anyway?

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00 [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h David Malcolm
  2016-01-01  0:00 ` Pedro Alves
  2016-01-01  0:00 ` [PATCH 2/2] jit: use FINAL and OVERRIDE throughout David Malcolm
@ 2016-01-01  0:00 ` Jakub Jelinek
  2016-01-01  0:00   ` CONSTEXPR macro (was "Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h") David Malcolm
  2 siblings, 1 reply; 21+ messages in thread
From: Jakub Jelinek @ 2016-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, jit

On Fri, May 06, 2016 at 12:40:45PM -0400, David Malcolm wrote:
> 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.
> 
> We use virtual functions in a few places (e.g. in the jit), so it would
> be good to get this extra checking.
> 
> This patch adds OVERRIDE and FINAL as macros to coretypes.h
> allowing us to get this extra checking when compiling with a compiler
> that implements C++11 or later (e.g. gcc 6 by default),
> but without requiring C++11.

Don't we also want CONSTEXPR similarly defined to constexpr for C++11 and
above and nothing otherwise?

	Jakub

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00 ` Pedro Alves
@ 2016-01-01  0:00   ` Jason Merrill
  2016-01-01  0:00   ` Pedro Alves
  1 sibling, 0 replies; 21+ messages in thread
From: Jason Merrill @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves; +Cc: David Malcolm, gcc-patches List, jit

On Fri, May 6, 2016 at 1:56 PM, Pedro Alves <palves@redhat.com> wrote:
> On 05/06/2016 05:40 PM, David Malcolm wrote:
>> +#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
>> +
>
> Is there a reason this is preferred over using override/final in
> the sources directly, and then define them away as empty
> on pre-C++11?
>
> I mean:
>
> #if __cplusplus < 201103
> # define override
> # define final
> #endif
>
> then use override/final throughout instead of OVERRIDE/FINAL.

This would break any existing use of those identifiers; they are not
keywords, so a variable named "final" is perfectly valid C++11.

Jason

^ permalink raw reply	[flat|nested] 21+ messages in thread

* CONSTEXPR macro (was "Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h")
  2016-01-01  0:00 ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Jakub Jelinek
@ 2016-01-01  0:00   ` David Malcolm
  2016-01-01  0:00     ` Jakub Jelinek
  0 siblings, 1 reply; 21+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches, jit

On Fri, 2016-05-06 at 18:20 +0200, Jakub Jelinek wrote:
> On Fri, May 06, 2016 at 12:40:45PM -0400, David Malcolm wrote:
> > 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.
> > 
> > We use virtual functions in a few places (e.g. in the jit), so it
> > would
> > be good to get this extra checking.
> > 
> > This patch adds OVERRIDE and FINAL as macros to coretypes.h
> > allowing us to get this extra checking when compiling with a
> > compiler
> > that implements C++11 or later (e.g. gcc 6 by default),
> > but without requiring C++11.
> 
> Don't we also want CONSTEXPR similarly defined to constexpr for C++11
> and
> above and nothing otherwise?

Perhaps, but CONSTEXPR seems to be more awkward than OVERRIDE and
FINAL.  The meanings of "final" and "override" are consistent between
C++11 and C++14, but C++14 allows more things to be marked as
"constexpr" than C++11.  Hence having a single "CONSTEXPR" macro might
not be sufficient.  Perhaps there'd be CONSTEXPR_11 and CONSTEXPR_14
macros for things that are constexpr in C++11 onwards and constexpr in
C++14 onwards, respectively? (seems ugly to me).

Are the OVERRIDE and FINAL macros OK for trunk?

Thanks
Dave

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00     ` Trevor Saunders
  2016-01-01  0:00       ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h) Pedro Alves
@ 2016-01-01  0:00       ` Pedro Alves
  1 sibling, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

On 05/06/2016 07:33 PM, Trevor Saunders wrote:
> On Fri, May 06, 2016 at 07:10:33PM +0100, Pedro Alves wrote:

>> 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.

gdb already builds as a C++ compiler by default today, and will
switch to C++-only right after the next release (couple months),
the latest.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00   ` Pedro Alves
@ 2016-01-01  0:00     ` Trevor Saunders
  2016-01-01  0:00       ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h) Pedro Alves
  2016-01-01  0:00       ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Pedro Alves
  0 siblings, 2 replies; 21+ messages in thread
From: Trevor Saunders @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves; +Cc: David Malcolm, gcc-patches, jit

On Fri, May 06, 2016 at 07:10:33PM +0100, Pedro Alves wrote:
> On 05/06/2016 06:56 PM, Pedro Alves wrote:
> 
> > If building gcc as a C++11 program is supported, then it
> > won't be possible to use these names as symbols for
> > anything else anyway?
> 
> Just found out the above is not true.  Apparently I've
> been stuck in C++98 for too long...  Sorry about the noise.
> 
> 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.

Trev

> 
> 
> -- 
> Thanks,
> Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 2/2] jit: use FINAL and OVERRIDE throughout
  2016-01-01  0:00 [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h David Malcolm
  2016-01-01  0:00 ` Pedro Alves
@ 2016-01-01  0:00 ` David Malcolm
  2016-01-01  0:00   ` David Malcolm
  2016-01-01  0:00 ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Jakub Jelinek
  2 siblings, 1 reply; 21+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches, jit; +Cc: David Malcolm

Mark most virtual functions in gcc/jit as being FINAL OVERRIDE.
gcc::jit::recording::lvalue::access_as_rvalue is the sole OVERRIDE
that isn't a FINAL.

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.

I can self-approve this, but as asked in patch 1,
does "final" imply "override"?  Is "final override" a tautology?

gcc/jit/ChangeLog:
	* jit-playback.h: Within namespace gcc:jit::playback...
	(compile_to_memory::postprocess): Mark with FINAL OVERRIDE.
	(compile_to_file::postprocess): Likewise.
	(function::finalizer): Likewise.
	(block::finalizer): Likewise.
	(source_file::finalizer): Likewise.
	(source_line::finalizer): Likewise.
	* jit-recording.c (gcc::jit::rvalue_usage_validator):: Likewise.
	* jit-recording.h: Within namespace gcc::jit::recording...
	(string::replay_into): Mark with FINAL OVERRIDE.
	(string::make_debug_string): Likewise.
	(string::write_reproducer): Likewise.
	(location::replay_into): Likewise.
	(location::dyn_cast_location): Likewise.
	(location::make_debug_string): Likewise.
	(location::write_reproducer): Likewise.
	(memento_of_get_type::dereference): Likewise.
	(memento_of_get_type::accepts_writes_from): Likewise.
	(memento_of_get_type::is_int): Likewise.
	(memento_of_get_type::is_float): Likewise.
	(memento_of_get_type::is_bool): Likewise.
	(memento_of_get_type::is_pointer): Likewise.
	(memento_of_get_type::is_array): Likewise.
	(memento_of_get_type::is_void): Likewise.
	(memento_of_get_type::replay_into): Likewise.
	(memento_of_get_type::make_debug_string): Likewise.
	(memento_of_get_type::write_reproducer): Likewise.
	(memento_of_get_pointer::dereference): Likewise.
	(memento_of_get_pointer::accepts_writes_from): Likewise.
	(memento_of_get_pointer::replay_into): Likewise.
	(memento_of_get_pointer::is_int): Likewise.
	(memento_of_get_pointer::is_float): Likewise.
	(memento_of_get_pointer::is_bool): Likewise.
	(memento_of_get_pointer::is_pointer): Likewise.
	(memento_of_get_pointer::is_array): Likewise.
	(memento_of_get_pointer::make_debug_string): Likewise.
	(memento_of_get_pointer::write_reproducer): Likewise.
	(memento_of_get_const::dereference): Likewise.
	(memento_of_get_const::accepts_writes_from): Likewise.
	(memento_of_get_const::unqualified): Likewise.
	(memento_of_get_const::is_int): Likewise.
	(memento_of_get_const::is_float): Likewise.
	(memento_of_get_const::is_bool): Likewise.
	(memento_of_get_const::is_pointer): Likewise.
	(memento_of_get_const::is_array): Likewise.
	(memento_of_get_const::void replay_into): Likewise;
	(memento_of_get_const::make_debug_string): Likewise.
	(memento_of_get_const::write_reproducer): Likewise.
	(memento_of_get_volatile::dereference): Likewise.
	(memento_of_get_volatile::unqualified): Likewise.
	(memento_of_get_volatile::is_int): Likewise.
	(memento_of_get_volatile::is_float): Likewise.
	(memento_of_get_volatile::is_bool): Likewise.
	(memento_of_get_volatile::is_pointer): Likewise.
	(memento_of_get_volatile::is_array): Likewise.
	(memento_of_get_volatile::replay_into): Likewise;
	(memento_of_get_volatile::make_debug_string): Likewise.
	(memento_of_get_volatile::write_reproducer): Likewise.
	(array_type::dereference): Likewise.
	(array_type::is_int): Likewise.
	(array_type::is_float): Likewise.
	(array_type::is_bool): Likewise.
	(array_type::is_pointer): Likewise.
	(array_type::is_array): Likewise.
	(array_type::replay_into): Likewise;
	(array_type::make_debug_string): Likewise.
	(array_type::write_reproducer): Likewise.
	(function_type::dereference): Likewise.
	(function_type::function_dyn_cast_function_type): Likewise.
	(function_type::function_as_a_function_type): Likewise.
	(function_type::is_int): Likewise.
	(function_type::is_float): Likewise.
	(function_type::is_bool): Likewise.
	(function_type::is_pointer): Likewise.
	(function_type::is_array): Likewise.
	(function_type::replay_into): Likewise;
	(function_type::make_debug_string): Likewise.
	(function_type::write_reproducer): Likewise.
	(field::replay_into): Likewise;
	(field::write_to_dump): Likewise.
	(field::make_debug_string): Likewise.
	(field::write_reproducer): Likewise.
	(compound_type::dereference): Likewise.
	(compound_type::is_int): Likewise.
	(compound_type::is_float): Likewise.
	(compound_type::is_bool): Likewise.
	(compound_type::is_pointer): Likewise.
	(compound_type::is_array): Likewise.
	(compound_type::has_known_size): Likewise.
	(struct_::dyn_cast_struct): Likewise.
	(struct_::replay_into): Likewise.
	(struct_::access_as_type): Likewise.
	(struct_::make_debug_string): Likewise.
	(struct_::write_reproducer): Likewise.
	(fields::replay_into): Likewise.
	(fields::write_to_dump): Likewise.
	(fields::make_debug_string): Likewise.
	(fields::write_reproducer): Likewise.
	(union_::replay_into): Likewise.
	(union_::make_debug_string): Likewise.
	(union_::write_reproducer): Likewise.
	(lvalue::access_as_rvalue): Mark with OVERRIDE.
	(param::replay_into): Mark with FINAL OVERRIDE.
	(param::visit_children): Likewise.
	(param::dyn_cast_param): Likewise.
	(param::access_as_rvalue): Likewise.
	(param::access_as_lvalue): Likewise.
	(param::make_debug_string): Likewise.
	(param::write_reproducer): Likewise.
	(param::get_precedence): Likewise.
	(function::replay_into): Likewise.
	(function::write_to_dump): Likewise.
	(function::make_debug_string): Likewise.
	(function::write_reproducer): Likewise.
	(block::write_to_dump): Likewise.
	(block::make_debug_string): Likewise.
	(block::write_reproducer): Likewise.
	(block::replay_into): Likewise.
	(global::replay_into): Likewise;
	(global::visit_children): Likewise.
	(global::write_to_dump): Likewise.
	(global::make_debug_string): Likewise.
	(global::write_reproducer): Likewise.
	(global::get_precedence): Likewise.
	(memento_of_new_rvalue_from_const::replay_into): Likewise.
	(memento_of_new_rvalue_from_const::visit_children): Likewise.
	(memento_of_new_rvalue_from_const::is_constant): Likewise.
	(memento_of_new_rvalue_from_const::get_wide_int): Likewise.
	(memento_of_new_rvalue_from_const::make_debug_string): Likewise.
	(memento_of_new_rvalue_from_const::write_reproducer): Likewise.
	(memento_of_new_rvalue_from_const::get_precedence): Likewise.
	(memento_of_new_string_literal::replay_into): Likewise.
	(memento_of_new_string_literal::visit_children): Likewise.
	(memento_of_new_string_literal::make_debug_string): Likewise.
	(memento_of_new_string_literal::write_reproducer): Likewise.
	(memento_of_new_string_literal::get_precedence): Likewise.
	(unary_op::replay_into): Likewise.
	(unary_op::visit_children): Likewise.
	(unary_op::make_debug_string): Likewise.
	(unary_op::write_reproducer): Likewise.
	(unary_op::get_precedence): Likewise.
	(binary_op::replay_into): Likewise.
	(binary_op::visit_children): Likewise.
	(binary_op::make_debug_string): Likewise.
	(binary_op::write_reproducer): Likewise.
	(binary_op::get_precedence): Likewise.
	(comparison::replay_into): Likewise.
	(comparison::visit_children): Likewise.
	(comparison::make_debug_string): Likewise.
	(comparison::write_reproducer): Likewise.
	(comparison::get_precedence): Likewise.
	(cast::replay_into): Likewise.
	(cast::visit_children): Likewise.
	(cast::make_debug_string): Likewise.
	(cast::write_reproducer): Likewise.
	(cast::get_precedence): Likewise.
	(call::replay_into): Likewise.
	(call::visit_children): Likewise.
	(call::make_debug_string): Likewise.
	(call::write_reproducer): Likewise.
	(call::get_precedence): Likewise.
	(call_through_ptr::replay_into): Likewise.
	(call_through_ptr::visit_children): Likewise.
	(call_through_ptr::make_debug_string): Likewise.
	(call_through_ptr::write_reproducer): Likewise.
	(call_through_ptr::get_precedence): Likewise.
	(array_access::replay_into): Likewise.
	(array_access::visit_children): Likewise.
	(array_access::make_debug_string): Likewise.
	(array_access::write_reproducer): Likewise.
	(array_access::get_precedence): Likewise.
	(access_field_of_lvalue::replay_into): Likewise.
	(access_field_of_lvalue::visit_children): Likewise.
	(access_field_of_lvalue::make_debug_string): Likewise.
	(access_field_of_lvalue::write_reproducer): Likewise.
	(access_field_of_lvalue::get_precedence): Likewise.
	(access_field_rvalue::replay_into): Likewise.
	(access_field_rvalue::visit_children): Likewise.
	(access_field_rvalue::make_debug_string): Likewise.
	(access_field_rvalue::write_reproducer): Likewise.
	(access_field_rvalue::get_precedence): Likewise.
	(dereference_field_rvalue::replay_into): Likewise.
	(dereference_field_rvalue::visit_children): Likewise.
	(dereference_field_rvalue::make_debug_string): Likewise.
	(dereference_field_rvalue::write_reproducer): Likewise.
	(dereference_field_rvalue::get_precedence): Likewise.
	(dereference_rvalue::replay_into): Likewise.
	(dereference_rvalue::visit_children): Likewise.
	(dereference_rvalue::make_debug_string): Likewise.
	(dereference_rvalue::write_reproducer): Likewise.
	(dereference_rvalue::get_precedence): Likewise.
	(get_address_of_lvalue::replay_into): Likewise.
	(get_address_of_lvalue::visit_children): Likewise.
	(get_address_of_lvalue::make_debug_string): Likewise.
	(get_address_of_lvalue::write_reproducer): Likewise.
	(get_address_of_lvalue::get_precedence): Likewise.
	(local::replay_into): Likewise.
	(local::visit_children): Likewise.
	(local::write_to_dump): Likewise.
	(local::make_debug_string): Likewise.
	(local::write_reproducer): Likewise.
	(local::get_precedence): Likewise.
	(statement::write_to_dump): Likewise.
	(eval::replay_into): Likewise.
	(eval::make_debug_string): Likewise.
	(eval::write_reproducer): Likewise.
	(assignment::replay_into): Likewise.
	(assignment::make_debug_string): Likewise.
	(assignment::write_reproducer): Likewise.
	(assignment_op::replay_into): Likewise.
	(assignment_op::make_debug_string): Likewise.
	(assignment_op::write_reproducer): Likewise.
	(comment::replay_into): Likewise.
	(comment::make_debug_string): Likewise.
	(comment::write_reproducer): Likewise.
	(conditional::replay_into): Likewise.
	(conditional::get_successor_blocks): Likewise.
	(conditional::make_debug_string): Likewise.
	(conditional::write_reproducer): Likewise.
	(jump::replay_into): Likewise.
	(jump::get_successor_blocks): Likewise.
	(jump::make_debug_string): Likewise.
	(jump::write_reproducer): Likewise.
	(return_::replay_into): Likewise.
	(return_::get_successor_blocks): Likewise.
	(return_::make_debug_string): Likewise.
	(return_::write_reproducer): Likewise.
	(case_::replay_into): Likewise.
	(case_::write_reproducer): Likewise.
	(case_::make_debug_string): Likewise.
	(switch_::replay_into): Likewise.
	(switch_::get_successor_blocks): Likewise.
	(switch_::make_debug_string): Likewise.
	(switch_::write_reproducer): Likewise.
---
 gcc/jit/jit-playback.h  |  12 +-
 gcc/jit/jit-recording.c |   2 +-
 gcc/jit/jit-recording.h | 495 ++++++++++++++++++++++++++----------------------
 3 files changed, 277 insertions(+), 232 deletions(-)

diff --git a/gcc/jit/jit-playback.h b/gcc/jit/jit-playback.h
index 7519bc4..905747c 100644
--- a/gcc/jit/jit-playback.h
+++ b/gcc/jit/jit-playback.h
@@ -314,7 +314,7 @@ class compile_to_memory : public context
 {
  public:
   compile_to_memory (recording::context *ctxt);
-  void postprocess (const char *ctxt_progname);
+  void postprocess (const char *ctxt_progname) FINAL OVERRIDE;
 
   result *get_result_obj () const { return m_result; }
 
@@ -328,7 +328,7 @@ class compile_to_file : public context
   compile_to_file (recording::context *ctxt,
 		   enum gcc_jit_output_kind output_kind,
 		   const char *output_path);
-  void postprocess (const char *ctxt_progname);
+  void postprocess (const char *ctxt_progname) FINAL OVERRIDE;
 
  private:
   void
@@ -414,7 +414,7 @@ public:
   function(context *ctxt, tree fndecl, enum gcc_jit_function_kind kind);
 
   void gt_ggc_mx ();
-  void finalizer ();
+  void finalizer () FINAL OVERRIDE;
 
   tree get_return_type_as_tree () const;
 
@@ -475,7 +475,7 @@ public:
   block (function *func,
 	 const char *name);
 
-  void finalizer ();
+  void finalizer () FINAL OVERRIDE;
 
   tree as_label_decl () const { return m_label_decl; }
 
@@ -619,7 +619,7 @@ class source_file : public wrapper
 {
 public:
   source_file (tree filename);
-  void finalizer ();
+  void finalizer () FINAL OVERRIDE;
 
   source_line *
   get_source_line (int line_num);
@@ -640,7 +640,7 @@ class source_line : public wrapper
 {
 public:
   source_line (source_file *file, int line_num);
-  void finalizer ();
+  void finalizer () FINAL OVERRIDE;
 
   location *
   get_location (recording::location *rloc, int column_num);
diff --git a/gcc/jit/jit-recording.c b/gcc/jit/jit-recording.c
index 41556db..8f5f914 100644
--- a/gcc/jit/jit-recording.c
+++ b/gcc/jit/jit-recording.c
@@ -3015,7 +3015,7 @@ class rvalue_usage_validator : public recording::rvalue_visitor
 			  recording::statement *stmt);
 
   void
-  visit (recording::rvalue *rvalue);
+  visit (recording::rvalue *rvalue) FINAL OVERRIDE;
 
  private:
   const char *m_api_funcname;
diff --git a/gcc/jit/jit-recording.h b/gcc/jit/jit-recording.h
index d99c752..1c3e763 100644
--- a/gcc/jit/jit-recording.h
+++ b/gcc/jit/jit-recording.h
@@ -401,11 +401,11 @@ public:
   static string * from_printf (context *ctxt, const char *fmt, ...)
     GNU_PRINTF(2, 3);
 
-  void replay_into (replayer *) {}
+  void replay_into (replayer *) FINAL OVERRIDE {}
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   size_t m_len;
@@ -424,7 +424,7 @@ public:
     m_created_by_user (created_by_user)
  {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
   playback::location *
   playback_location (replayer *r)
@@ -453,12 +453,12 @@ public:
     return static_cast <playback::location *> (m_playback_obj);
   }
 
-  location *dyn_cast_location () { return this; }
+  location *dyn_cast_location () FINAL OVERRIDE { return this; }
   bool created_by_user () const { return m_created_by_user; }
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   string *m_filename;
@@ -538,9 +538,9 @@ public:
   : type (ctxt),
     m_kind (kind) {}
 
-  type *dereference ();
+  type *dereference () FINAL OVERRIDE;
 
-  bool accepts_writes_from (type *rtype)
+  bool accepts_writes_from (type *rtype) FINAL OVERRIDE
   {
     if (m_kind == GCC_JIT_TYPE_VOID_PTR)
       if (rtype->is_pointer ())
@@ -553,19 +553,19 @@ public:
     return type::accepts_writes_from (rtype);
   }
 
-  bool is_int () const;
-  bool is_float () const;
-  bool is_bool () const;
-  type *is_pointer () { return dereference (); }
-  type *is_array () { return NULL; }
-  bool is_void () const { return m_kind == GCC_JIT_TYPE_VOID; }
+  bool is_int () const FINAL OVERRIDE;
+  bool is_float () const FINAL OVERRIDE;
+  bool is_bool () const FINAL OVERRIDE;
+  type *is_pointer () FINAL OVERRIDE { return dereference (); }
+  type *is_array () FINAL OVERRIDE { return NULL; }
+  bool is_void () const FINAL OVERRIDE { return m_kind == GCC_JIT_TYPE_VOID; }
 
 public:
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   enum gcc_jit_types m_kind;
@@ -579,21 +579,21 @@ public:
   : type (other_type->m_ctxt),
     m_other_type (other_type) {}
 
-  type *dereference () { return m_other_type; }
+  type *dereference () FINAL OVERRIDE { return m_other_type; }
 
-  bool accepts_writes_from (type *rtype);
+  bool accepts_writes_from (type *rtype) FINAL OVERRIDE;
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  bool is_int () const { return false; }
-  bool is_float () const { return false; }
-  bool is_bool () const { return false; }
-  type *is_pointer () { return m_other_type; }
-  type *is_array () { return NULL; }
+  bool is_int () const FINAL OVERRIDE { return false; }
+  bool is_float () const FINAL OVERRIDE { return false; }
+  bool is_bool () const FINAL OVERRIDE { return false; }
+  type *is_pointer () FINAL OVERRIDE { return m_other_type; }
+  type *is_array () FINAL OVERRIDE { return NULL; }
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   type *m_other_type;
@@ -607,28 +607,28 @@ public:
   : type (other_type->m_ctxt),
     m_other_type (other_type) {}
 
-  type *dereference () { return m_other_type->dereference (); }
+  type *dereference () FINAL OVERRIDE { return m_other_type->dereference (); }
 
-  bool accepts_writes_from (type */*rtype*/)
+  bool accepts_writes_from (type */*rtype*/) FINAL OVERRIDE
   {
     /* Can't write to a "const".  */
     return false;
   }
 
   /* Strip off the "const", giving the underlying type.  */
-  type *unqualified () { return m_other_type; }
+  type *unqualified () FINAL OVERRIDE { return m_other_type; }
 
-  bool is_int () const { return m_other_type->is_int (); }
-  bool is_float () const { return m_other_type->is_float (); }
-  bool is_bool () const { return m_other_type->is_bool (); }
-  type *is_pointer () { return m_other_type->is_pointer (); }
-  type *is_array () { return m_other_type->is_array (); }
+  bool is_int () const FINAL OVERRIDE { return m_other_type->is_int (); }
+  bool is_float () const FINAL OVERRIDE { return m_other_type->is_float (); }
+  bool is_bool () const FINAL OVERRIDE { return m_other_type->is_bool (); }
+  type *is_pointer () FINAL OVERRIDE { return m_other_type->is_pointer (); }
+  type *is_array () FINAL OVERRIDE { return m_other_type->is_array (); }
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   type *m_other_type;
@@ -642,22 +642,22 @@ public:
   : type (other_type->m_ctxt),
     m_other_type (other_type) {}
 
-  type *dereference () { return m_other_type->dereference (); }
+  type *dereference () FINAL OVERRIDE { return m_other_type->dereference (); }
 
   /* Strip off the "volatile", giving the underlying type.  */
-  type *unqualified () { return m_other_type; }
+  type *unqualified () FINAL OVERRIDE { return m_other_type; }
 
-  bool is_int () const { return m_other_type->is_int (); }
-  bool is_float () const { return m_other_type->is_float (); }
-  bool is_bool () const { return m_other_type->is_bool (); }
-  type *is_pointer () { return m_other_type->is_pointer (); }
-  type *is_array () { return m_other_type->is_array (); }
+  bool is_int () const FINAL OVERRIDE { return m_other_type->is_int (); }
+  bool is_float () const FINAL OVERRIDE { return m_other_type->is_float (); }
+  bool is_bool () const FINAL OVERRIDE { return m_other_type->is_bool (); }
+  type *is_pointer () FINAL OVERRIDE { return m_other_type->is_pointer (); }
+  type *is_array () FINAL OVERRIDE { return m_other_type->is_array (); }
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   type *m_other_type;
@@ -676,19 +676,19 @@ class array_type : public type
     m_num_elements (num_elements)
   {}
 
-  type *dereference ();
+  type *dereference () FINAL OVERRIDE;
 
-  bool is_int () const { return false; }
-  bool is_float () const { return false; }
-  bool is_bool () const { return false; }
-  type *is_pointer () { return NULL; }
-  type *is_array () { return m_element_type; }
+  bool is_int () const FINAL OVERRIDE { return false; }
+  bool is_float () const FINAL OVERRIDE { return false; }
+  bool is_bool () const FINAL OVERRIDE { return false; }
+  type *is_pointer () FINAL OVERRIDE { return NULL; }
+  type *is_array () FINAL OVERRIDE { return m_element_type; }
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
  private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
  private:
   location *m_loc;
@@ -705,17 +705,17 @@ public:
 		 type **param_types,
 		 int is_variadic);
 
-  type *dereference ();
-  function_type *dyn_cast_function_type () { return this; }
-  function_type *as_a_function_type () { return this; }
+  type *dereference () FINAL OVERRIDE;
+  function_type *dyn_cast_function_type () FINAL OVERRIDE { return this; }
+  function_type *as_a_function_type () FINAL OVERRIDE { return this; }
 
-  bool is_int () const { return false; }
-  bool is_float () const { return false; }
-  bool is_bool () const { return false; }
-  type *is_pointer () { return NULL; }
-  type *is_array () { return NULL; }
+  bool is_int () const FINAL OVERRIDE { return false; }
+  bool is_float () const FINAL OVERRIDE { return false; }
+  bool is_bool () const FINAL OVERRIDE { return false; }
+  type *is_pointer () FINAL OVERRIDE { return NULL; }
+  type *is_array () FINAL OVERRIDE { return NULL; }
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
   type * get_return_type () const { return m_return_type; }
   const vec<type *> &get_param_types () const { return m_param_types; }
@@ -728,9 +728,9 @@ public:
 			     memento *ptr_type);
 
  private:
-  string * make_debug_string ();
+  string * make_debug_string () FINAL OVERRIDE;
   string * make_debug_string_with (const char *);
-  void write_reproducer (reproducer &r);
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   type *m_return_type;
@@ -757,9 +757,9 @@ public:
   compound_type * get_container () const { return m_container; }
   void set_container (compound_type *c) { m_container = c; }
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
   playback::field *
   playback_field () const
@@ -768,8 +768,8 @@ public:
   }
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   location *m_loc;
@@ -795,15 +795,15 @@ public:
 	      int num_fields,
 	      field **fields);
 
-  type *dereference ();
+  type *dereference () FINAL OVERRIDE;
 
-  bool is_int () const { return false; }
-  bool is_float () const { return false; }
-  bool is_bool () const { return false; }
-  type *is_pointer () { return NULL; }
-  type *is_array () { return NULL; }
+  bool is_int () const FINAL OVERRIDE { return false; }
+  bool is_float () const FINAL OVERRIDE { return false; }
+  bool is_bool () const FINAL OVERRIDE { return false; }
+  type *is_pointer () FINAL OVERRIDE { return NULL; }
+  type *is_array () FINAL OVERRIDE { return NULL; }
 
-  bool has_known_size () const { return m_fields != NULL; }
+  bool has_known_size () const FINAL OVERRIDE { return m_fields != NULL; }
 
   playback::compound_type *
   playback_compound_type ()
@@ -824,18 +824,18 @@ public:
 	   location *loc,
 	   string *name);
 
-  struct_ *dyn_cast_struct () { return this; }
+  struct_ *dyn_cast_struct () FINAL OVERRIDE { return this; }
 
   type *
   as_type () { return this; }
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  const char *access_as_type (reproducer &r);
+  const char *access_as_type (reproducer &r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 };
 
 // memento of struct_::set_fields
@@ -846,16 +846,16 @@ public:
 	  int num_fields,
 	  field **fields);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
   int length () const { return m_fields.length (); }
   field *get_field (int i) const { return m_fields[i]; }
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   compound_type *m_struct_or_union;
@@ -869,11 +869,11 @@ public:
 	  location *loc,
 	  string *name);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   location *m_loc;
@@ -1009,7 +1009,7 @@ public:
   rvalue *
   as_rvalue () { return this; }
 
-  const char *access_as_rvalue (reproducer &r);
+  const char *access_as_rvalue (reproducer &r) OVERRIDE;
   virtual const char *access_as_lvalue (reproducer &r);
 };
 
@@ -1026,9 +1026,9 @@ public:
   lvalue *
   as_lvalue () { return this; }
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *) {}
+  void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
 
   playback::param *
   playback_param () const
@@ -1036,15 +1036,18 @@ public:
     return static_cast <playback::param *> (m_playback_obj);
   }
 
-  param *dyn_cast_param () { return this; }
+  param *dyn_cast_param () FINAL OVERRIDE { return this; }
 
-  const char *access_as_rvalue (reproducer &r);
-  const char *access_as_lvalue (reproducer &r);
+  const char *access_as_rvalue (reproducer &r) FINAL OVERRIDE;
+  const char *access_as_lvalue (reproducer &r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string () { return m_name; }
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_PRIMARY; }
+  string * make_debug_string () FINAL OVERRIDE { return m_name; }
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_PRIMARY;
+  }
 
 private:
   string *m_name;
@@ -1063,7 +1066,7 @@ public:
 	    int is_variadic,
 	    enum built_in_function builtin_id);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
   playback::function *
   playback_function () const
@@ -1093,15 +1096,15 @@ public:
 
   bool is_variadic () const { return m_is_variadic; }
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
   void validate ();
 
   void dump_to_dot (const char *path);
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   location *m_loc;
@@ -1183,7 +1186,7 @@ public:
     return static_cast <playback::block *> (m_playback_obj);
   }
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
   bool validate ();
 
@@ -1195,10 +1198,10 @@ public:
   vec <block *> get_successor_blocks () const;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
   void dump_to_dot (pretty_printer *pp);
   void dump_edges_to_dot (pretty_printer *pp);
@@ -1227,16 +1230,19 @@ public:
     m_name (name)
   {}
 
-  void replay_into (replayer *);
+  void replay_into (replayer *) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *) {}
+  void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string () { return m_name; }
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_PRIMARY; }
+  string * make_debug_string () FINAL OVERRIDE { return m_name; }
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_PRIMARY;
+  }
 
 private:
   enum gcc_jit_global_kind m_kind;
@@ -1254,18 +1260,21 @@ public:
   : rvalue (ctxt, loc, type),
     m_value (value) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *) {}
+  void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
 
-  bool is_constant () const { return true; }
+  bool is_constant () const FINAL OVERRIDE { return true; }
 
-  bool get_wide_int (wide_int *out) const;
+  bool get_wide_int (wide_int *out) const FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_PRIMARY; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_PRIMARY;
+  }
 
 private:
   HOST_TYPE m_value;
@@ -1280,14 +1289,17 @@ public:
   : rvalue (ctxt, loc, ctxt->get_type (GCC_JIT_TYPE_CONST_CHAR_PTR)),
     m_value (value) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *) {}
+  void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_PRIMARY; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_PRIMARY;
+  }
 
 private:
   string *m_value;
@@ -1306,14 +1318,17 @@ public:
     m_a (a)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const {return PRECEDENCE_UNARY;}
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_UNARY;
+  }
 
 private:
   enum gcc_jit_unary_op m_op;
@@ -1333,14 +1348,14 @@ public:
     m_a (a),
     m_b (b) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const;
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE;
 
 private:
   enum gcc_jit_binary_op m_op;
@@ -1361,14 +1376,14 @@ public:
     m_b (b)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const;
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE;
 
 private:
   enum gcc_jit_comparison m_op;
@@ -1387,14 +1402,17 @@ public:
     m_rvalue (a)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_CAST; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_CAST;
+  }
 
 private:
   rvalue *m_rvalue;
@@ -1409,14 +1427,17 @@ public:
 	int numargs,
 	rvalue **args);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   function *m_func;
@@ -1432,14 +1453,17 @@ public:
 		    int numargs,
 		    rvalue **args);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   rvalue *m_fn_ptr;
@@ -1458,14 +1482,17 @@ public:
     m_index (index)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   rvalue *m_ptr;
@@ -1484,14 +1511,17 @@ public:
     m_field (field)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   lvalue *m_lvalue;
@@ -1510,14 +1540,17 @@ public:
     m_field (field)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   rvalue *m_rvalue;
@@ -1536,14 +1569,17 @@ public:
     m_field (field)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_POSTFIX; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_POSTFIX;
+  }
 
 private:
   rvalue *m_rvalue;
@@ -1559,14 +1595,17 @@ public:
   : lvalue (ctxt, loc, val->get_type ()->dereference ()),
     m_rvalue (val) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_UNARY; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_UNARY;
+  }
 
 private:
   rvalue *m_rvalue;
@@ -1582,14 +1621,17 @@ public:
     m_lvalue (val)
   {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *v);
+  void visit_children (rvalue_visitor *v) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_UNARY; }
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_UNARY;
+  }
 
 private:
   lvalue *m_lvalue;
@@ -1606,16 +1648,19 @@ public:
     set_scope (func);
   }
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  void visit_children (rvalue_visitor *) {}
+  void visit_children (rvalue_visitor *) FINAL OVERRIDE {}
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string () { return m_name; }
-  void write_reproducer (reproducer &r);
-  enum precedence get_precedence () const { return PRECEDENCE_PRIMARY; }
+  string * make_debug_string () FINAL OVERRIDE { return m_name; }
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
+  enum precedence get_precedence () const FINAL OVERRIDE
+  {
+    return PRECEDENCE_PRIMARY;
+  }
 
 private:
   function *m_func;
@@ -1627,7 +1672,7 @@ class statement : public memento
 public:
   virtual vec <block *> get_successor_blocks () const;
 
-  void write_to_dump (dump &d);
+  void write_to_dump (dump &d) FINAL OVERRIDE;
 
   block *get_block () const { return m_block; }
   location *get_loc () const { return m_loc; }
@@ -1658,11 +1703,11 @@ public:
   : statement (b, loc),
     m_rvalue (rvalue) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   rvalue *m_rvalue;
@@ -1679,11 +1724,11 @@ public:
     m_lvalue (lvalue),
     m_rvalue (rvalue) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   lvalue *m_lvalue;
@@ -1703,11 +1748,11 @@ public:
     m_op (op),
     m_rvalue (rvalue) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   lvalue *m_lvalue;
@@ -1724,11 +1769,11 @@ public:
   : statement (b, loc),
     m_text (text) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   string *m_text;
@@ -1747,13 +1792,13 @@ public:
     m_on_true (on_true),
     m_on_false (on_false) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  vec <block *> get_successor_blocks () const;
+  vec <block *> get_successor_blocks () const FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   rvalue *m_boolval;
@@ -1770,13 +1815,13 @@ public:
   : statement (b, loc),
     m_target (target) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  vec <block *> get_successor_blocks () const;
+  vec <block *> get_successor_blocks () const FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   block *m_target;
@@ -1791,13 +1836,13 @@ public:
   : statement (b, loc),
     m_rvalue (rvalue) {}
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  vec <block *> get_successor_blocks () const;
+  vec <block *> get_successor_blocks () const FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   rvalue *m_rvalue;
@@ -1820,12 +1865,12 @@ class case_ : public memento
   rvalue *get_max_value () const { return m_max_value; }
   block *get_dest_block () const { return m_dest_block; }
 
-  void replay_into (replayer *) { /* empty */ }
+  void replay_into (replayer *) FINAL OVERRIDE { /* empty */ }
 
-  void write_reproducer (reproducer &r);
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
+  string * make_debug_string () FINAL OVERRIDE;
 
  private:
   rvalue *m_min_value;
@@ -1843,13 +1888,13 @@ public:
 	   int num_cases,
 	   case_ **cases);
 
-  void replay_into (replayer *r);
+  void replay_into (replayer *r) FINAL OVERRIDE;
 
-  vec <block *> get_successor_blocks () const;
+  vec <block *> get_successor_blocks () const FINAL OVERRIDE;
 
 private:
-  string * make_debug_string ();
-  void write_reproducer (reproducer &r);
+  string * make_debug_string () FINAL OVERRIDE;
+  void write_reproducer (reproducer &r) FINAL OVERRIDE;
 
 private:
   rvalue *m_expr;
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
@ 2016-01-01  0:00 David Malcolm
  2016-01-01  0:00 ` Pedro Alves
                   ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches, jit; +Cc: David Malcolm

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.

We use virtual functions in a few places (e.g. in the jit), so it would
be good to get this extra checking.

This patch adds OVERRIDE and FINAL as macros to coretypes.h
allowing us to get this extra checking when compiling with a compiler
that implements C++11 or later (e.g. gcc 6 by default),
but without requiring C++11.

Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.

OK for trunk?

Does "final" imply "override"?  Is "final override" a tautology?

gcc/ChangeLog:
	* coretypes.h (OVERRIDE): New macro.
	(FINAL): New macro.
---
 gcc/coretypes.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/gcc/coretypes.h b/gcc/coretypes.h
index 2932d73..b3a91a6 100644
--- a/gcc/coretypes.h
+++ b/gcc/coretypes.h
@@ -361,6 +361,31 @@ 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"
-- 
1.8.5.3

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h
  2016-01-01  0:00 ` Pedro Alves
  2016-01-01  0:00   ` Jason Merrill
@ 2016-01-01  0:00   ` Pedro Alves
  2016-01-01  0:00     ` Trevor Saunders
  1 sibling, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves, David Malcolm, gcc-patches, jit

On 05/06/2016 06:56 PM, Pedro Alves wrote:

> If building gcc as a C++11 program is supported, then it
> won't be possible to use these names as symbols for
> anything else anyway?

Just found out the above is not true.  Apparently I've
been stuck in C++98 for too long...  Sorry about the noise.

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.

I like your names without the GCC_ prefix better though,
for the same reason of standardizing binutils-gdb + gcc
on the same symbols.


-- 
Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [PATCH 2/2] jit: use FINAL and OVERRIDE throughout
  2016-01-01  0:00 ` [PATCH 2/2] jit: use FINAL and OVERRIDE throughout David Malcolm
@ 2016-01-01  0:00   ` David Malcolm
  0 siblings, 0 replies; 21+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: gcc-patches, jit

On Fri, 2016-05-06 at 12:40 -0400, David Malcolm wrote:
> Mark most virtual functions in gcc/jit as being FINAL OVERRIDE.
> gcc::jit::recording::lvalue::access_as_rvalue is the sole OVERRIDE
> that isn't a FINAL.
> 
> Successfully bootstrapped&regrtested on x86_64-pc-linux-gnu.
> 
> I can self-approve this, but as asked in patch 1,
> does "final" imply "override"?  Is "final override" a tautology?

http://stackoverflow.com/questions/29412412/does-final-imply-override s
ays that "final override" is *not* tautologous.

I've committed this jit patch to trunk as r236223.

Dave

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: CONSTEXPR macro (was "Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h")
  2016-01-01  0:00   ` CONSTEXPR macro (was "Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h") David Malcolm
@ 2016-01-01  0:00     ` Jakub Jelinek
  0 siblings, 0 replies; 21+ messages in thread
From: Jakub Jelinek @ 2016-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm; +Cc: gcc-patches, jit

On Fri, May 06, 2016 at 12:32:47PM -0400, David Malcolm wrote:
> Perhaps, but CONSTEXPR seems to be more awkward than OVERRIDE and
> FINAL.  The meanings of "final" and "override" are consistent between
> C++11 and C++14, but C++14 allows more things to be marked as
> "constexpr" than C++11.  Hence having a single "CONSTEXPR" macro might
> not be sufficient.  Perhaps there'd be CONSTEXPR_11 and CONSTEXPR_14
> macros for things that are constexpr in C++11 onwards and constexpr in
> C++14 onwards, respectively? (seems ugly to me).

Yeah, or CONSTEXPR and CONSTEXPR14 could work, sure.

> Are the OVERRIDE and FINAL macros OK for trunk?

Yes.

	Jakub

^ permalink raw reply	[flat|nested] 21+ messages in thread

* [wwwdocs, coding conventions] Mention OVERRIDE/FINAL
  2016-01-01  0:00               ` Pedro Alves
@ 2016-01-01  0:00                 ` David Malcolm
  2016-01-01  0:00                   ` Pedro Alves
                                     ` (2 more replies)
  0 siblings, 3 replies; 21+ messages in thread
From: David Malcolm @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves, Bernd Schmidt, Trevor Saunders
  Cc: gcc-patches, jit, Gerald Pfeifer

[-- Attachment #1: Type: text/plain, Size: 801 bytes --]

On Fri, 2016-10-14 at 16:27 +0100, Pedro Alves wrote:
> On 10/12/2016 03:13 PM, Bernd Schmidt wrote:
> > On 10/12/2016 04:09 PM, Pedro Alves wrote:
> > > 
> > > Thanks.  Here's a follow up patch that I was just testing.
> > > 
> > > Need this if building with "g++ -std=gnu++11", with gcc < 4.7.
> > 
> > Lovely. That's ok too if the other one goes in.
> 
> FYI, I pushed these in now.  I also bootstrapped with the
> jit included in the selected languages, and hacked the
> jit code a bit to trigger the problems OVERRIDE intends to
> catch, just to make sure it still works.
> 
> Thanks,
> Pedro Alves

I propose that we update our coding conventions to mention the OVERRIDE
and FINAL macros in the paragraph that discusses virtual funcs.

The attached patch (to the website) does so.

OK to commit?

[-- Attachment #2: www-use-OVERRIDE-and-FINAL.patch --]
[-- Type: text/x-patch, Size: 814 bytes --]

Index: htdocs/codingconventions.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.77
diff -u -p -r1.77 codingconventions.html
--- htdocs/codingconventions.html	18 Sep 2016 13:55:17 -0000	1.77
+++ htdocs/codingconventions.html	14 Oct 2016 21:22:44 -0000
@@ -902,7 +902,10 @@ Its use with data-carrying classes is mo
 <p>
 Think carefully about the size and performance impact
 of virtual functions and virtual bases
-before using them.
+before using them.  If you do use virtual functions, use the
+<code>OVERRIDE</code> and <code>FINAL</code> macros from
+<code>include/ansidecl.h</code> to annotate the code for a human reader,
+and to allow sufficiently modern C++ compilers to detect mistakes.
 </p>
 
 <p>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h)
  2016-01-01  0:00     ` Trevor Saunders
@ 2016-01-01  0:00       ` Pedro Alves
  2016-01-01  0:00         ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h Bernd Schmidt
  2016-01-01  0:00       ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Pedro Alves
  1 sibling, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

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 <palves@redhat.com>
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  <palves@redhat.com>

	* coretypes.h (OVERRIDE, FINAL): Delete, moved to
	include/ansidecl.h.

include/ChangeLog:
yyyy-mm-dd  Pedro Alves  <palves@redhat.com>

	* 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

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h
  2016-01-01  0:00           ` Pedro Alves
@ 2016-01-01  0:00             ` Bernd Schmidt
  2016-01-01  0:00               ` Pedro Alves
  0 siblings, 1 reply; 21+ messages in thread
From: Bernd Schmidt @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves, Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

On 10/12/2016 04:09 PM, Pedro Alves wrote:
>
> Thanks.  Here's a follow up patch that I was just testing.
>
> Need this if building with "g++ -std=gnu++11", with gcc < 4.7.

Lovely. That's ok too if the other one goes in.


Bernd

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h
  2016-01-01  0:00             ` Bernd Schmidt
@ 2016-01-01  0:00               ` Pedro Alves
  2016-01-01  0:00                 ` [wwwdocs, coding conventions] Mention OVERRIDE/FINAL David Malcolm
  0 siblings, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Bernd Schmidt, Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

On 10/12/2016 03:13 PM, Bernd Schmidt wrote:
> On 10/12/2016 04:09 PM, Pedro Alves wrote:
>>
>> Thanks.  Here's a follow up patch that I was just testing.
>>
>> Need this if building with "g++ -std=gnu++11", with gcc < 4.7.
> 
> Lovely. That's ok too if the other one goes in.

FYI, I pushed these in now.  I also bootstrapped with the
jit included in the selected languages, and hacked the
jit code a bit to trigger the problems OVERRIDE intends to
catch, just to make sure it still works.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h
  2016-01-01  0:00       ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h) Pedro Alves
@ 2016-01-01  0:00         ` Bernd Schmidt
  2016-01-01  0:00           ` Pedro Alves
  0 siblings, 1 reply; 21+ messages in thread
From: Bernd Schmidt @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Pedro Alves, Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

On 10/10/2016 09:32 PM, Pedro Alves wrote:
> From: Pedro Alves <palves@redhat.com>
> 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.

Seems reasonable. OK unless someone objects by the end of the week.


Bernd


^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h
  2016-01-01  0:00         ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h Bernd Schmidt
@ 2016-01-01  0:00           ` Pedro Alves
  2016-01-01  0:00             ` Bernd Schmidt
  0 siblings, 1 reply; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: Bernd Schmidt, Trevor Saunders; +Cc: David Malcolm, gcc-patches, jit

On 10/12/2016 03:01 PM, Bernd Schmidt wrote:
> On 10/10/2016 09:32 PM, Pedro Alves wrote:
>> From: Pedro Alves <palves@redhat.com>
>> 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.
> 
> Seems reasonable. OK unless someone objects by the end of the week.

Thanks.  Here's a follow up patch that I was just testing.

Need this if building with "g++ -std=gnu++11", with gcc < 4.7.

From: Pedro Alves <palves@redhat.com>
Date: 2016-10-12 01:49:53 +0100

FINAL/OVERRIDE: Define to empty on g++ < 4.7

final/override were only implemented in 4.7.

include/ChangeLog
2016-10-12  Pedro Alves  <palves@redhat.com>

	* ansidecl.h [__cplusplus >= 201103 && GCC_VERSION > 4007] (FINAL,
	OVERRIDE): Define as empty.
	[__cplusplus < 201103 && GCC_VERSION > 4007] (FINAL): Define as
	__final.
	[__cplusplus < 201103 && GCC_VERSION > 4007] (OVERRIDE): Define as
	empty.
---

 include/ansidecl.h |   20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/include/ansidecl.h b/include/ansidecl.h
index ee93421..08aeb1e 100644
--- a/include/ansidecl.h
+++ b/include/ansidecl.h
@@ -329,13 +329,23 @@ So instead we use the macro below and test it against specific values.  */
    this by default (actually GNU++14).  */
 
 #if __cplusplus >= 201103
-/* C++11 claims to be available: use it: */
-#define OVERRIDE override
-#define FINAL final
+/* 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
+# define OVERRIDE
+# define FINAL
 #endif
 
 #ifdef __cplusplus

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [wwwdocs, coding conventions] Mention OVERRIDE/FINAL
  2016-01-01  0:00                 ` [wwwdocs, coding conventions] Mention OVERRIDE/FINAL David Malcolm
@ 2016-01-01  0:00                   ` Pedro Alves
  2017-01-01  0:00                   ` Gerald Pfeifer
  2017-01-01  0:00                   ` Gerald Pfeifer
  2 siblings, 0 replies; 21+ messages in thread
From: Pedro Alves @ 2016-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm, Bernd Schmidt, Trevor Saunders
  Cc: gcc-patches, jit, Gerald Pfeifer

On 10/14/2016 10:28 PM, David Malcolm wrote:

> I propose that we update our coding conventions to mention the OVERRIDE
> and FINAL macros in the paragraph that discusses virtual funcs.
> 
> The attached patch (to the website) does so.
> 

Good idea, I like it.

GDB is following GCC's C++ coding conventions, BTW:

  https://sourceware.org/gdb/wiki/Internals%20GDB-C-Coding-Standards#C.2B-.2B--specific_coding_conventions

At least for starters.  :-)  Let's see how that goes.

Thanks,
Pedro Alves

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [wwwdocs, coding conventions] Mention OVERRIDE/FINAL
  2016-01-01  0:00                 ` [wwwdocs, coding conventions] Mention OVERRIDE/FINAL David Malcolm
  2016-01-01  0:00                   ` Pedro Alves
@ 2017-01-01  0:00                   ` Gerald Pfeifer
  2017-01-01  0:00                     ` Trevor Saunders
  2017-01-01  0:00                   ` Gerald Pfeifer
  2 siblings, 1 reply; 21+ messages in thread
From: Gerald Pfeifer @ 2017-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm, Bernd Schmidt, Jeff Law
  Cc: Pedro Alves, Trevor Saunders, gcc-patches, jit

[-- Attachment #1: Type: text/plain, Size: 765 bytes --]

On Fri, 14 Oct 2016, David Malcolm wrote:
> On Fri, 2016-10-14 at 16:27 +0100, Pedro Alves wrote:
>> FYI, I pushed these in now.  I also bootstrapped with the
>> jit included in the selected languages, and hacked the
>> jit code a bit to trigger the problems OVERRIDE intends to
>> catch, just to make sure it still works.
> I propose that we update our coding conventions to mention the OVERRIDE
> and FINAL macros in the paragraph that discusses virtual funcs.
> 
> The attached patch (to the website) does so.
> 
> OK to commit?

I noticed this one has neither been rejected nor applied.

The patch appears fine wearing my wwwdocs maintainer hat, alas I
do not feel confident approving it (content-wise).

Perhaps something for Jeff (now added) or Bernd?

Gerald

[-- Attachment #2: Type: text/x-patch, Size: 814 bytes --]

Index: htdocs/codingconventions.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.77
diff -u -p -r1.77 codingconventions.html
--- htdocs/codingconventions.html	18 Sep 2016 13:55:17 -0000	1.77
+++ htdocs/codingconventions.html	14 Oct 2016 21:22:44 -0000
@@ -902,7 +902,10 @@ Its use with data-carrying classes is mo
 <p>
 Think carefully about the size and performance impact
 of virtual functions and virtual bases
-before using them.
+before using them.  If you do use virtual functions, use the
+<code>OVERRIDE</code> and <code>FINAL</code> macros from
+<code>include/ansidecl.h</code> to annotate the code for a human reader,
+and to allow sufficiently modern C++ compilers to detect mistakes.
 </p>
 
 <p>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [wwwdocs, coding conventions] Mention OVERRIDE/FINAL
  2016-01-01  0:00                 ` [wwwdocs, coding conventions] Mention OVERRIDE/FINAL David Malcolm
  2016-01-01  0:00                   ` Pedro Alves
  2017-01-01  0:00                   ` Gerald Pfeifer
@ 2017-01-01  0:00                   ` Gerald Pfeifer
  2 siblings, 0 replies; 21+ messages in thread
From: Gerald Pfeifer @ 2017-01-01  0:00 UTC (permalink / raw)
  To: David Malcolm
  Cc: Pedro Alves, Bernd Schmidt, Trevor Saunders, gcc-patches, jit

[-- Attachment #1: Type: text/plain, Size: 560 bytes --]

Hi David,

On Fri, 14 Oct 2016, David Malcolm wrote:
> I propose that we update our coding conventions to mention the OVERRIDE
> and FINAL macros in the paragraph that discusses virtual funcs.
> 
> The attached patch (to the website) does so.
> 
> OK to commit?

I saw that Pedro agreed, but none of our global reviewers (such as
Bernd) chimed in.

So, while this looks fine from a pure wwwdocs perspective, I did
not feel comfortable approving it without larger concensus.  If
you want to push this, perhaps send a note/request to gcc@ proposing
this?

Gerald

[-- Attachment #2: Type: text/x-patch, Size: 814 bytes --]

Index: htdocs/codingconventions.html
===================================================================
RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
retrieving revision 1.77
diff -u -p -r1.77 codingconventions.html
--- htdocs/codingconventions.html	18 Sep 2016 13:55:17 -0000	1.77
+++ htdocs/codingconventions.html	14 Oct 2016 21:22:44 -0000
@@ -902,7 +902,10 @@ Its use with data-carrying classes is mo
 <p>
 Think carefully about the size and performance impact
 of virtual functions and virtual bases
-before using them.
+before using them.  If you do use virtual functions, use the
+<code>OVERRIDE</code> and <code>FINAL</code> macros from
+<code>include/ansidecl.h</code> to annotate the code for a human reader,
+and to allow sufficiently modern C++ compilers to detect mistakes.
 </p>
 
 <p>

^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: [wwwdocs, coding conventions] Mention OVERRIDE/FINAL
  2017-01-01  0:00                   ` Gerald Pfeifer
@ 2017-01-01  0:00                     ` Trevor Saunders
  0 siblings, 0 replies; 21+ messages in thread
From: Trevor Saunders @ 2017-01-01  0:00 UTC (permalink / raw)
  To: Gerald Pfeifer
  Cc: David Malcolm, Bernd Schmidt, Jeff Law, Pedro Alves, gcc-patches, jit

On Fri, Feb 03, 2017 at 09:34:52AM +0100, Gerald Pfeifer wrote:
> On Fri, 14 Oct 2016, David Malcolm wrote:
> > On Fri, 2016-10-14 at 16:27 +0100, Pedro Alves wrote:
> >> FYI, I pushed these in now.  I also bootstrapped with the
> >> jit included in the selected languages, and hacked the
> >> jit code a bit to trigger the problems OVERRIDE intends to
> >> catch, just to make sure it still works.
> > I propose that we update our coding conventions to mention the OVERRIDE
> > and FINAL macros in the paragraph that discusses virtual funcs.
> > 
> > The attached patch (to the website) does so.
> > 
> > OK to commit?
> 
> I noticed this one has neither been rejected nor applied.
> 
> The patch appears fine wearing my wwwdocs maintainer hat, alas I
> do not feel confident approving it (content-wise).

fwiw I can't think of any big downsides, I guess there's slightly more
work ocassionally when you add a new class that inherits from an old one
and slightly more verbosity, but it definitely seems worth it to me.

Trev

> 
> Perhaps something for Jeff (now added) or Bernd?
> 
> Gerald

> Index: htdocs/codingconventions.html
> ===================================================================
> RCS file: /cvs/gcc/wwwdocs/htdocs/codingconventions.html,v
> retrieving revision 1.77
> diff -u -p -r1.77 codingconventions.html
> --- htdocs/codingconventions.html	18 Sep 2016 13:55:17 -0000	1.77
> +++ htdocs/codingconventions.html	14 Oct 2016 21:22:44 -0000
> @@ -902,7 +902,10 @@ Its use with data-carrying classes is mo
>  <p>
>  Think carefully about the size and performance impact
>  of virtual functions and virtual bases
> -before using them.
> +before using them.  If you do use virtual functions, use the
> +<code>OVERRIDE</code> and <code>FINAL</code> macros from
> +<code>include/ansidecl.h</code> to annotate the code for a human reader,
> +and to allow sufficiently modern C++ compilers to detect mistakes.
>  </p>
>  
>  <p>

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2017-02-04  0:55 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-01  0:00 [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h David Malcolm
2016-01-01  0:00 ` Pedro Alves
2016-01-01  0:00   ` Jason Merrill
2016-01-01  0:00   ` Pedro Alves
2016-01-01  0:00     ` Trevor Saunders
2016-01-01  0:00       ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h (was: Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h) Pedro Alves
2016-01-01  0:00         ` Move OVERRIDE/FINAL from gcc/coretypes.h to include/ansidecl.h Bernd Schmidt
2016-01-01  0:00           ` Pedro Alves
2016-01-01  0:00             ` Bernd Schmidt
2016-01-01  0:00               ` Pedro Alves
2016-01-01  0:00                 ` [wwwdocs, coding conventions] Mention OVERRIDE/FINAL David Malcolm
2016-01-01  0:00                   ` Pedro Alves
2017-01-01  0:00                   ` Gerald Pfeifer
2017-01-01  0:00                     ` Trevor Saunders
2017-01-01  0:00                   ` Gerald Pfeifer
2016-01-01  0:00       ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Pedro Alves
2016-01-01  0:00 ` [PATCH 2/2] jit: use FINAL and OVERRIDE throughout David Malcolm
2016-01-01  0:00   ` David Malcolm
2016-01-01  0:00 ` [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h Jakub Jelinek
2016-01-01  0:00   ` CONSTEXPR macro (was "Re: [PATCH 1/2] Add OVERRIDE and FINAL macros to coretypes.h") David Malcolm
2016-01-01  0:00     ` Jakub Jelinek

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).