This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Implement __attribute__((final)) for C++, restricting subtyping and overriding
- From: "Doug Gregor" <doug dot gregor at gmail dot com>
- To: "Jeffrey Yasskin" <jyasskin at gmail dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Fri, 10 Oct 2008 16:04:17 -0400
- Subject: Re: PATCH: Implement __attribute__((final)) for C++, restricting subtyping and overriding
- References: <5d44f72f0810101053x1709a505w5f45143400aec338@mail.gmail.com>
On Fri, Oct 10, 2008 at 1:53 PM, Jeffrey Yasskin <jyasskin@gmail.com> wrote:
> Hi all.
>
> I've implemented __attribute__ ((final)) for C++ classes and virtual
> member functions. It behaves very similarly to Java's final keyword:
> when applied to a class, it prevents anyone from subtyping that class;
> and when applied to a virtual member function, it prevents any
> subtypes from overriding that function. The patch shouldn't affect any
> code that doesn't use the attribute. In theory, knowing that a method
> is the final override could allow g++ to, in some cases, emit static
> calls instead of virtual calls, but I haven't implemented that here.
Does this implement exactly the behavior required for the "final"
attribute that just went into C++0x?
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf
- Doug