diff options
author | Ville Voutilainen <ville.voutilainen@gmail.com> | 2011-05-14 21:13:23 +0300 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2011-05-14 14:13:23 -0400 |
commit | 486d481b392fae54d39413f3d1fc6851383fce47 (patch) | |
tree | 6e71c4f8224656772ee33335e93d1fb8eb7d983e /gcc/cp/class.c | |
parent | ade2e40389bd3c76031c486991005ffffa1493bf (diff) | |
download | gcc-486d481b392fae54d39413f3d1fc6851383fce47.zip gcc-486d481b392fae54d39413f3d1fc6851383fce47.tar.gz gcc-486d481b392fae54d39413f3d1fc6851383fce47.tar.bz2 |
Implement final on class.
* class.c (check_bases): Diagnose derivation from a final class.
* cp-tree.h (lang_type_class): Add is_final and adjust dummy.
(CLASSTYPE_FINAL): New.
* parser.c (cp_parser_class_head): Parse class-virt-specifier, set
CLASSTYPE_FINAL.
* pt.c (instantiate_class_template_1): Copy CLASSTYPE_FINAL.
From-SVN: r173761
Diffstat (limited to 'gcc/cp/class.c')
-rw-r--r-- | gcc/cp/class.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 938d522..dc2c509 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1268,6 +1268,10 @@ check_bases (tree t, gcc_assert (COMPLETE_TYPE_P (basetype)); + if (CLASSTYPE_FINAL (basetype)) + error ("cannot derive from %<final%> base %qT in derived type %qT", + basetype, t); + /* If any base class is non-literal, so is the derived class. */ if (!CLASSTYPE_LITERAL_P (basetype)) CLASSTYPE_LITERAL_P (t) = false; |