Implement defaulted/deleted functions as per N2346
authorJason Merrill <jason@redhat.com>
Thu, 24 Jul 2008 19:15:00 +0000 (15:15 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Thu, 24 Jul 2008 19:15:00 +0000 (15:15 -0400)
commitb87d79e640b3e9ab1e126bb6d87472b2a261a640
tree38c6149cb50c1486bcdf000c5463ee69d1c647a7
parentc3005b0f0c8081ccb719740c3c27ee13d5697add
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
19 files changed:
gcc/cp/ChangeLog
gcc/cp/call.c
gcc/cp/class.c
gcc/cp/cp-tree.h
gcc/cp/decl.c
gcc/cp/decl2.c
gcc/cp/error.c
gcc/cp/init.c
gcc/cp/mangle.c
gcc/cp/method.c
gcc/cp/parser.c
gcc/cp/search.c
gcc/testsuite/g++.dg/cpp0x/defaulted1.C [new file with mode: 0644]
gcc/testsuite/g++.dg/cpp0x/defaulted2.C [new file with mode: 0644]
gcc/testsuite/g++.dg/parse/crash27.C
gcc/testsuite/g++.dg/parse/error15.C
gcc/testsuite/g++.dg/template/crash60.C
gcc/testsuite/g++.dg/template/crash7.C
gcc/testsuite/g++.old-deja/g++.pt/error2.C