This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PATCH: Implement __attribute__((final)) for C++, restricting subtyping and overriding


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]