diff options
author | Jason Merrill <jason@redhat.com> | 2008-07-24 15:15:00 -0400 |
---|---|---|
committer | Jason Merrill <jason@gcc.gnu.org> | 2008-07-24 15:15:00 -0400 |
commit | b87d79e640b3e9ab1e126bb6d87472b2a261a640 (patch) | |
tree | 38c6149cb50c1486bcdf000c5463ee69d1c647a7 /gcc/cp/search.c | |
parent | c3005b0f0c8081ccb719740c3c27ee13d5697add (diff) | |
download | gcc-b87d79e640b3e9ab1e126bb6d87472b2a261a640.tar.gz |
Implement defaulted/deleted functions as per N2346
Implement defaulted/deleted functions as per N2346
* cp-tree.h (struct lang_decl_flags): Add defaulted_p bitfield.
(DECL_DELETED_FN): New macro.
(DECL_DEFAULTED_FN): New macro.
* class.c (user_provided_p): New fn.
(defaultable_fn_p): New fn.
(type_has_user_provided_constructor): New fn.
(type_has_user_provided_default_constructor): New fn.
(check_methods): A defaulted fn is still trivial.
(check_bases_and_members): Likewise.
* decl.c (grok_special_member_properties): Likewise.
(duplicate_decls): Complain about redeclaring a function as deleted.
(start_decl): initialized==2 means deleted.
(cp_finish_decl): Handle deleted/defaulted semantics.
* decl2.c (grokfield): Likewise.
(mark_used): Check DECL_DEFAULTED_FN instead of DECL_ARTIFICIAL.
Complain about using a deleted fn.
* init.c (build_value_init_1): Use type_has_user_provided_constructor.
(perform_member_init): Check for a user-provided default constructor
even if TYPE_NEEDS_CONSTRUCTING.
(build_new_1): Likewise.
* call.c (build_over_call): Don't call mark_used twice.
* method.c (implicitly_declare_fn): Set DECL_DEFAULTED_FN.
* search.c (check_final_overrider): Check for deleted mismatch.
* parser.c (cp_parser_init_declarator): Tell start_decl about =delete.
(cp_parser_pure_specifier): Handle =default and =delete.
* error.c (maybe_warn_cpp0x): Suggest -std=gnu++0x as well.
From-SVN: r138123
Diffstat (limited to 'gcc/cp/search.c')
-rw-r--r-- | gcc/cp/search.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/gcc/cp/search.c b/gcc/cp/search.c index cee29240e9e..7fc040bc8c4 100644 --- a/gcc/cp/search.c +++ b/gcc/cp/search.c @@ -1912,6 +1912,20 @@ check_final_overrider (tree overrider, tree basefn) return 0; } + if (DECL_DELETED_FN (basefn) != DECL_DELETED_FN (overrider)) + { + if (DECL_DELETED_FN (overrider)) + { + error ("deleted function %q+D", overrider); + error ("overriding non-deleted function %q+D", basefn); + } + else + { + error ("non-deleted function %q+D", overrider); + error ("overriding deleted function %q+D", basefn); + } + return 0; + } return 1; } |