From: Ville Voutilainen Date: Tue, 3 Feb 2015 02:49:42 +0000 (+0200) Subject: re PR c++/64901 (overriding final function defined out of line does not lead to an... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=879887f1d250f677eb22d9aec6714ce131fd995b;p=gcc.git re PR c++/64901 (overriding final function defined out of line does not lead to an error) PR c++/64901 * decl.c (duplicate_decls): Also duplicate DECL_FINAL_P and DECL_OVERRIDE_P. From-SVN: r220363 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 2e5e2a53d18..7c200d629a2 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,9 @@ +2015-02-02 Ville Voutilainen + + PR c++/64901 + * decl.c (duplicate_decls): Also duplicate DECL_FINAL_P and + DECL_OVERRIDE_P. + 2015-02-02 Jason Merrill * tree.c (handle_abi_tag_attribute): Diagnose invalid arguments. diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index 5119964dea9..d2b0814543d 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1813,6 +1813,8 @@ duplicate_decls (tree newdecl, tree olddecl, bool newdecl_is_friend) DECL_PURE_VIRTUAL_P (newdecl) |= DECL_PURE_VIRTUAL_P (olddecl); DECL_VIRTUAL_P (newdecl) |= DECL_VIRTUAL_P (olddecl); DECL_INVALID_OVERRIDER_P (newdecl) |= DECL_INVALID_OVERRIDER_P (olddecl); + DECL_FINAL_P (newdecl) |= DECL_FINAL_P (olddecl); + DECL_OVERRIDE_P (newdecl) |= DECL_OVERRIDE_P (olddecl); DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl); if (DECL_OVERLOADED_OPERATOR_P (olddecl) != ERROR_MARK) SET_OVERLOADED_OPERATOR_CODE diff --git a/gcc/testsuite/g++.dg/cpp0x/override1.C b/gcc/testsuite/g++.dg/cpp0x/override1.C index 05d729084da..7686a286fc6 100644 --- a/gcc/testsuite/g++.dg/cpp0x/override1.C +++ b/gcc/testsuite/g++.dg/cpp0x/override1.C @@ -4,8 +4,11 @@ struct B virtual void f() final {} virtual void g() {} virtual void x() const {} + virtual void y() final; }; +void B::y() {} // { dg-error "overriding" } + struct B2 { virtual void h() {} @@ -14,6 +17,7 @@ struct B2 struct D : B { virtual void g() override final {} // { dg-error "overriding" } + virtual void y() override final {} // { dg-error "virtual" } }; template struct D2 : T