From 39e70cbf1779519844a6a7246ba9719d80516610 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 4 Jul 2009 00:43:26 +0000 Subject: * cp-tree.h (struct lang_decl): Overhaul. (struct lang_decl_flags): Remove. (struct lang_decl_base): New. (struct lang_decl_min): New. (struct lang_decl_fn): New. (struct lang_decl_ns): New. (CAN_HAVE_FULL_LANG_DECL_P): Replace with LANG_DECL_HAS_MIN. (LANG_DECL_MIN_CHECK): New. (LANG_DECL_FN_CHECK): New. (LANG_DECL_NS_CHECK): New. (STRIP_TEMPLATE): New. (NON_THUNK_FUNCTION_CHECK): Remove. (DECL_DECLARES_FUNCTION_P): New. (lots): Adjust. * lex.c (retrofit_lang_decl, cxx_dup_lang_specific_decl): Adjust. * decl.c (push_local_name, duplicate_decls): Adjust. * decl2.c (start_objects): Don't set u2sel. * semantics.c (finish_omp_threadprivate): Adjust. * class.c (build_clone): Don't do much on TEMPLATE_DECLs. (decl_cloned_function_p): Out-of-line implementation of macros. (clone_function_decl, adjust_clone_args): Use DECL_CLONED_FUNCTION_P. * mangle.c (write_unqualified_name): Don't check function flags on non-functions. * method.c (make_alias_for): Don't set DECL_CLONED_FUNCTION. * pt.c (build_template_decl): Don't set function flags. (check_default_tmpl_args): Check that it's a function. (instantiate_template): Use DECL_ABSTRACT_ORIGIN to find the cloned template. * pt.c (tsubst_decl) [FUNCTION_DECL]: Don't tsubst DECL_CLONED_FUNCTION. * cp-tree.h (struct lang_type_class): Move sorted_fields here. * class.c (finish_struct_1): Adjust. * ptree.c (cxx_print_decl, cxx_print_type): Adjust. * search.c (lookup_field_1): Adjust. * cp-tree.h (CLASSTYPE_INLINE_FRIENDS): Remove. * decl.c (finish_method): Don't add to it. * class.c (fixup_pending_inline): Remove. (fixup_inline_methods): Remove. (finish_struct_1): Don't call it. * error.c (dump_function_name): Handle null name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149217 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 177 +++++++++++++++++++++++++-------------------------------- 1 file changed, 78 insertions(+), 99 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 12192e61393..4668c68d008 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -151,8 +151,6 @@ static void check_bases_and_members (tree); static tree create_vtable_ptr (tree, tree *); static void include_empty_classes (record_layout_info); static void layout_class_type (tree, tree *); -static void fixup_pending_inline (tree); -static void fixup_inline_methods (tree); static void propagate_binfo_offsets (tree, tree); static void layout_virtual_bases (record_layout_info, splay_tree); static void build_vbase_offset_vtbl_entries (tree, vtbl_init_data *); @@ -3799,12 +3797,27 @@ build_clone (tree fn, tree name) /* Copy the function. */ clone = copy_decl (fn); - /* Remember where this function came from. */ - DECL_CLONED_FUNCTION (clone) = fn; - DECL_ABSTRACT_ORIGIN (clone) = fn; /* Reset the function name. */ DECL_NAME (clone) = name; SET_DECL_ASSEMBLER_NAME (clone, NULL_TREE); + /* Remember where this function came from. */ + DECL_ABSTRACT_ORIGIN (clone) = fn; + /* Make it easy to find the CLONE given the FN. */ + TREE_CHAIN (clone) = TREE_CHAIN (fn); + TREE_CHAIN (fn) = clone; + + /* If this is a template, do the rest on the DECL_TEMPLATE_RESULT. */ + if (TREE_CODE (clone) == TEMPLATE_DECL) + { + tree result = build_clone (DECL_TEMPLATE_RESULT (clone), name); + DECL_TEMPLATE_RESULT (clone) = result; + DECL_TEMPLATE_INFO (result) = copy_node (DECL_TEMPLATE_INFO (result)); + DECL_TI_TEMPLATE (result) = clone; + TREE_TYPE (clone) = TREE_TYPE (result); + return clone; + } + + DECL_CLONED_FUNCTION (clone) = fn; /* There's no pending inline data for this function. */ DECL_PENDING_INLINE_INFO (clone) = NULL; DECL_PENDING_INLINE_P (clone) = 0; @@ -3852,61 +3865,79 @@ build_clone (tree fn, tree name) TYPE_ATTRIBUTES (TREE_TYPE (fn))); } - /* Copy the function parameters. But, DECL_ARGUMENTS on a TEMPLATE_DECL - aren't function parameters; those are the template parameters. */ - if (TREE_CODE (clone) != TEMPLATE_DECL) + /* Copy the function parameters. */ + DECL_ARGUMENTS (clone) = copy_list (DECL_ARGUMENTS (clone)); + /* Remove the in-charge parameter. */ + if (DECL_HAS_IN_CHARGE_PARM_P (clone)) + { + TREE_CHAIN (DECL_ARGUMENTS (clone)) + = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone))); + DECL_HAS_IN_CHARGE_PARM_P (clone) = 0; + } + /* And the VTT parm, in a complete [cd]tor. */ + if (DECL_HAS_VTT_PARM_P (fn)) { - DECL_ARGUMENTS (clone) = copy_list (DECL_ARGUMENTS (clone)); - /* Remove the in-charge parameter. */ - if (DECL_HAS_IN_CHARGE_PARM_P (clone)) + if (DECL_NEEDS_VTT_PARM_P (clone)) + DECL_HAS_VTT_PARM_P (clone) = 1; + else { TREE_CHAIN (DECL_ARGUMENTS (clone)) = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone))); - DECL_HAS_IN_CHARGE_PARM_P (clone) = 0; - } - /* And the VTT parm, in a complete [cd]tor. */ - if (DECL_HAS_VTT_PARM_P (fn)) - { - if (DECL_NEEDS_VTT_PARM_P (clone)) - DECL_HAS_VTT_PARM_P (clone) = 1; - else - { - TREE_CHAIN (DECL_ARGUMENTS (clone)) - = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone))); - DECL_HAS_VTT_PARM_P (clone) = 0; - } + DECL_HAS_VTT_PARM_P (clone) = 0; } + } - for (parms = DECL_ARGUMENTS (clone); parms; parms = TREE_CHAIN (parms)) - { - DECL_CONTEXT (parms) = clone; - cxx_dup_lang_specific_decl (parms); - } + for (parms = DECL_ARGUMENTS (clone); parms; parms = TREE_CHAIN (parms)) + { + DECL_CONTEXT (parms) = clone; + cxx_dup_lang_specific_decl (parms); } /* Create the RTL for this function. */ SET_DECL_RTL (clone, NULL_RTX); rest_of_decl_compilation (clone, /*top_level=*/1, at_eof); - /* Make it easy to find the CLONE given the FN. */ - TREE_CHAIN (clone) = TREE_CHAIN (fn); - TREE_CHAIN (fn) = clone; + if (pch_file) + note_decl_for_pch (clone); - /* If this is a template, handle the DECL_TEMPLATE_RESULT as well. */ - if (TREE_CODE (clone) == TEMPLATE_DECL) - { - tree result; + return clone; +} - DECL_TEMPLATE_RESULT (clone) - = build_clone (DECL_TEMPLATE_RESULT (clone), name); - result = DECL_TEMPLATE_RESULT (clone); - DECL_TEMPLATE_INFO (result) = copy_node (DECL_TEMPLATE_INFO (result)); - DECL_TI_TEMPLATE (result) = clone; +/* Implementation of DECL_CLONED_FUNCTION and DECL_CLONED_FUNCTION_P, do + not invoke this function directly. + + For a non-thunk function, returns the address of the slot for storing + the function it is a clone of. Otherwise returns NULL_TREE. + + If JUST_TESTING, looks through TEMPLATE_DECL and returns NULL if + cloned_function is unset. This is to support the separate + DECL_CLONED_FUNCTION and DECL_CLONED_FUNCTION_P modes; using the latter + on a template makes sense, but not the former. */ + +tree * +decl_cloned_function_p (const_tree decl, bool just_testing) +{ + tree *ptr; + if (just_testing) + decl = STRIP_TEMPLATE (decl); + + if (TREE_CODE (decl) != FUNCTION_DECL + || !DECL_LANG_SPECIFIC (decl) + || DECL_LANG_SPECIFIC (decl)->u.fn.thunk_p) + { +#if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) + if (!just_testing) + lang_check_failed (__FILE__, __LINE__, __FUNCTION__); + else +#endif + return NULL; } - else if (pch_file) - note_decl_for_pch (clone); - return clone; + ptr = &DECL_LANG_SPECIFIC (decl)->u.fn.u5.cloned_function; + if (just_testing && *ptr == NULL_TREE) + return NULL; + else + return ptr; } /* Produce declarations for all appropriate clones of FN. If @@ -3920,7 +3951,7 @@ clone_function_decl (tree fn, int update_method_vec_p) /* Avoid inappropriate cloning. */ if (TREE_CHAIN (fn) - && DECL_CLONED_FUNCTION (TREE_CHAIN (fn))) + && DECL_CLONED_FUNCTION_P (TREE_CHAIN (fn))) return; if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)) @@ -3977,7 +4008,7 @@ adjust_clone_args (tree decl) { tree clone; - for (clone = TREE_CHAIN (decl); clone && DECL_CLONED_FUNCTION (clone); + for (clone = TREE_CHAIN (decl); clone && DECL_CLONED_FUNCTION_P (clone); clone = TREE_CHAIN (clone)) { tree orig_clone_parms = TYPE_ARG_TYPES (TREE_TYPE (clone)); @@ -4447,54 +4478,6 @@ create_vtable_ptr (tree t, tree* virtuals_p) return NULL_TREE; } -/* Fixup the inline function given by INFO now that the class is - complete. */ - -static void -fixup_pending_inline (tree fn) -{ - if (DECL_PENDING_INLINE_INFO (fn)) - { - tree args = DECL_ARGUMENTS (fn); - while (args) - { - DECL_CONTEXT (args) = fn; - args = TREE_CHAIN (args); - } - } -} - -/* Fixup the inline methods and friends in TYPE now that TYPE is - complete. */ - -static void -fixup_inline_methods (tree type) -{ - tree method = TYPE_METHODS (type); - VEC(tree,gc) *friends; - unsigned ix; - - if (method && TREE_CODE (method) == TREE_VEC) - { - if (TREE_VEC_ELT (method, 1)) - method = TREE_VEC_ELT (method, 1); - else if (TREE_VEC_ELT (method, 0)) - method = TREE_VEC_ELT (method, 0); - else - method = TREE_VEC_ELT (method, 2); - } - - /* Do inline member functions. */ - for (; method; method = TREE_CHAIN (method)) - fixup_pending_inline (method); - - /* Do friends. */ - for (friends = CLASSTYPE_INLINE_FRIENDS (type), ix = 0; - VEC_iterate (tree, friends, ix, method); ix++) - fixup_pending_inline (method); - CLASSTYPE_INLINE_FRIENDS (type) = NULL; -} - /* Add OFFSET to all base types of BINFO which is a base in the hierarchy dominated by T. @@ -5219,8 +5202,6 @@ finish_struct_1 (tree t) TYPE_SIZE (t) = NULL_TREE; CLASSTYPE_PRIMARY_BINFO (t) = NULL_TREE; - fixup_inline_methods (t); - /* Make assumptions about the class; we'll reset the flags if necessary. */ CLASSTYPE_EMPTY_P (t) = 1; @@ -5332,9 +5313,7 @@ finish_struct_1 (tree t) add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0); qsort (field_vec->elts, n_fields, sizeof (tree), field_decl_cmp); - if (! DECL_LANG_SPECIFIC (TYPE_MAIN_DECL (t))) - retrofit_lang_decl (TYPE_MAIN_DECL (t)); - DECL_SORTED_FIELDS (TYPE_MAIN_DECL (t)) = field_vec; + CLASSTYPE_SORTED_FIELDS (t) = field_vec; } /* Complain if one of the field types requires lower visibility. */ -- cgit v1.2.1 From c1c67b4f5041c4367842002c81ffe912ff97f2d8 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 16 Jul 2009 20:36:10 +0000 Subject: PR libstdc++/37907 Support std::is_standard_layout and std::is_trivial traits, change POD to C++0x version (except for layout). * gcc/c-common.c (c_common_reswords): Add __is_standard_layout and __is_trivial. * gcc/c-common.h (enum rid): Add RID_IS_STD_LAYOUT and RID_IS_TRIVIAL. * gcc/cp/cp-tree.h (enum cp_trait_kind): Add CPTK_IS_STD_LAYOUT, CPTK_IS_TRIVIAL. (struct lang_type_class): Add non_std_layout. (CLASSTYPE_NON_STD_LAYOUT): New. * gcc/cp/class.c (check_bases): Set it. (check_field_decls): Likewise. (check_bases_and_members): Likewise. * gcc/cp/parser.c (cp_parser_primary_expression): Handle RID_IS_STD_LAYOUT, RID_IS_TRIVIAL. (cp_parser_trait_expr): Likewise. * gcc/cp/semantics.c (trait_expr_value): Handle CPTK_IS_STD_LAYOUT, CPTK_IS_TRIVIAL. (finish_trait_expr): Likewise. * gcc/cp/tree.c (scalarish_type_p, trivial_type_p, std_layout_type_p): New. (pod_type_p): Use them. * gcc/cp/typeck.c (build_class_member_access_expr): Check CLASSTYPE_NON_STD_LAYOUT rather than CLASSTYPE_NON_POD_P. * libstdc++-v3/include/std/type_traits: Add is_standard_layout, is_trivial. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149721 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 7 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4668c68d008..373f4578190 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1248,9 +1248,15 @@ check_bases (tree t, int seen_non_virtual_nearly_empty_base_p; tree base_binfo; tree binfo; + tree field = NULL_TREE; seen_non_virtual_nearly_empty_base_p = 0; + if (!CLASSTYPE_NON_STD_LAYOUT (t)) + for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + if (TREE_CODE (field) == FIELD_DECL) + break; + for (binfo = TYPE_BINFO (t), i = 0; BINFO_BASE_ITERATE (binfo, i, base_binfo); i++) { @@ -1305,6 +1311,36 @@ check_bases (tree t, CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_HAS_COMPLEX_DFLT (basetype); + + /* A standard-layout class is a class that: + ... + * has no non-standard-layout base classes, */ + CLASSTYPE_NON_STD_LAYOUT (t) |= CLASSTYPE_NON_STD_LAYOUT (basetype); + if (!CLASSTYPE_NON_STD_LAYOUT (t)) + { + tree basefield; + /* ...has no base classes of the same type as the first non-static + data member... */ + if (field && DECL_CONTEXT (field) == t + && (same_type_ignoring_top_level_qualifiers_p + (TREE_TYPE (field), basetype))) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + else + /* ...either has no non-static data members in the most-derived + class and at most one base class with non-static data + members, or has no base classes with non-static data + members */ + for (basefield = TYPE_FIELDS (basetype); basefield; + basefield = TREE_CHAIN (basefield)) + if (TREE_CODE (basefield) == FIELD_DECL) + { + if (field) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + else + field = basefield; + break; + } + } } } @@ -2870,6 +2906,7 @@ check_field_decls (tree t, tree *access_decls, bool has_pointers; int any_default_members; int cant_pack = 0; + int field_access = -1; /* Assume there are no access declarations. */ *access_decls = NULL_TREE; @@ -2883,6 +2920,7 @@ check_field_decls (tree t, tree *access_decls, { tree x = *field; tree type = TREE_TYPE (x); + int this_field_access; next = &TREE_CHAIN (x); @@ -2957,10 +2995,21 @@ check_field_decls (tree t, tree *access_decls, if (TREE_PRIVATE (x) || TREE_PROTECTED (x)) CLASSTYPE_NON_AGGREGATE (t) = 1; + /* A standard-layout class is a class that: + ... + has the same access control (Clause 11) for all non-static data members, + ... */ + this_field_access = TREE_PROTECTED (x) ? 1 : TREE_PRIVATE (x) ? 2 : 0; + if (field_access == -1) + field_access = this_field_access; + else if (this_field_access != field_access) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; + /* If this is of reference type, check if it needs an init. */ if (TREE_CODE (type) == REFERENCE_TYPE) { - CLASSTYPE_NON_POD_P (t) = 1; + CLASSTYPE_NON_LAYOUT_POD_P (t) = 1; + CLASSTYPE_NON_STD_LAYOUT (t) = 1; if (DECL_INITIAL (x) == NULL_TREE) SET_CLASSTYPE_REF_FIELDS_NEED_INIT (t, 1); @@ -2975,7 +3024,7 @@ check_field_decls (tree t, tree *access_decls, if (TYPE_PACKED (t)) { - if (!pod_type_p (type) && !TYPE_PACKED (type)) + if (!layout_pod_type_p (type) && !TYPE_PACKED (type)) { warning (0, @@ -3024,10 +3073,13 @@ check_field_decls (tree t, tree *access_decls, if (DECL_MUTABLE_P (x) || TYPE_HAS_MUTABLE_P (type)) CLASSTYPE_HAS_MUTABLE (t) = 1; - if (! pod_type_p (type)) + if (! layout_pod_type_p (type)) /* DR 148 now allows pointers to members (which are POD themselves), to be allowed in POD structs. */ - CLASSTYPE_NON_POD_P (t) = 1; + CLASSTYPE_NON_LAYOUT_POD_P (t) = 1; + + if (!std_layout_type_p (type)) + CLASSTYPE_NON_STD_LAYOUT (t) = 1; if (! zero_init_p (type)) CLASSTYPE_NON_ZERO_INIT_P (t) = 1; @@ -4280,7 +4332,7 @@ type_requires_array_cookie (tree type) /* Check the validity of the bases and members declared in T. Add any implicitly-generated functions (like copy-constructors and assignment operators). Compute various flag bits (like - CLASSTYPE_NON_POD_T) for T. This routine works purely at the C++ + CLASSTYPE_NON_LAYOUT_POD_T) for T. This routine works purely at the C++ level: i.e., independently of the ABI in use. */ static void @@ -4346,9 +4398,12 @@ check_bases_and_members (tree t) elsewhere. */ CLASSTYPE_NON_AGGREGATE (t) |= (type_has_user_provided_constructor (t) || TYPE_POLYMORPHIC_P (t)); - CLASSTYPE_NON_POD_P (t) + /* This is the C++98/03 definition of POD; it changed in C++0x, but we + retain the old definition internally for ABI reasons. */ + CLASSTYPE_NON_LAYOUT_POD_P (t) |= (CLASSTYPE_NON_AGGREGATE (t) || saved_nontrivial_dtor || saved_complex_asn_ref); + CLASSTYPE_NON_STD_LAYOUT (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_CONTAINS_VPTR_P (t); @@ -5031,7 +5086,7 @@ layout_class_type (tree t, tree *virtuals_p) /* Create the version of T used for virtual bases. We do not use make_class_type for this version; this is an artificial type. For a POD type, we just reuse T. */ - if (CLASSTYPE_NON_POD_P (t) || CLASSTYPE_EMPTY_P (t)) + if (CLASSTYPE_NON_LAYOUT_POD_P (t) || CLASSTYPE_EMPTY_P (t)) { base_t = make_node (TREE_CODE (t)); -- cgit v1.2.1 From 389dd41bd043170e7dc7660304f14a5f16af3562 Mon Sep 17 00:00:00 2001 From: manu Date: Thu, 16 Jul 2009 22:29:52 +0000 Subject: =?UTF-8?q?2009-07-17=20=20Aldy=20Hernandez=20=20=20=09=20=20=20=20Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez=20=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PR 40435 * tree-complex.c, tree-loop-distribution.c, tree.c, tree.h, builtins.c, fold-const.c, omp-low.c, cgraphunit.c, tree-ssa-ccp.c, tree-ssa-dom.c, gimple-low.c, expr.c, tree-ssa-ifcombine.c, c-decl.c, stor-layout.c, tree-if-conv.c, c-typeck.c, gimplify.c, calls.c, tree-sra.c, tree-mudflap.c, tree-ssa-copy.c, tree-ssa-forwprop.c, c-convert.c, c-omp.c, varasm.c, tree-inline.c, c-common.c, c-common.h, gimple.c, tree-switch-conversion.c, gimple.h, tree-cfg.c, c-parser.c, convert.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. objc/ * objc-act.c: Add location argument to all calls to build_fold_addr_expr. testsuite/ * gcc.dg/pr36902.c: Add column info. * g++.dg/gcov/gcov-2.C: Change count for definition. cp/ * typeck.c, init.c, class.c, method.c, rtti.c, except.c, error.c, tree.c, cp-gimplify.c, cxx-pretty-print.c, pt.c, semantics.c, call.c, cvt.c, mangle.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. fortran/ * trans-expr.c, trans-array.c, trans-openmp.c, trans-stmt.c, trans.c, trans-io.c, trans-decl.c, trans-intrinsic.c: Add location argument to fold_{unary,binary,ternary}, fold_build[123], build_call_expr, build_size_arg, build_fold_addr_expr, build_call_array, non_lvalue, size_diffop, fold_build1_initializer, fold_build2_initializer, fold_build3_initializer, fold_build_call_array, fold_build_call_array_initializer, fold_single_bit_test, omit_one_operand, omit_two_operands, invert_truthvalue, fold_truth_not_expr, build_fold_indirect_ref, fold_indirect_ref, combine_comparisons, fold_builtin_*, fold_call_expr, build_range_check, maybe_fold_offset_to_address, round_up, round_down. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149722 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 61 +++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 373f4578190..9a768831621 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -333,7 +333,7 @@ build_base_path (enum tree_code code, if (null_test) { tree zero = cp_convert (TREE_TYPE (expr), integer_zero_node); - null_test = fold_build2 (NE_EXPR, boolean_type_node, + null_test = fold_build2_loc (input_location, NE_EXPR, boolean_type_node, expr, zero); } @@ -385,7 +385,7 @@ build_base_path (enum tree_code code, TREE_CONSTANT (v_offset) = 1; offset = convert_to_integer (ptrdiff_type_node, - size_diffop (offset, + size_diffop_loc (input_location, offset, BINFO_OFFSET (v_binfo))); if (!integer_zerop (offset)) @@ -417,7 +417,7 @@ build_base_path (enum tree_code code, { offset = fold_convert (sizetype, offset); if (code == MINUS_EXPR) - offset = fold_build1 (NEGATE_EXPR, sizetype, offset); + offset = fold_build1_loc (input_location, NEGATE_EXPR, sizetype, offset); expr = build2 (POINTER_PLUS_EXPR, ptr_target_type, expr, offset); } else @@ -428,8 +428,8 @@ build_base_path (enum tree_code code, out: if (null_test) - expr = fold_build3 (COND_EXPR, target_type, null_test, expr, - fold_build1 (NOP_EXPR, target_type, + expr = fold_build3_loc (input_location, COND_EXPR, target_type, null_test, expr, + fold_build1_loc (input_location, NOP_EXPR, target_type, integer_zero_node)); return expr; @@ -553,10 +553,11 @@ convert_to_base_statically (tree expr, tree base) expr = cp_build_unary_op (ADDR_EXPR, expr, /*noconvert=*/1, tf_warning_or_error); if (!integer_zerop (BINFO_OFFSET (base))) - expr = fold_build2 (POINTER_PLUS_EXPR, pointer_type, expr, + expr = fold_build2_loc (input_location, + POINTER_PLUS_EXPR, pointer_type, expr, fold_convert (sizetype, BINFO_OFFSET (base))); expr = fold_convert (build_pointer_type (BINFO_TYPE (base)), expr); - expr = build_fold_indirect_ref (expr); + expr = build_fold_indirect_ref_loc (input_location, expr); } return expr; @@ -1396,7 +1397,8 @@ determine_primary_bases (tree t) /* A virtual binfo might have been copied from within another hierarchy. As we're about to use it as a primary base, make sure the offsets match. */ - delta = size_diffop (convert (ssizetype, + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (base_binfo)), convert (ssizetype, BINFO_OFFSET (this_primary))); @@ -1459,7 +1461,7 @@ determine_primary_bases (tree t) /* A virtual binfo might have been copied from within another hierarchy. As we're about to use it as a primary base, make sure the offsets match. */ - delta = size_diffop (ssize_int (0), + delta = size_diffop_loc (input_location, ssize_int (0), convert (ssizetype, BINFO_OFFSET (primary))); propagate_binfo_offsets (primary, delta); @@ -2162,9 +2164,10 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, { /* We convert via virtual base. Adjust the fixed offset to be from there. */ - offset = size_diffop - (offset, convert - (ssizetype, BINFO_OFFSET (virtual_offset))); + offset = + size_diffop (offset, + convert (ssizetype, + BINFO_OFFSET (virtual_offset))); } if (fixed_offset) /* There was an existing fixed offset, this must be @@ -2247,7 +2250,8 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, if (virtual_base) /* The `this' pointer needs to be adjusted from the declaration to the nearest virtual base. */ - delta = size_diffop (convert (ssizetype, BINFO_OFFSET (virtual_base)), + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (virtual_base)), convert (ssizetype, BINFO_OFFSET (first_defn))); else if (lost) /* If the nearest definition is in a lost primary, we don't need an @@ -2260,7 +2264,8 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, BINFO to pointing at the base where the final overrider appears. */ virtual_covariant: - delta = size_diffop (convert (ssizetype, + delta = size_diffop_loc (input_location, + convert (ssizetype, BINFO_OFFSET (TREE_VALUE (overrider))), convert (ssizetype, BINFO_OFFSET (binfo))); @@ -3574,7 +3579,8 @@ layout_nonempty_base_or_field (record_layout_info rli, hierarchy. Therefore, we may not need to add the entire OFFSET. */ propagate_binfo_offsets (binfo, - size_diffop (convert (ssizetype, offset), + size_diffop_loc (input_location, + convert (ssizetype, offset), convert (ssizetype, BINFO_OFFSET (binfo)))); } @@ -3611,7 +3617,8 @@ layout_empty_base (record_layout_info rli, tree binfo, { if (abi_version_at_least (2)) propagate_binfo_offsets - (binfo, size_diffop (size_zero_node, BINFO_OFFSET (binfo))); + (binfo, size_diffop_loc (input_location, + size_zero_node, BINFO_OFFSET (binfo))); else warning (OPT_Wabi, "offset of empty base %qT may not be ABI-compliant and may" @@ -3717,7 +3724,8 @@ build_base_field (record_layout_info rli, tree binfo, /* On some platforms (ARM), even empty classes will not be byte-aligned. */ - eoc = round_up (rli_size_unit_so_far (rli), + eoc = round_up_loc (input_location, + rli_size_unit_so_far (rli), CLASSTYPE_ALIGN_UNIT (basetype)); atend = layout_empty_base (rli, binfo, eoc, offsets); /* A nearly-empty class "has no proper base class that is empty, @@ -4637,7 +4645,8 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets) && first_vbase && (tree_int_cst_lt (size_binop (CEIL_DIV_EXPR, - round_up (CLASSTYPE_SIZE (t), + round_up_loc (input_location, + CLASSTYPE_SIZE (t), CLASSTYPE_ALIGN (basetype)), bitsize_unit_node), BINFO_OFFSET (vbase)))) @@ -5070,7 +5079,7 @@ layout_class_type (tree t, tree *virtuals_p) /* Make sure that we are on a byte boundary so that the size of the class without virtual bases will always be a round number of bytes. */ - rli->bitpos = round_up (rli->bitpos, BITS_PER_UNIT); + rli->bitpos = round_up_loc (input_location, rli->bitpos, BITS_PER_UNIT); normalize_rli (rli); } @@ -7765,11 +7774,12 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid) The vbase offsets go in reverse inheritance-graph order, and we are walking in inheritance graph order so these end up in the right order. */ - delta = size_diffop (BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo)); + delta = size_diffop_loc (input_location, + BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo)); *vid->last_init = build_tree_list (NULL_TREE, - fold_build1 (NOP_EXPR, + fold_build1_loc (input_location, NOP_EXPR, vtable_entry_type, delta)); vid->last_init = &TREE_CHAIN (*vid->last_init); @@ -7999,9 +8009,11 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) vid->binfo. But it might be a lost primary, so its BINFO_OFFSET might be wrong, so we just use the BINFO_OFFSET from vid->binfo. */ - vcall_offset = size_diffop (BINFO_OFFSET (base), + vcall_offset = size_diffop_loc (input_location, + BINFO_OFFSET (base), BINFO_OFFSET (vid->binfo)); - vcall_offset = fold_build1 (NOP_EXPR, vtable_entry_type, + vcall_offset = fold_build1_loc (input_location, + NOP_EXPR, vtable_entry_type, vcall_offset); } /* Add the initializer to the vtable. */ @@ -8040,7 +8052,8 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid) && BINFO_INHERITANCE_CHAIN (primary_base) == b); b = primary_base; } - offset = size_diffop (BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b)); + offset = size_diffop_loc (input_location, + BINFO_OFFSET (vid->rtti_binfo), BINFO_OFFSET (b)); /* The second entry is the address of the typeinfo object. */ if (flag_rtti) -- cgit v1.2.1 From 27ccbdd99bae356e6bd76abe15bb9ef02fe586d2 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 24 Aug 2009 21:32:24 +0000 Subject: * cp-tree.h (DECL_DEFERRED_FN): Remove. (struct lang_decl_fn): Remove deferred flag. * class.c (build_clone): Don't set it. * decl2.c (note_vague_linkage_fn): Don't check or set it. (mark_used): Don't check it. * method.c (make_thunk, make_alias_for): Don't set it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151063 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9a768831621..694d2628baa 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3881,8 +3881,6 @@ build_clone (tree fn, tree name) /* There's no pending inline data for this function. */ DECL_PENDING_INLINE_INFO (clone) = NULL; DECL_PENDING_INLINE_P (clone) = 0; - /* And it hasn't yet been deferred. */ - DECL_DEFERRED_FN (clone) = 0; /* The base-class destructor is not virtual. */ if (name == base_dtor_identifier) -- cgit v1.2.1 From 7496b60933cbb86c3bb26e4f17bc3d1861492c47 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 27 Aug 2009 08:56:10 +0000 Subject: 2009-08-27 Richard Guenther * gengtype.c (main): Handle uint64_t. * ipa-utils.c (get_base_var): Indent properly. * tree-ssa-live.c (debug_scope_block): New function. * tree-flow.h (debug_scope_block): Declare. * tree-ssa-copy.c (replace_exp_1): Add vertical space. * basic-block.h (enum profile_status): Rename to enum profile_status_d. (x_profile_status): Adjust type. cp/ * class.c (build_vtbl_ref_1): Remove excess vertical space. * Make-lang.in (CXX_TREE_H): Remove c-common.def dependency tracked by $(TREE_H). * semantics.c (expand_or_defer_fn): Zero DECL_SAVED_TREE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151139 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 694d2628baa..2c308cfb5c9 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -624,7 +624,6 @@ build_vtbl_ref_1 (tree instance, tree idx) if (!vtbl) vtbl = build_vfield_ref (instance, basetype); - aref = build_array_ref (input_location, vtbl, idx); TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx); -- cgit v1.2.1 From f353e7cd324ede485593b22e33f4e7ed68fc9498 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 8 Sep 2009 18:13:02 +0000 Subject: * class.c (currently_open_class): Make sure we're dealing with the main variant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151529 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 2c308cfb5c9..9938a3d84d1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5846,6 +5846,8 @@ currently_open_class (tree t) if (!CLASS_TYPE_P (t)) return false; + t = TYPE_MAIN_VARIANT (t); + /* We start looking from 1 because entry 0 is from global scope, and has no type. */ for (i = current_class_depth; i > 0; --i) -- cgit v1.2.1 From a8b750816ddebe7302b52551d9cb745e77d95152 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Sep 2009 03:01:30 +0000 Subject: merge in cxx0x-lambdas-branch@152308 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152318 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 9938a3d84d1..d29d6615f33 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2677,6 +2677,10 @@ add_implicitly_declared_members (tree t, CLASSTYPE_LAZY_COPY_CTOR (t) = 1; } + /* Currently only lambdas get a lazy move ctor. */ + if (LAMBDA_TYPE_P (t)) + CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; + /* If there is no assignment operator, one will be created if and when it is needed. For now, just record whether or not the type of the parameter to the assignment operator will be a const or @@ -4449,6 +4453,20 @@ check_bases_and_members (tree t) cant_have_const_ctor, no_const_asn_ref); + if (LAMBDA_TYPE_P (t)) + { + /* "The closure type associated with a lambda-expression has a deleted + default constructor and a deleted copy assignment operator." */ + TYPE_NEEDS_CONSTRUCTING (t) = 1; + TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0; + CLASSTYPE_LAZY_DEFAULT_CTOR (t) = 0; + TYPE_HAS_ASSIGN_REF (t) = 0; + CLASSTYPE_LAZY_ASSIGNMENT_OP (t) = 0; + + /* "This class type is not an aggregate." */ + CLASSTYPE_NON_AGGREGATE (t) = 1; + } + /* Create the in-charge and not-in-charge variants of constructors and destructors. */ clone_constructors_and_destructors (t); @@ -6601,7 +6619,8 @@ maybe_note_name_used_in_class (tree name, tree decl) /* If we're not defining a class, there's nothing to do. */ if (!(innermost_scope_kind() == sk_class - && TYPE_BEING_DEFINED (current_class_type))) + && TYPE_BEING_DEFINED (current_class_type) + && !LAMBDA_TYPE_P (current_class_type))) return; /* If there's already a binding for this NAME, then we don't have -- cgit v1.2.1 From e8c9f615d3856ee3d8635e8ec92bbd2fa2cfa3a9 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 26 Oct 2009 19:07:14 +0000 Subject: PR c++/38796, Core issue 906 gcc/cp * cp-tree.h (DECL_DEFAULTED_OUTSIDE_CLASS_P): New. (DECL_DEFAULTED_IN_CLASS_P): New. * class.c (user_provided_p): Non-static. (check_methods): Use it. (check_bases_and_members): Check defaulted fns. (defaultable_fn_p): Move and rename to... * method.c (defaultable_fn_check): ...this. (defaulted_late_check): New. * pt.c (tsubst_decl): Call it. * decl2.c (grokfield): Adjust. * decl.c (cp_finish_decl): Adjust. (grok_special_member_properties): Use user_provided_p. libstdc++-v3 * include/std/future (~Future_result_base): Default outside class body. * include/std/system_error (error_category()): Likewise. * libsupc++/nested_exception.h (nested_exception): Remove exception specifications from defaulted methods. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153565 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 61 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d29d6615f33..d737bdf7055 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3843,7 +3843,7 @@ check_methods (tree t) VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); } /* All user-provided destructors are non-trivial. */ - if (DECL_DESTRUCTOR_P (x) && !DECL_DEFAULTED_FN (x)) + if (DECL_DESTRUCTOR_P (x) && user_provided_p (x)) TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1; } } @@ -4174,17 +4174,17 @@ type_has_user_nondefault_constructor (tree t) } /* Returns true iff FN is a user-provided function, i.e. user-declared - and not defaulted at its first declaration. */ + and not defaulted at its first declaration; or explicit, private, + protected, or non-const. */ -static bool +bool user_provided_p (tree fn) { if (TREE_CODE (fn) == TEMPLATE_DECL) return true; else return (!DECL_ARTIFICIAL (fn) - && !(DECL_DEFAULTED_FN (fn) - && DECL_INITIALIZED_IN_CLASS_P (fn))); + && !DECL_DEFAULTED_IN_CLASS_P (fn)); } /* Returns true iff class T has a user-provided constructor. */ @@ -4238,31 +4238,6 @@ type_has_user_provided_default_constructor (tree t) return false; } -/* Returns true if FN can be explicitly defaulted. */ - -bool -defaultable_fn_p (tree fn) -{ - if (DECL_CONSTRUCTOR_P (fn)) - { - if (FUNCTION_FIRST_USER_PARMTYPE (fn) == void_list_node) - return true; - else if (copy_fn_p (fn) > 0 - && (TREE_CHAIN (FUNCTION_FIRST_USER_PARMTYPE (fn)) - == void_list_node)) - return true; - else - return false; - } - else if (DECL_DESTRUCTOR_P (fn)) - return true; - else if (DECL_ASSIGNMENT_OPERATOR_P (fn) - && DECL_OVERLOADED_OPERATOR_P (fn) == NOP_EXPR) - return copy_fn_p (fn); - else - return false; -} - /* Remove all zero-width bit-fields from T. */ static void @@ -4356,6 +4331,7 @@ check_bases_and_members (tree t) tree access_decls; bool saved_complex_asn_ref; bool saved_nontrivial_dtor; + tree fn; /* By default, we use const reference arguments and generate default constructors. */ @@ -4453,6 +4429,31 @@ check_bases_and_members (tree t) cant_have_const_ctor, no_const_asn_ref); + /* Check defaulted declarations here so we have cant_have_const_ctor + and don't need to worry about clones. */ + for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) + if (DECL_DEFAULTED_IN_CLASS_P (fn)) + { + int copy = copy_fn_p (fn); + if (copy > 0) + { + bool imp_const_p + = (DECL_CONSTRUCTOR_P (fn) ? !cant_have_const_ctor + : !no_const_asn_ref); + bool fn_const_p = (copy == 2); + + if (fn_const_p && !imp_const_p) + /* If the function is defaulted outside the class, we just + give the synthesis error. */ + error ("%q+D declared to take const reference, but implicit " + "declaration would take non-const", fn); + else if (imp_const_p && !fn_const_p) + error ("%q+D declared to take non-const reference cannot be " + "defaulted in the class body", fn); + } + defaulted_late_check (fn); + } + if (LAMBDA_TYPE_P (t)) { /* "The closure type associated with a lambda-expression has a deleted -- cgit v1.2.1 From 91a733f97f879e50ec17dea55200c6d630d75cd3 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Oct 2009 21:58:09 +0000 Subject: Allow no-capture lambdas to convert to function pointer. * semantics.c (maybe_add_lambda_conv_op): New. * parser.c (cp_parser_lambda_expression): Call it. (cp_parser_lambda_declarator_opt): Make op() static if no captures. * mangle.c (write_closure_type_name): Adjust. * semantics.c (finish_this_expr): Adjust. * decl.c (grok_op_properties): Allow it. * call.c (build_user_type_conversion_1): Handle static conversion op. (build_op_call): And op(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153617 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index d737bdf7055..dc4c6b39c9a 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2677,7 +2677,8 @@ add_implicitly_declared_members (tree t, CLASSTYPE_LAZY_COPY_CTOR (t) = 1; } - /* Currently only lambdas get a lazy move ctor. */ + /* Currently only lambdas get a lazy move ctor, but N2987 adds them for + other classes. */ if (LAMBDA_TYPE_P (t)) CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; -- cgit v1.2.1 From 0a52fc4a6faa7c7baa63ddb59ae2fc042cb9a8f9 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 6 Nov 2009 03:33:17 +0000 Subject: PR c++/7046 * class.c (finish_struct): Store maximum_field_alignment in TYPE_PRECISION. * pt.c (instantiate_class_template): Set maximum_field_alignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153959 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index dc4c6b39c9a..4020144e815 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5516,6 +5516,9 @@ finish_struct (tree t, tree attributes) if (DECL_PURE_VIRTUAL_P (x)) VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); complete_vars (t); + + /* Remember current #pragma pack value. */ + TYPE_PRECISION (t) = maximum_field_alignment; } else finish_struct_1 (t); -- cgit v1.2.1 From 897d42c2d6da15f8f0f4fc7ec6bae0f9c884dd4b Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 6 Nov 2009 21:18:35 +0000 Subject: PR c++/9381 * decl2.c (build_memfn_type): Preserve attributes. (cp_reconstruct_complex_type): Likewise. (maybe_retrofit_in_chrg): Likewise. * call.c (standard_conversion): Use build_memfn_type. * pt.c (tsubst): Likewise. * decl.c (build_ptrmem_type): Likewise (check_function_type): Preserve attributes. * tree.c (cp_build_type_attribute_variant): Propagate exception specs on METHOD_TYPE, too. (strip_typedefs): Preserve exception specs and attributes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153977 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 4020144e815..c798ba2833f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4104,6 +4104,7 @@ adjust_clone_args (tree decl) /* A default parameter has been added. Adjust the clone's parameters. */ tree exceptions = TYPE_RAISES_EXCEPTIONS (TREE_TYPE (clone)); + tree attrs = TYPE_ATTRIBUTES (TREE_TYPE (clone)); tree basetype = TYPE_METHOD_BASETYPE (TREE_TYPE (clone)); tree type; @@ -4121,6 +4122,8 @@ adjust_clone_args (tree decl) clone_parms); if (exceptions) type = build_exception_variant (type, exceptions); + if (attrs) + type = cp_build_type_attribute_variant (type, attrs); TREE_TYPE (clone) = type; clone_parms = NULL_TREE; -- cgit v1.2.1 From 4d5c38fc8df3eb086dda3acfbe37ec06d7683698 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 19 Nov 2009 16:59:05 +0000 Subject: PR c++/561 * decl.c (static_fn_type): Split out... (revert_static_member_fn): ...from here. * cp-tree.h: Declare it. * class.c (resolve_address_of_overloaded_function): Use it to compare pointers to member functions. * typeck.c (build_static_cast_1): Call instantiate_type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154336 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 39 ++++++++++++--------------------------- 1 file changed, 12 insertions(+), 27 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c798ba2833f..3cf15fb0fa6 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6065,6 +6065,7 @@ resolve_address_of_overloaded_function (tree target_type, interoperability with most_specialized_instantiation. */ tree matches = NULL_TREE; tree fn; + tree target_fn_type; /* By the time we get here, we should be seeing only real pointer-to-member types, not the internal POINTER_TYPE to @@ -6096,6 +6097,15 @@ resolve_address_of_overloaded_function (tree target_type, return error_mark_node; } + /* Non-member functions and static member functions match targets of type + "pointer-to-function" or "reference-to-function." Nonstatic member + functions match targets of type "pointer-to-member-function;" the + function type of the pointer to member is used to select the member + function from the set of overloaded member functions. + + So figure out the FUNCTION_TYPE that we want to match against. */ + target_fn_type = static_fn_type (target_type); + /* If we can find a non-template function that matches, we can just use it. There's no point in generating template instantiations if we're just going to throw them out anyhow. But, of course, we @@ -6107,7 +6117,6 @@ resolve_address_of_overloaded_function (tree target_type, for (fns = overload; fns; fns = OVL_NEXT (fns)) { tree fn = OVL_CURRENT (fns); - tree fntype; if (TREE_CODE (fn) == TEMPLATE_DECL) /* We're not looking for templates just yet. */ @@ -6125,13 +6134,7 @@ resolve_address_of_overloaded_function (tree target_type, continue; /* See if there's a match. */ - fntype = TREE_TYPE (fn); - if (is_ptrmem) - fntype = build_ptrmemfunc_type (build_pointer_type (fntype)); - else if (!is_reference) - fntype = build_pointer_type (fntype); - - if (can_convert_arg (target_type, fntype, fn, LOOKUP_NORMAL)) + if (same_type_p (target_fn_type, static_fn_type (fn))) matches = tree_cons (fn, NULL_TREE, matches); } } @@ -6141,7 +6144,6 @@ resolve_address_of_overloaded_function (tree target_type, match we need to look at them, too. */ if (!matches) { - tree target_fn_type; tree target_arg_types; tree target_ret_type; tree fns; @@ -6149,18 +6151,9 @@ resolve_address_of_overloaded_function (tree target_type, unsigned int nargs, ia; tree arg; - if (is_ptrmem) - target_fn_type - = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (target_type)); - else - target_fn_type = TREE_TYPE (target_type); target_arg_types = TYPE_ARG_TYPES (target_fn_type); target_ret_type = TREE_TYPE (target_fn_type); - /* Never do unification on the 'this' parameter. */ - if (TREE_CODE (target_fn_type) == METHOD_TYPE) - target_arg_types = TREE_CHAIN (target_arg_types); - nargs = list_length (target_arg_types); args = XALLOCAVEC (tree, nargs); for (arg = target_arg_types, ia = 0; @@ -6173,7 +6166,6 @@ resolve_address_of_overloaded_function (tree target_type, { tree fn = OVL_CURRENT (fns); tree instantiation; - tree instantiation_type; tree targs; if (TREE_CODE (fn) != TEMPLATE_DECL) @@ -6201,14 +6193,7 @@ resolve_address_of_overloaded_function (tree target_type, continue; /* See if there's a match. */ - instantiation_type = TREE_TYPE (instantiation); - if (is_ptrmem) - instantiation_type = - build_ptrmemfunc_type (build_pointer_type (instantiation_type)); - else if (!is_reference) - instantiation_type = build_pointer_type (instantiation_type); - if (can_convert_arg (target_type, instantiation_type, instantiation, - LOOKUP_NORMAL)) + if (same_type_p (target_fn_type, static_fn_type (instantiation))) matches = tree_cons (instantiation, fn, matches); } -- cgit v1.2.1 From 013143e015ea9a0a876b60b1143ca3b234f1aea3 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 20 Nov 2009 03:12:07 +0000 Subject: DR 176 permissiveness gcc/ * dwarf2out.c (get_context_die): Take TYPE_MAIN_VARIANT. gcc/cp/ * class.c (build_self_reference): Call set_underlying_type. * decl.c (check_elaborated_type_specifier): Don't complain about injected-class-name. (type_is_deprecated): Use TYPE_MAIN_VARIANT. * pt.c (convert_template_argument): Handle injected-class-name used as template template argument. * typeck2.c (abstract_virtuals_error): Use TYPE_MAIN_VARIANT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154354 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3cf15fb0fa6..38eb73f4004 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6513,6 +6513,7 @@ build_self_reference (void) DECL_CONTEXT (value) = current_class_type; DECL_ARTIFICIAL (value) = 1; SET_DECL_SELF_REFERENCE_P (value); + set_underlying_type (value); if (processing_template_decl) value = push_template_decl (value); -- cgit v1.2.1 From 8e9e8d76599e6392050ce67a4c965fc493ed01ef Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 2 Dec 2009 08:39:10 +0000 Subject: * g++spec.c (lang_specific_driver): Remove unused saw_verbose_flag variable. * pt.c (tsubst_pack_expansion): Remove unused first_arg_pack variable. * init.c (build_vec_init): Remove unused size variable. * typeck2.c (check_narrowing): Remove unused was_decl variable. * decl.c (poplevel): Remove unused tmp and real_functionbody variables. (decls_match): Remove unused tree_name variable. (start_decl): Remove unused type variable. * parser.c (cp_parser_type_parameter): Remove unused parameter_list variable. (cp_parser_template_id, cp_parser_explicit_instantiation, cp_parser_declarator): Remove unused token variable. (cp_parser_simple_type_specifier): Remove unused id variable. (cp_parser_parameter_declaration): Remove unused greater_than_is_operator_p variable. (cp_parser_check_declarator_template_parameters): Remove unused member variable. (c_parse_file): Remove unused error_occurred variable. * cp-gimplify.c (cp_gimplify_init_expr): Remove unused slot variable. * typeck.c (cp_build_function_call_vec): Remove unused name variable. * class.c (resolve_address_of_overloaded_function): Remove unused is_reference variable. (build_rtti_vtbl_entries): Remove unused basetype variable. * mangle.c (write_template_param): Remove unused parm_level and parm_type variables. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154899 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 38eb73f4004..1dcc2383794 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6059,7 +6059,6 @@ resolve_address_of_overloaded_function (tree target_type, selected function. */ int is_ptrmem = 0; - int is_reference = 0; /* We store the matches in a TREE_LIST rooted here. The functions are the TREE_PURPOSE, not the TREE_VALUE, in this list, for easy interoperability with most_specialized_instantiation. */ @@ -6082,12 +6081,9 @@ resolve_address_of_overloaded_function (tree target_type, /* This is OK, too. */ is_ptrmem = 1; else if (TREE_CODE (target_type) == FUNCTION_TYPE) - { - /* This is OK, too. This comes from a conversion to reference - type. */ - target_type = build_reference_type (target_type); - is_reference = 1; - } + /* This is OK, too. This comes from a conversion to reference + type. */ + target_type = build_reference_type (target_type); else { if (flags & tf_error) @@ -8043,12 +8039,10 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid) { tree b; tree t; - tree basetype; tree offset; tree decl; tree init; - basetype = BINFO_TYPE (binfo); t = BINFO_TYPE (vid->rtti_binfo); /* To find the complete object, we will first convert to our most -- cgit v1.2.1 From 8a72e7d5378073be6dc7dbf59137861dc3e5881b Mon Sep 17 00:00:00 2001 From: dodji Date: Thu, 3 Dec 2009 08:33:03 +0000 Subject: Fix PR c++/42217 gcc/cp/ChangeLog PR c++/42217 * class.c (remove_zero_width_bit_fields): The width of the bit field is in DECL_SIZE, not in DECL_INITIAL. gcc/testsuite/ChangeLog PR c++/42217 * g++.dg/other/bitfield4.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154938 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 1dcc2383794..ca75bc15896 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4254,7 +4254,12 @@ remove_zero_width_bit_fields (tree t) { if (TREE_CODE (*fieldsp) == FIELD_DECL && DECL_C_BIT_FIELD (*fieldsp) - && DECL_INITIAL (*fieldsp)) + /* We should not be confused by the fact that grokbitfield + temporarily sets the width of the bit field into + DECL_INITIAL (*fieldsp). + check_bitfield_decl eventually sets DECL_SIZE (*fieldsp) + to that width. */ + && integer_zerop (DECL_SIZE (*fieldsp))) *fieldsp = TREE_CHAIN (*fieldsp); else fieldsp = &TREE_CHAIN (*fieldsp); -- cgit v1.2.1 From d7f79c8890d12b5ac37f59b9e5171ca6f4fe3b41 Mon Sep 17 00:00:00 2001 From: dodji Date: Fri, 11 Dec 2009 14:36:05 +0000 Subject: Fix PR c++/42225 gcc/cp/ChangeLog: PR c++/42225 * typeck.c (incompatible_dependent_typedefs_p): New function. (structural_comptypes): Use it. * cp-tree.h (cp_set_underlying_type): Declare ... * tree.c (cp_set_underlying_type): ... new function. * class.c (build_self_reference): Use cp_set_underlying_type instead of set_underlying_type. * decl2.c (grokfield): Likewise. * name-lookup.c (pushdecl_maybe_friend): Likewise. gcc/testsuite/ChangeLog: PR c++/42225 * g++.dg/template/typedef24.C: New test. * g++.dg/template/typedef25.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155160 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index ca75bc15896..fff438033d3 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6514,7 +6514,7 @@ build_self_reference (void) DECL_CONTEXT (value) = current_class_type; DECL_ARTIFICIAL (value) = 1; SET_DECL_SELF_REFERENCE_P (value); - set_underlying_type (value); + cp_set_underlying_type (value); if (processing_template_decl) value = push_template_decl (value); -- cgit v1.2.1 From f08923b304ae4677059147e8cd52278a201f9ce0 Mon Sep 17 00:00:00 2001 From: pzhao Date: Thu, 17 Dec 2009 03:22:22 +0000 Subject: 2009-12-17 Shujing Zhao PR c/40885 * c-common.h (ref_operator): New type. (build_indirect_ref): Adjust prototype with new argument. * c-typeck.c (build_indirect_ref): Accept ref_operator as argument and emit the diagnostics for easy translation. (build_array_ref): Update calls to build_indirect_ref. * c-omp.c (c_finish_omp_atomic): Likewise. * c-parser.c (c_parser_unary_expression, c_parser_postfix_expression_after_primary): Likewise. cp/ 2009-12-17 Shujing Zhao * typeck.c (build_indirect_ref): Update the argument. (build_x_indirect_ref): Likewise. (cp_build_indirect_ref): Update the argument and emit the diagnostics for easy translation. (build_class_member_access_expr, build_array_ref, get_member_function_from_ptrfunc): Update calls. * cp-tree.h (build_x_indirect_ref, cp_build_indirect_ref): Update prototypes. * call.c (build_new_op, convert_like_real, build_x_va_arg, build_over_call): Update calls. * class.c (build_base_path, build_simple_base_path, build_vfn_ref): Likewise. * decl.c (start_preparsed_function): Likewise. * except.c (expand_start_catch_block, build_throw): Likewise. * init.c (emit_mem_initializers, expand_virtual_init, expand_virtual_init, build_new_1, build_vec_init, build_delete, build_vec_delete): Likewise. * parser.c (cp_parser_unary_expression): Likewise. * pt.c (tsubst_copy_and_build): Likewise. * rtti.c (build_headof, get_tinfo_decl_dynamic, get_typeid): Likewise. * semantics.c (finish_non_static_data_member, thisify_lambda_field): Likewise. * tree.c (build_dummy_object, stabilize_expr): Likewise. * typeck2.c (build_x_arrow): Likewise. testsuite/ 2009-12-17 Shujing Zhao * g++.old-deja/g++.mike/net31.C: Make expected dg-error strings explicit. * g++.old-deja/g++.bugs/900213_02.C: Likewise. * g++.old-deja/g++.bugs/900215_02.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155302 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index fff438033d3..16d566682a6 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -297,7 +297,7 @@ build_base_path (enum tree_code code, { expr = build_nop (build_pointer_type (target_type), expr); if (!want_pointer) - expr = build_indirect_ref (EXPR_LOCATION (expr), expr, NULL); + expr = build_indirect_ref (EXPR_LOCATION (expr), expr, RO_NULL); return expr; } @@ -343,7 +343,7 @@ build_base_path (enum tree_code code, interesting to the optimizers anyway. */ && !has_empty) { - expr = cp_build_indirect_ref (expr, NULL, tf_warning_or_error); + expr = cp_build_indirect_ref (expr, RO_NULL, tf_warning_or_error); expr = build_simple_base_path (expr, binfo); if (want_pointer) expr = build_address (expr); @@ -368,11 +368,11 @@ build_base_path (enum tree_code code, t = TREE_TYPE (TYPE_VFIELD (current_class_type)); t = build_pointer_type (t); v_offset = convert (t, current_vtt_parm); - v_offset = cp_build_indirect_ref (v_offset, NULL, + v_offset = cp_build_indirect_ref (v_offset, RO_NULL, tf_warning_or_error); } else - v_offset = build_vfield_ref (cp_build_indirect_ref (expr, NULL, + v_offset = build_vfield_ref (cp_build_indirect_ref (expr, RO_NULL, tf_warning_or_error), TREE_TYPE (TREE_TYPE (expr))); @@ -381,7 +381,7 @@ build_base_path (enum tree_code code, v_offset = build1 (NOP_EXPR, build_pointer_type (ptrdiff_type_node), v_offset); - v_offset = cp_build_indirect_ref (v_offset, NULL, tf_warning_or_error); + v_offset = cp_build_indirect_ref (v_offset, RO_NULL, tf_warning_or_error); TREE_CONSTANT (v_offset) = 1; offset = convert_to_integer (ptrdiff_type_node, @@ -424,7 +424,7 @@ build_base_path (enum tree_code code, null_test = NULL; if (!want_pointer) - expr = cp_build_indirect_ref (expr, NULL, tf_warning_or_error); + expr = cp_build_indirect_ref (expr, RO_NULL, tf_warning_or_error); out: if (null_test) @@ -458,7 +458,7 @@ build_simple_base_path (tree expr, tree binfo) in the back end. */ temp = unary_complex_lvalue (ADDR_EXPR, expr); if (temp) - expr = cp_build_indirect_ref (temp, NULL, tf_warning_or_error); + expr = cp_build_indirect_ref (temp, RO_NULL, tf_warning_or_error); return expr; } @@ -646,7 +646,7 @@ build_vfn_ref (tree instance_ptr, tree idx) { tree aref; - aref = build_vtbl_ref_1 (cp_build_indirect_ref (instance_ptr, 0, + aref = build_vtbl_ref_1 (cp_build_indirect_ref (instance_ptr, RO_NULL, tf_warning_or_error), idx); -- cgit v1.2.1 From 46e79de0b2639b93ad427705b1f05d3068f427cf Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 20 Jan 2010 22:14:51 +0000 Subject: PR c++/41788 * class.c (layout_class_type): Set packed_maybe_necessary for packed non-PODs. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156088 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 16d566682a6..f88914d3c22 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5216,6 +5216,11 @@ layout_class_type (tree t, tree *virtuals_p) build_decl (input_location, FIELD_DECL, NULL_TREE, char_type_node)); + /* If this is a non-POD, declaring it packed makes a difference to how it + can be used as a field; don't let finalize_record_size undo it. */ + if (TYPE_PACKED (t) && !layout_pod_type_p (t)) + rli->packed_maybe_necessary = true; + /* Let the back end lay out the type. */ finish_record_layout (rli, /*free_p=*/true); -- cgit v1.2.1 From aa1d3529bbcffc39740b198cb013ef285676a17d Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 19 Feb 2010 01:16:28 +0000 Subject: PR c++/42837 * class.c (create_vtable_ptr): Set DECL_PACKED if type is packed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156885 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f88914d3c22..f7e0a9307d5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4554,6 +4554,8 @@ create_vtable_ptr (tree t, tree* virtuals_p) DECL_ARTIFICIAL (field) = 1; DECL_FIELD_CONTEXT (field) = t; DECL_FCONTEXT (field) = t; + if (TYPE_PACKED (t)) + DECL_PACKED (field) = 1; TYPE_VFIELD (t) = field; -- cgit v1.2.1 From aee336fc478509d78f98243d07d51a700f985f82 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 24 Feb 2010 19:26:29 +0000 Subject: * class.c (layout_class_type): Don't give -Wabi warning for a bug in a previous ABI version. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157051 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f7e0a9307d5..1bab07dd42c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5044,6 +5044,7 @@ layout_class_type (tree t, tree *virtuals_p) /* G++ used to use DECL_FIELD_OFFSET as if it were the byte offset of the field. */ if (warn_abi + && !abi_version_at_least (2) && !tree_int_cst_equal (DECL_FIELD_OFFSET (field), byte_position (field)) && contains_empty_class_p (TREE_TYPE (field))) -- cgit v1.2.1 From b566a4fd1a917fc9a9d1f8116171c8798efb7b7e Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 18:56:13 +0000 Subject: PR c++/42844 * decl.c (check_for_uninitialized_const_var): Handle classes that need constructing, too. (check_initializer): Call it for classes that need constructing, too. * class.c (in_class_defaulted_default_constructor): New. * cp-tree.h: Declare it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158797 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 1bab07dd42c..26da21b8c82 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1,6 +1,6 @@ /* Functions related to building classes and their related objects. Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, - 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009 + 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. Contributed by Michael Tiemann (tiemann@cygnus.com) @@ -4177,6 +4177,34 @@ type_has_user_nondefault_constructor (tree t) return false; } +/* Returns the defaulted constructor if T has one. Otherwise, returns + NULL_TREE. */ + +tree +in_class_defaulted_default_constructor (tree t) +{ + tree fns, args; + + if (!TYPE_HAS_USER_CONSTRUCTOR (t)) + return NULL_TREE; + + for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + { + tree fn = OVL_CURRENT (fns); + + if (DECL_DEFAULTED_IN_CLASS_P (fn)) + { + args = FUNCTION_FIRST_USER_PARMTYPE (fn); + while (args && TREE_PURPOSE (args)) + args = TREE_CHAIN (args); + if (!args || args == void_list_node) + return fn; + } + } + + return NULL_TREE; +} + /* Returns true iff FN is a user-provided function, i.e. user-declared and not defaulted at its first declaration; or explicit, private, protected, or non-const. */ -- cgit v1.2.1 From 640a46a5c7038d1d97009cd1d4106ed24281985b Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 19:04:09 +0000 Subject: PR c++/41468 * class.c (convert_to_base): Add complain parameter. Pass ba_quiet to lookup_base if we don't want errors. (build_vfield_ref): Pass complain to convert_to_base. * call.c (convert_like_real): Likewise. (initialize_reference): Likewise. (perform_direct_initialization_if_possible): Pass complain to convert_like_real. * cp-tree.h: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158798 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 26da21b8c82..07dfb1ce561 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -506,10 +506,12 @@ build_simple_base_path (tree expr, tree binfo) assumed to be non-NULL. */ tree -convert_to_base (tree object, tree type, bool check_access, bool nonnull) +convert_to_base (tree object, tree type, bool check_access, bool nonnull, + tsubst_flags_t complain) { tree binfo; tree object_type; + base_access access; if (TYPE_PTR_P (TREE_TYPE (object))) { @@ -519,8 +521,11 @@ convert_to_base (tree object, tree type, bool check_access, bool nonnull) else object_type = TREE_TYPE (object); + access = check_access ? ba_check : ba_unique; + if (!(complain & tf_error)) + access |= ba_quiet; binfo = lookup_base (object_type, type, - check_access ? ba_check : ba_unique, + access, NULL); if (!binfo || binfo == error_mark_node) return error_mark_node; @@ -575,7 +580,7 @@ build_vfield_ref (tree datum, tree type) /* First, convert to the requested type. */ if (!same_type_ignoring_top_level_qualifiers_p (TREE_TYPE (datum), type)) datum = convert_to_base (datum, type, /*check_access=*/false, - /*nonnull=*/true); + /*nonnull=*/true, tf_warning_or_error); /* Second, the requested type may not be the owner of its own vptr. If not, convert to the base class that owns it. We cannot use -- cgit v1.2.1 From e97d2125b72beaac4d28f38a13114b2330d1bc6b Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:26:25 +0000 Subject: PR c++/43856 * name-lookup.c (qualify_lookup): Disqualify lambda op(). * class.c (current_nonlambda_class_type): New fn. * semantics.c (nonlambda_method_basetype): New. * cp-tree.h: Declare them. * tree.c (maybe_dummy_object): Handle implicit 'this' capture. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158807 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 07dfb1ce561..c640af4d5b6 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5971,6 +5971,34 @@ currently_open_derived_class (tree t) return NULL_TREE; } +/* Returns the innermost class type which is not a lambda closure type. */ + +tree +current_nonlambda_class_type (void) +{ + int i; + + /* We start looking from 1 because entry 0 is from global scope, + and has no type. */ + for (i = current_class_depth; i > 0; --i) + { + tree c; + if (i == current_class_depth) + c = current_class_type; + else + { + if (current_class_stack[i].hidden) + break; + c = current_class_stack[i].type; + } + if (!c) + continue; + if (!LAMBDA_TYPE_P (c)) + return c; + } + return NULL_TREE; +} + /* When entering a class scope, all enclosing class scopes' names with static meaning (static variables, static functions, types and enumerators) have to be visible. This recursive function calls -- cgit v1.2.1 From bb9c1a09933d3b672bedb16747761d478245dddc Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 3 May 2010 21:16:40 +0000 Subject: PR c++/43680 gcc: * c.opt (-fstrict-enums): New. * doc/invoke.texi (C++ Dialect Options): Document -fstrict-enums. gcc/cp: * decl.c (finish_enum): Use the TYPE_MIN_VALUE and TYPE_MAX_VALUE from the selected underlying type unless -fstrict-enums. Set ENUM_UNDERLYING_TYPE to have the restricted range. * cvt.c (type_promotes_to): Use ENUM_UNDERLYING_TYPE. * class.c (check_bitfield_decl): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159006 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c640af4d5b6..87f8111f15f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2786,14 +2786,8 @@ check_bitfield_decl (tree field) && TREE_CODE (type) != BOOLEAN_TYPE) warning (0, "width of %q+D exceeds its type", field); else if (TREE_CODE (type) == ENUMERAL_TYPE - && (0 > compare_tree_int (w, - tree_int_cst_min_precision - (TYPE_MIN_VALUE (type), - TYPE_UNSIGNED (type))) - || 0 > compare_tree_int (w, - tree_int_cst_min_precision - (TYPE_MAX_VALUE (type), - TYPE_UNSIGNED (type))))) + && (0 > (compare_tree_int + (w, TYPE_PRECISION (ENUM_UNDERLYING_TYPE (type)))))) warning (0, "%q+D is too small to hold all values of %q#T", field, type); } -- cgit v1.2.1 From 4fdaf896dddd224958053b670bc9be78f102e789 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 May 2010 05:04:14 +0000 Subject: * cp-tree.h (UNKNOWN_TYPE): Remove. * decl.c (cxx_init_decl_processing): Use LANG_TYPE instead. * error.c (dumy_type, dump_type_prefix, dump_type_suffix): Likewise. * typeck2.c (cxx_incomplete_type_diagnostic): Likewise. * class.c (instantiate_type): Check unknown_type_node rather than UNKNOWN_TYPE. * name-lookup.c (maybe_push_decl): Likewise. * rtti.c (get_tinfo_decl_dynamic): Likewise. (get_typeid): Likewise. * semantics.c (finish_offsetof): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159349 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 87f8111f15f..88db80faae8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -6398,7 +6398,7 @@ instantiate_type (tree lhstype, tree rhs, tsubst_flags_t flags) flags &= ~tf_ptrmem_ok; - if (TREE_CODE (lhstype) == UNKNOWN_TYPE) + if (lhstype == unknown_type_node) { if (flags & tf_error) error ("not enough type information"); -- cgit v1.2.1 From b48186034999492fb05990f815702e81d214a61d Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 May 2010 05:05:21 +0000 Subject: * typeck.c (build_array_ref): Take complain parm. * cp-tree.h: Add it to prototype. * call.c (build_new_op): Pass it. * class.c (build_vtbl_ref): Pass it. * decl2.c (grok_array_decl): Pass it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159351 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 88db80faae8..e22ef079440 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -629,7 +629,7 @@ build_vtbl_ref_1 (tree instance, tree idx) if (!vtbl) vtbl = build_vfield_ref (instance, basetype); - aref = build_array_ref (input_location, vtbl, idx); + aref = build_array_ref (input_location, vtbl, idx, tf_warning_or_error); TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx); return aref; -- cgit v1.2.1 From 1d291991576abee064a48ae7f070adf347eeac29 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 May 2010 20:53:38 +0000 Subject: * typeck.c (cp_build_array_ref): Factor out from... (build_array_ref): ...here. Drop complain parm. (build_new_op): Adjust. * class.c (build_vtbl_ref_1): Adjust. * decl2.c (grok_array_decl): Adjust. * cp-tree.h: Adjust prototypes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159377 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index e22ef079440..88db80faae8 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -629,7 +629,7 @@ build_vtbl_ref_1 (tree instance, tree idx) if (!vtbl) vtbl = build_vfield_ref (instance, basetype); - aref = build_array_ref (input_location, vtbl, idx, tf_warning_or_error); + aref = build_array_ref (input_location, vtbl, idx); TREE_CONSTANT (aref) |= TREE_CONSTANT (vtbl) && TREE_CONSTANT (idx); return aref; -- cgit v1.2.1 From ce494fcf6cecbd423d44d552e2094b923fac9a22 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 19 May 2010 21:02:27 +0000 Subject: * call.c (reference_binding): Use cp_build_qualified_type_real and cp_type_quals consistently. (add_function_candidate): Likewise. (build_conditional_expr): Likewise. (convert_like_real): Likewise. (type_passed_as): Likewise. * class.c (add_method): Likewise. (same_signature_p): Likewise. (layout_class_type): Likewise. * decl.c (cxx_init_decl_processing): Likewise. (cp_fname_init): Likewise. (grokdeclarator): Likewise. * decl2.c (cp_reconstruct_complex_type): Likewise. * init.c (build_new_1): Likewise. * method.c (do_build_copy_constructor): Likewise. (implicitly_declare_fn): Likewise. * pt.c (tsubst_aggr_type): Likewise. (tsubst): Likewise. * rtti.c (init_rtti_processing): Likewise. (build_headof): Likewise. (build_dynamic_cast_1): Likewise. (tinfo_base_init): Likewise. (emit_support_tinfos): Likewise. * semantics.c (capture_decltype): Likewise. * tree.c (cv_unqualified): Likewise. * typeck.c (composite_pointer_type): Likewise. (string_conv_p): Likewise. * mangle.c (write_CV_qualifiers_for_type): Tweak. * call.c (initialize_reference): Use CP_TYPE_CONST_P. * decl.c (start_decl): Likewise. * semantics.c (finish_compound_literal): Likewise. * typeck.c (check_return_expr): Use CP_TYPE_VOLATILE_P. (cp_type_readonly): Remove. * cp-tree.h: Remove declaration. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159599 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 88db80faae8..748e1b33b60 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1048,8 +1048,8 @@ add_method (tree type, tree method, tree using_decl) && ! DECL_STATIC_FUNCTION_P (method) && TREE_TYPE (TREE_VALUE (parms1)) != error_mark_node && TREE_TYPE (TREE_VALUE (parms2)) != error_mark_node - && (TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms1))) - != TYPE_QUALS (TREE_TYPE (TREE_VALUE (parms2))))) + && (cp_type_quals (TREE_TYPE (TREE_VALUE (parms1))) + != cp_type_quals (TREE_TYPE (TREE_VALUE (parms2))))) continue; /* For templates, the return type and template parameters @@ -1868,8 +1868,8 @@ same_signature_p (const_tree fndecl, const_tree base_fndecl) tree types, base_types; types = TYPE_ARG_TYPES (TREE_TYPE (fndecl)); base_types = TYPE_ARG_TYPES (TREE_TYPE (base_fndecl)); - if ((TYPE_QUALS (TREE_TYPE (TREE_VALUE (base_types))) - == TYPE_QUALS (TREE_TYPE (TREE_VALUE (types)))) + if ((cp_type_quals (TREE_TYPE (TREE_VALUE (base_types))) + == cp_type_quals (TREE_TYPE (TREE_VALUE (types)))) && compparms (TREE_CHAIN (base_types), TREE_CHAIN (types))) return 1; } @@ -5102,7 +5102,7 @@ layout_class_type (tree t, tree *virtuals_p) TYPE_UNSIGNED (ftype)); TREE_TYPE (field) = cp_build_qualified_type (TREE_TYPE (field), - TYPE_QUALS (ftype)); + cp_type_quals (ftype)); } } -- cgit v1.2.1 From c4b9c21a2470c2d1d1cca1577a802531752ab067 Mon Sep 17 00:00:00 2001 From: steven Date: Tue, 25 May 2010 18:14:23 +0000 Subject: gcc/ChangeLog: * Makefile.in (EXCEPT_H): Fix typo. objc/ChangeLog: * objc-act.h: Do not include gimple.h. * objc-act.c: Do not include rtl.h, expr.h, libfuncs.h, and tm_p.h. Include gimple.h. Explain why except.h has to be included. * objc-lang.c: Do not include diagnostics.h. * Make-lang.in: Update dependencies. objcp/ChangeLog: * objcp-decl.c: Do not include tm.h, rtl.h, expr.h, c-common.h, flags.h, input.h, except.h, output.h, toplev.h, cpplib.h, debug.h, and target.h. * objcp-lang.c: Do not include tm.h, toplev.h, diagnostics.h, and debug.h. Explain why except.h has to be included. * Make-lang.in: Update dependencies. cp/ChangeLog: * cp-tree.h: Do not include splay-tree.h. (struct prtmem_cst): Remove unused field and false comment. * typeck.c: Do not include rtl.h, expr.h, and tm_p.h. * optimize.c: Do not inclde rtl.h, insn-config.h, and integrate.h. * init.c: Do not include rtl.h and expr.h. * class.c: Do not include rtl.h. Include splay-tree.h. (build_clone): Use plain NULL instead of NULL_RTX. * decl.c: Do not include expr.h. Explain why rtl.h has to be included. Include splay-tree.h. * method.c: Do not include rtl.h and expr.h. (use_thunk): Use plain NULL instead of NULL_RTX. * except.c: Do not include rtl.h, expr.h, and libfuncs.h. * tree.c: Do not include rtl.h, insn-config.h, integrate.h, and target.h. Include splay-tree.h. * expr.c: Do not include rtl.h and expr.h. * pt.c: Do not include obstack.h and rtl.h. (tsubst_friend_function): Use plain NULL instead of NULL_RTX. (tsubst_decl): Likewise. (instantiate_decl): Likewise. * semantics.c: Do not include exprt.h and debug.h. Explain why rtl.h has to be included. * decl2.c: Do not include rtl.h and expr.h. Include splay-tree.h. * call.c: Do not include rtl.h and expr.h. * search.c: Do not include obstack.h and rtl.h. * friend.c: Do not include rtl.h and expr.h. * Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159839 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 748e1b33b60..523f401e868 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -30,13 +30,13 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "cp-tree.h" #include "flags.h" -#include "rtl.h" #include "output.h" #include "toplev.h" #include "target.h" #include "convert.h" #include "cgraph.h" #include "tree-dump.h" +#include "splay-tree.h" /* The number of nested classes being processed. If we are not in the scope of any class, this is zero. */ @@ -3955,7 +3955,7 @@ build_clone (tree fn, tree name) } /* Create the RTL for this function. */ - SET_DECL_RTL (clone, NULL_RTX); + SET_DECL_RTL (clone, NULL); rest_of_decl_compilation (clone, /*top_level=*/1, at_eof); if (pch_file) -- cgit v1.2.1 From 890d0caa48695c5fb7ac1981126cf32fa892c244 Mon Sep 17 00:00:00 2001 From: ktietz Date: Thu, 27 May 2010 08:13:58 +0000 Subject: gcc/cp/ 2010-05-27 Kai Tietz PR bootstrap/44287 * rtti.c (emit_support_tinfos): Check for NULL_TREE. * class.c (layout_class_type): Likewise. * decl.c (finish_enum): Likewise. * mangle.c (write_builitin_type): Likewise. gcc/ 2010-05-27 Kai Tietz PR bootstrp/44287 * c-lex.c (narrowest_unsigned_type): Check for NULL_TREE. (narrow_signed_type): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159912 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 523f401e868..c2831c1a485 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4975,14 +4975,19 @@ layout_class_type (tree t, tree *virtuals_p) of the field. Then, we are supposed to use the left over bits as additional padding. */ for (itk = itk_char; itk != itk_none; ++itk) - if (INT_CST_LT (DECL_SIZE (field), - TYPE_SIZE (integer_types[itk]))) + if (integer_types[itk] != NULL_TREE + && INT_CST_LT (DECL_SIZE (field), + TYPE_SIZE (integer_types[itk]))) break; /* ITK now indicates a type that is too large for the field. We have to back up by one to find the largest type that fits. */ - integer_type = integer_types[itk - 1]; + do + { + --itk; + integer_type = integer_types[itk]; + } while (itk > 0 && integer_type == NULL_TREE); /* Figure out how much additional padding is required. GCC 3.2 always created a padding field, even if it had zero -- cgit v1.2.1 From b2e48750cfa8c75c101a37264e58056d2663cac3 Mon Sep 17 00:00:00 2001 From: hjl Date: Thu, 3 Jun 2010 16:36:22 +0000 Subject: Check MAX_FIXED_MODE_SIZE on bit-field in C++. gcc/ada/ 2010-06-03 H.J. Lu PR c++/44294 * gcc-interface/decl.c (MAX_FIXED_MODE_SIZE): Removed. gcc/cp/ 2010-06-03 H.J. Lu PR c++/44294 * class.c (layout_class_type): Check MAX_FIXED_MODE_SIZE on bit-field. gcc/ 2010-06-03 H.J. Lu PR c++/44294 * defaults.h (MAX_FIXED_MODE_SIZE): New. * stor-layout.c (MAX_FIXED_MODE_SIZE): Removed. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160229 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c2831c1a485..69064a6242c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4976,8 +4976,10 @@ layout_class_type (tree t, tree *virtuals_p) bits as additional padding. */ for (itk = itk_char; itk != itk_none; ++itk) if (integer_types[itk] != NULL_TREE - && INT_CST_LT (DECL_SIZE (field), - TYPE_SIZE (integer_types[itk]))) + && (INT_CST_LT (size_int (MAX_FIXED_MODE_SIZE), + TYPE_SIZE (integer_types[itk])) + || INT_CST_LT (DECL_SIZE (field), + TYPE_SIZE (integer_types[itk])))) break; /* ITK now indicates a type that is too large for the -- cgit v1.2.1 From eb26f8645c9a98035be477434cf87519560a2e7d Mon Sep 17 00:00:00 2001 From: froydnj Date: Thu, 3 Jun 2010 20:46:04 +0000 Subject: * class.c (struct vtbl_init_data_s): Remove last_init field. (struct secondary_vptr_vtt_init_data_s): Change type of inits field to a VEC. (finish_vtbls): Use a VEC rather than a TREE_LIST for the accumulated initializers. (build_vtt): Likewise. (initialize_vtable): Take a VEC instead of a tree. (build_vtt_inits): Change return type to void. Take a VEC ** instead of a tree *; accumulate results into said VEC. (build_ctor_vtbl_group): Use a VEC rather than a TREE_LIST for the accumulated initializers. Pass the vtable to accumulate_vtbl_inits. (accumulate_vtbl_inits): Add extra vtable tree parameter; take a VEC instead of a tree. (dfs_accumulate_vtbl_inits): Likewise. Change return type to void. (build_vtbl_initializer): Add VEC parameter; accumulate initializers into it. (dfs_build_secondary_vptr_vtt_inits): Use CONSTRUCTOR_APPEND_ELT rather than tree_cons. (build_vbase_offset_vtbl_entries): Likewise. (add_vcall_offset): Likewise. (build_rtti_vtbl_entries): Likewise. * cp-tree.h (initialize_artificial_var): Take a VEC instead of a tree. * decl.c (initialize_artificial_var): Use build_constructor instead of build_constructor_from_list. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160233 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 224 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 109 insertions(+), 115 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 69064a6242c..2ee779299fe 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -77,9 +77,7 @@ typedef struct vtbl_init_data_s tree rtti_binfo; /* The negative-index vtable initializers built up so far. These are in order from least negative index to most negative index. */ - tree inits; - /* The last (i.e., most negative) entry in INITS. */ - tree* last_init; + VEC(constructor_elt,gc) *inits; /* The binfo for the virtual base for which we're building vcall offset initializers. */ tree vbase; @@ -136,7 +134,8 @@ static void add_implicitly_declared_members (tree, int, int); static tree fixed_type_or_null (tree, int *, int *); static tree build_simple_base_path (tree expr, tree binfo); static tree build_vtbl_ref_1 (tree, tree); -static tree build_vtbl_initializer (tree, tree, tree, tree, int *); +static void build_vtbl_initializer (tree, tree, tree, tree, int *, + VEC(constructor_elt,gc) **); static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); static bool check_bitfield_decl (tree); @@ -173,14 +172,15 @@ static void dump_vtable (tree, tree, tree); static void dump_vtt (tree, tree); static void dump_thunk (FILE *, int, tree); static tree build_vtable (tree, tree, tree); -static void initialize_vtable (tree, tree); +static void initialize_vtable (tree, VEC(constructor_elt,gc) *); static void layout_nonempty_base_or_field (record_layout_info, tree, tree, splay_tree); static tree end_of_class (tree, int); static bool layout_empty_base (record_layout_info, tree, tree, splay_tree); -static void accumulate_vtbl_inits (tree, tree, tree, tree, tree); -static tree dfs_accumulate_vtbl_inits (tree, tree, tree, tree, - tree); +static void accumulate_vtbl_inits (tree, tree, tree, tree, tree, + VEC(constructor_elt,gc) **); +static void dfs_accumulate_vtbl_inits (tree, tree, tree, tree, tree, + VEC(constructor_elt,gc) **); static void build_rtti_vtbl_entries (tree, vtbl_init_data *); static void build_vcall_and_vbase_vtbl_entries (tree, vtbl_init_data *); static void clone_constructors_and_destructors (tree); @@ -189,7 +189,7 @@ static void update_vtable_entry_for_fn (tree, tree, tree, tree *, unsigned); static void build_ctor_vtbl_group (tree, tree); static void build_vtt (tree); static tree binfo_ctor_vtable (tree); -static tree *build_vtt_inits (tree, tree, tree *, tree *); +static void build_vtt_inits (tree, tree, VEC(constructor_elt,gc) **, tree *); static tree dfs_build_secondary_vptr_vtt_inits (tree, void *); static tree dfs_fixup_binfo_vtbls (tree, void *); static int record_subobject_offset (tree, tree, splay_tree); @@ -7042,36 +7042,36 @@ debug_thunks (tree fn) static void finish_vtbls (tree t) { - tree list; tree vbase; + VEC(constructor_elt,gc) *v = NULL; + tree vtable = BINFO_VTABLE (TYPE_BINFO (t)); /* We lay out the primary and secondary vtables in one contiguous vtable. The primary vtable is first, followed by the non-virtual secondary vtables in inheritance graph order. */ - list = build_tree_list (BINFO_VTABLE (TYPE_BINFO (t)), NULL_TREE); - accumulate_vtbl_inits (TYPE_BINFO (t), TYPE_BINFO (t), - TYPE_BINFO (t), t, list); + accumulate_vtbl_inits (TYPE_BINFO (t), TYPE_BINFO (t), TYPE_BINFO (t), + vtable, t, &v); /* Then come the virtual bases, also in inheritance graph order. */ for (vbase = TYPE_BINFO (t); vbase; vbase = TREE_CHAIN (vbase)) { if (!BINFO_VIRTUAL_P (vbase)) continue; - accumulate_vtbl_inits (vbase, vbase, TYPE_BINFO (t), t, list); + accumulate_vtbl_inits (vbase, vbase, TYPE_BINFO (t), vtable, t, &v); } if (BINFO_VTABLE (TYPE_BINFO (t))) - initialize_vtable (TYPE_BINFO (t), TREE_VALUE (list)); + initialize_vtable (TYPE_BINFO (t), v); } /* Initialize the vtable for BINFO with the INITS. */ static void -initialize_vtable (tree binfo, tree inits) +initialize_vtable (tree binfo, VEC(constructor_elt,gc) *inits) { tree decl; - layout_vtable_decl (binfo, list_length (inits)); + layout_vtable_decl (binfo, VEC_length (constructor_elt, inits)); decl = get_vtbl_decl_for_binfo (binfo); initialize_artificial_var (decl, inits); dump_vtable (BINFO_TYPE (binfo), binfo, decl); @@ -7093,13 +7093,13 @@ initialize_vtable (tree binfo, tree inits) static void build_vtt (tree t) { - tree inits; tree type; tree vtt; tree index; + VEC(constructor_elt,gc) *inits; /* Build up the initializers for the VTT. */ - inits = NULL_TREE; + inits = NULL; index = size_zero_node; build_vtt_inits (TYPE_BINFO (t), t, &inits, &index); @@ -7108,7 +7108,7 @@ build_vtt (tree t) return; /* Figure out the type of the VTT. */ - type = build_index_type (size_int (list_length (inits) - 1)); + type = build_index_type (size_int (VEC_length (constructor_elt, inits) - 1)); type = build_cplus_array_type (const_ptr_type_node, type); /* Now, build the VTT object itself. */ @@ -7154,8 +7154,8 @@ typedef struct secondary_vptr_vtt_init_data_s /* Current index into the VTT. */ tree index; - /* TREE_LIST of initializers built up. */ - tree inits; + /* Vector of initializers built up. */ + VEC(constructor_elt,gc) *inits; /* The type being constructed by this secondary VTT. */ tree type_being_constructed; @@ -7169,19 +7169,18 @@ typedef struct secondary_vptr_vtt_init_data_s for virtual bases of T. When it is not so, we build the constructor vtables for the BINFO-in-T variant. */ -static tree * -build_vtt_inits (tree binfo, tree t, tree *inits, tree *index) +static void +build_vtt_inits (tree binfo, tree t, VEC(constructor_elt,gc) **inits, tree *index) { int i; tree b; tree init; - tree secondary_vptrs; secondary_vptr_vtt_init_data data; int top_level_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t); /* We only need VTTs for subobjects with virtual bases. */ if (!CLASSTYPE_VBASECLASSES (BINFO_TYPE (binfo))) - return inits; + return; /* We need to use a construction vtable if this is not the primary VTT. */ @@ -7195,8 +7194,7 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index) /* Add the address of the primary vtable for the complete object. */ init = binfo_ctor_vtable (binfo); - *inits = build_tree_list (NULL_TREE, init); - inits = &TREE_CHAIN (*inits); + CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, init); if (top_level_p) { gcc_assert (!BINFO_VPTR_INDEX (binfo)); @@ -7207,30 +7205,23 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index) /* Recursively add the secondary VTTs for non-virtual bases. */ for (i = 0; BINFO_BASE_ITERATE (binfo, i, b); ++i) if (!BINFO_VIRTUAL_P (b)) - inits = build_vtt_inits (b, t, inits, index); + build_vtt_inits (b, t, inits, index); /* Add secondary virtual pointers for all subobjects of BINFO with either virtual bases or reachable along a virtual path, except subobjects that are non-virtual primary bases. */ data.top_level_p = top_level_p; data.index = *index; - data.inits = NULL; + data.inits = *inits; data.type_being_constructed = BINFO_TYPE (binfo); dfs_walk_once (binfo, dfs_build_secondary_vptr_vtt_inits, NULL, &data); *index = data.index; - /* The secondary vptrs come back in reverse order. After we reverse - them, and add the INITS, the last init will be the first element - of the chain. */ - secondary_vptrs = data.inits; - if (secondary_vptrs) - { - *inits = nreverse (secondary_vptrs); - inits = &TREE_CHAIN (secondary_vptrs); - gcc_assert (*inits == NULL_TREE); - } + /* data.inits might have grown as we added secondary virtual pointers. + Make sure our caller knows about the new vector. */ + *inits = data.inits; if (top_level_p) /* Add the secondary VTTs for virtual bases in inheritance graph @@ -7240,13 +7231,11 @@ build_vtt_inits (tree binfo, tree t, tree *inits, tree *index) if (!BINFO_VIRTUAL_P (b)) continue; - inits = build_vtt_inits (b, t, inits, index); + build_vtt_inits (b, t, inits, index); } else /* Remove the ctor vtables we created. */ dfs_walk_all (binfo, dfs_fixup_binfo_vtbls, NULL, binfo); - - return inits; } /* Called from build_vtt_inits via dfs_walk. BINFO is the binfo for the base @@ -7294,7 +7283,7 @@ dfs_build_secondary_vptr_vtt_inits (tree binfo, void *data_) } /* Add the initializer for the secondary vptr itself. */ - data->inits = tree_cons (NULL_TREE, binfo_ctor_vtable (binfo), data->inits); + CONSTRUCTOR_APPEND_ELT (data->inits, NULL_TREE, binfo_ctor_vtable (binfo)); /* Advance the vtt index. */ data->index = size_binop (PLUS_EXPR, data->index, @@ -7337,12 +7326,11 @@ dfs_fixup_binfo_vtbls (tree binfo, void* data) static void build_ctor_vtbl_group (tree binfo, tree t) { - tree list; tree type; tree vtbl; - tree inits; tree id; tree vbase; + VEC(constructor_elt,gc) *v; /* See if we've already created this construction vtable group. */ id = mangle_ctor_vtbl_for_type (t, binfo); @@ -7355,9 +7343,10 @@ build_ctor_vtbl_group (tree binfo, tree t) construction vtable group. */ vtbl = build_vtable (t, id, ptr_type_node); DECL_CONSTRUCTION_VTABLE_P (vtbl) = 1; - list = build_tree_list (vtbl, NULL_TREE); + + v = NULL; accumulate_vtbl_inits (binfo, TYPE_BINFO (TREE_TYPE (binfo)), - binfo, t, list); + binfo, vtbl, t, &v); /* Add the vtables for each of our virtual bases using the vbase in T binfo. */ @@ -7371,12 +7360,11 @@ build_ctor_vtbl_group (tree binfo, tree t) continue; b = copied_binfo (vbase, binfo); - accumulate_vtbl_inits (b, vbase, binfo, t, list); + accumulate_vtbl_inits (b, vbase, binfo, vtbl, t, &v); } - inits = TREE_VALUE (list); /* Figure out the type of the construction vtable. */ - type = build_index_type (size_int (list_length (inits) - 1)); + type = build_index_type (size_int (VEC_length (constructor_elt, v) - 1)); type = build_cplus_array_type (vtable_entry_type, type); layout_type (type); TREE_TYPE (vtbl) = type; @@ -7385,7 +7373,7 @@ build_ctor_vtbl_group (tree binfo, tree t) /* Initialize the construction vtable. */ CLASSTYPE_VTABLES (t) = chainon (CLASSTYPE_VTABLES (t), vtbl); - initialize_artificial_var (vtbl, inits); + initialize_artificial_var (vtbl, v); dump_vtable (t, binfo, vtbl); } @@ -7403,8 +7391,9 @@ static void accumulate_vtbl_inits (tree binfo, tree orig_binfo, tree rtti_binfo, + tree vtbl, tree t, - tree inits) + VEC(constructor_elt,gc) **inits) { int i; tree base_binfo; @@ -7424,10 +7413,7 @@ accumulate_vtbl_inits (tree binfo, return; /* Build the initializers for the BINFO-in-T vtable. */ - TREE_VALUE (inits) - = chainon (TREE_VALUE (inits), - dfs_accumulate_vtbl_inits (binfo, orig_binfo, - rtti_binfo, t, inits)); + dfs_accumulate_vtbl_inits (binfo, orig_binfo, rtti_binfo, vtbl, t, inits); /* Walk the BINFO and its bases. We walk in preorder so that as we initialize each vtable we can figure out at what offset the @@ -7441,24 +7427,25 @@ accumulate_vtbl_inits (tree binfo, continue; accumulate_vtbl_inits (base_binfo, BINFO_BASE_BINFO (orig_binfo, i), - rtti_binfo, t, + rtti_binfo, vtbl, t, inits); } } -/* Called from accumulate_vtbl_inits. Returns the initializers for - the BINFO vtable. */ +/* Called from accumulate_vtbl_inits. Adds the initializers for the + BINFO vtable to L. */ -static tree +static void dfs_accumulate_vtbl_inits (tree binfo, tree orig_binfo, tree rtti_binfo, + tree orig_vtbl, tree t, - tree l) + VEC(constructor_elt,gc) **l) { - tree inits = NULL_TREE; tree vtbl = NULL_TREE; int ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t); + int n_inits; if (ctor_vtbl_p && BINFO_VIRTUAL_P (orig_binfo) && BINFO_PRIMARY_P (orig_binfo)) @@ -7512,23 +7499,24 @@ dfs_accumulate_vtbl_inits (tree binfo, /* Otherwise, this is case 3 and we get our own. */ } else if (!BINFO_NEW_VTABLE_MARKED (orig_binfo)) - return inits; + return; + + n_inits = VEC_length (constructor_elt, *l); if (!vtbl) { tree index; int non_fn_entries; - /* Compute the initializer for this vtable. */ - inits = build_vtbl_initializer (binfo, orig_binfo, t, rtti_binfo, - &non_fn_entries); + /* Add the initializer for this vtable. */ + build_vtbl_initializer (binfo, orig_binfo, t, rtti_binfo, + &non_fn_entries, l); /* Figure out the position to which the VPTR should point. */ - vtbl = TREE_PURPOSE (l); - vtbl = build1 (ADDR_EXPR, vtbl_ptr_type_node, vtbl); + vtbl = build1 (ADDR_EXPR, vtbl_ptr_type_node, orig_vtbl); index = size_binop (PLUS_EXPR, size_int (non_fn_entries), - size_int (list_length (TREE_VALUE (l)))); + size_int (n_inits)); index = size_binop (MULT_EXPR, TYPE_SIZE_UNIT (vtable_entry_type), index); @@ -7541,12 +7529,11 @@ dfs_accumulate_vtbl_inits (tree binfo, straighten this out. */ BINFO_VTABLE (binfo) = tree_cons (rtti_binfo, vtbl, BINFO_VTABLE (binfo)); else if (BINFO_PRIMARY_P (binfo) && BINFO_VIRTUAL_P (binfo)) - inits = NULL_TREE; + /* Throw away any unneeded intializers. */ + VEC_truncate (constructor_elt, *l, n_inits); else /* For an ordinary vtable, set BINFO_VTABLE. */ BINFO_VTABLE (binfo) = vtbl; - - return inits; } static GTY(()) tree abort_fndecl_addr; @@ -7574,26 +7561,26 @@ static GTY(()) tree abort_fndecl_addr; primary bases; we need these while the primary base is being constructed. */ -static tree +static void build_vtbl_initializer (tree binfo, tree orig_binfo, tree t, tree rtti_binfo, - int* non_fn_entries_p) + int* non_fn_entries_p, + VEC(constructor_elt,gc) **inits) { tree v, b; - tree vfun_inits; vtbl_init_data vid; - unsigned ix; + unsigned ix, jx; tree vbinfo; VEC(tree,gc) *vbases; + constructor_elt *e; /* Initialize VID. */ memset (&vid, 0, sizeof (vid)); vid.binfo = binfo; vid.derived = t; vid.rtti_binfo = rtti_binfo; - vid.last_init = &vid.inits; vid.primary_vtbl_p = SAME_BINFO_TYPE_P (BINFO_TYPE (binfo), t); vid.ctor_vtbl_p = !SAME_BINFO_TYPE_P (BINFO_TYPE (rtti_binfo), t); vid.generate_vcall_entries = true; @@ -7619,28 +7606,51 @@ build_vtbl_initializer (tree binfo, /* If the target requires padding between data entries, add that now. */ if (TARGET_VTABLE_DATA_ENTRY_DISTANCE > 1) { - tree cur, *prev; + int n_entries = VEC_length (constructor_elt, vid.inits); + + VEC_safe_grow (constructor_elt, gc, vid.inits, + TARGET_VTABLE_DATA_ENTRY_DISTANCE * n_entries); - for (prev = &vid.inits; (cur = *prev); prev = &TREE_CHAIN (cur)) + /* Move data entries into their new positions and add padding + after the new positions. Iterate backwards so we don't + overwrite entries that we would need to process later. */ + for (ix = n_entries - 1; + VEC_iterate (constructor_elt, vid.inits, ix, e); + ix--) { - tree add = cur; - int i; + int j; + int new_position = TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix; + + VEC_replace (constructor_elt, vid.inits, new_position, e); - for (i = 1; i < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++i) - add = tree_cons (NULL_TREE, - build1 (NOP_EXPR, vtable_entry_type, - null_pointer_node), - add); - *prev = add; + for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j) + { + constructor_elt *f = VEC_index (constructor_elt, *inits, + new_position + j); + f->index = NULL_TREE; + f->value = build1 (NOP_EXPR, vtable_entry_type, + null_pointer_node); + } } } if (non_fn_entries_p) - *non_fn_entries_p = list_length (vid.inits); + *non_fn_entries_p = VEC_length (constructor_elt, vid.inits); + + /* The initializers for virtual functions were built up in reverse + order. Straighten them out and add them to the running list in one + step. */ + jx = VEC_length (constructor_elt, *inits); + VEC_safe_grow (constructor_elt, gc, *inits, + (jx + VEC_length (constructor_elt, vid.inits))); + + for (ix = VEC_length (constructor_elt, vid.inits) - 1; + VEC_iterate (constructor_elt, vid.inits, ix, e); + ix--, jx++) + VEC_replace (constructor_elt, *inits, jx, e); /* Go through all the ordinary virtual functions, building up initializers. */ - vfun_inits = NULL_TREE; for (v = BINFO_VIRTUALS (orig_binfo); v; v = TREE_CHAIN (v)) { tree delta; @@ -7726,7 +7736,7 @@ build_vtbl_initializer (tree binfo, int i; if (init == size_zero_node) for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) - vfun_inits = tree_cons (NULL_TREE, init, vfun_inits); + CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, init); else for (i = 0; i < TARGET_VTABLE_USES_DESCRIPTORS; ++i) { @@ -7735,22 +7745,12 @@ build_vtbl_initializer (tree binfo, build_int_cst (NULL_TREE, i)); TREE_CONSTANT (fdesc) = 1; - vfun_inits = tree_cons (NULL_TREE, fdesc, vfun_inits); + CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, fdesc); } } else - vfun_inits = tree_cons (NULL_TREE, init, vfun_inits); + CONSTRUCTOR_APPEND_ELT (*inits, NULL_TREE, init); } - - /* The initializers for virtual functions were built up in reverse - order; straighten them out now. */ - vfun_inits = nreverse (vfun_inits); - - /* The negative offset initializers are also in reverse order. */ - vid.inits = nreverse (vid.inits); - - /* Chain the two together. */ - return chainon (vid.inits, vfun_inits); } /* Adds to vid->inits the initializers for the vbase and vcall @@ -7860,12 +7860,9 @@ build_vbase_offset_vtbl_entries (tree binfo, vtbl_init_data* vid) delta = size_diffop_loc (input_location, BINFO_OFFSET (b), BINFO_OFFSET (non_primary_binfo)); - *vid->last_init - = build_tree_list (NULL_TREE, - fold_build1_loc (input_location, NOP_EXPR, - vtable_entry_type, - delta)); - vid->last_init = &TREE_CHAIN (*vid->last_init); + CONSTRUCTOR_APPEND_ELT (vid->inits, NULL_TREE, + fold_build1_loc (input_location, NOP_EXPR, + vtable_entry_type, delta)); } } @@ -8100,8 +8097,7 @@ add_vcall_offset (tree orig_fn, tree binfo, vtbl_init_data *vid) vcall_offset); } /* Add the initializer to the vtable. */ - *vid->last_init = build_tree_list (NULL_TREE, vcall_offset); - vid->last_init = &TREE_CHAIN (*vid->last_init); + CONSTRUCTOR_APPEND_ELT (vid->inits, NULL_TREE, vcall_offset); } } @@ -8145,15 +8141,13 @@ build_rtti_vtbl_entries (tree binfo, vtbl_init_data* vid) /* Convert the declaration to a type that can be stored in the vtable. */ init = build_nop (vfunc_ptr_type_node, decl); - *vid->last_init = build_tree_list (NULL_TREE, init); - vid->last_init = &TREE_CHAIN (*vid->last_init); + CONSTRUCTOR_APPEND_ELT (vid->inits, NULL_TREE, init); /* Add the offset-to-top entry. It comes earlier in the vtable than the typeinfo entry. Convert the offset to look like a function pointer, so that we can put it in the vtable. */ init = build_nop (vfunc_ptr_type_node, offset); - *vid->last_init = build_tree_list (NULL_TREE, init); - vid->last_init = &TREE_CHAIN (*vid->last_init); + CONSTRUCTOR_APPEND_ELT (vid->inits, NULL_TREE, init); } /* Fold a OBJ_TYPE_REF expression to the address of a function. -- cgit v1.2.1 From 892e7b037a7ac749cd787f2a91bd9041cd221202 Mon Sep 17 00:00:00 2001 From: fabien Date: Sun, 6 Jun 2010 09:35:45 +0000 Subject: Fix PR c++/44086 git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160337 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 2ee779299fe..c6da4cd28bb 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3092,6 +3092,14 @@ check_field_decls (tree t, tree *access_decls, if (! zero_init_p (type)) CLASSTYPE_NON_ZERO_INIT_P (t) = 1; + /* We set DECL_C_BIT_FIELD in grokbitfield. + If the type and width are valid, we'll also set DECL_BIT_FIELD. */ + if (! DECL_C_BIT_FIELD (x) || ! check_bitfield_decl (x)) + check_field_decl (x, t, + cant_have_const_ctor_p, + no_const_asn_ref_p, + &any_default_members); + /* If any field is const, the structure type is pseudo-const. */ if (CP_TYPE_CONST_P (type)) { @@ -3120,14 +3128,6 @@ check_field_decls (tree t, tree *access_decls, if (constructor_name_p (DECL_NAME (x), t) && TYPE_HAS_USER_CONSTRUCTOR (t)) permerror (input_location, "field %q+#D with same name as class", x); - - /* We set DECL_C_BIT_FIELD in grokbitfield. - If the type and width are valid, we'll also set DECL_BIT_FIELD. */ - if (! DECL_C_BIT_FIELD (x) || ! check_bitfield_decl (x)) - check_field_decl (x, t, - cant_have_const_ctor_p, - no_const_asn_ref_p, - &any_default_members); } /* Effective C++ rule 11: if a class has dynamic memory held by pointers, -- cgit v1.2.1 From ba72912a012b97cad825eebee3f5f22253d0afe4 Mon Sep 17 00:00:00 2001 From: lauras Date: Tue, 8 Jun 2010 07:25:24 +0000 Subject: gcc/ada: 2010-06-08 Laurynas Biveinis * gcc-interface/utils.c (init_gnat_to_gnu): Use typed GC allocation. (init_dummy_type): Likewise. (gnat_pushlevel): Likewise. * gcc-interface/trans.c (Attribute_to_gnu): Likewise. (Subprogram_Body_to_gnu): Likewise. (Compilation_Unit_to_gnu): Likewise. (start_stmt_group): Likewise. (extract_encoding): Likewise. (decode_name): Likewise. * gcc-interface/misc.c (gnat_printable_name): Likewise. * gcc-interface/decl.c (annotate_value): Likewise. * gcc-interface/ada-tree.h (struct lang_type): Add variable_size GTY option. (struct lang_decl): Likewise. (SET_TYPE_LANG_SPECIFIC): Use typed GC allocation. (SET_DECL_LANG_SPECIFIC): Likewise. gcc/c-family: 2010-06-08 Laurynas Biveinis * c-pragma.c (push_alignment): Use typed GC allocation. (handle_pragma_push_options): Likewise. * c-common.c (parse_optimize_options): Likewise. * c-common.h (struct sorted_fields_type): Add variable_size GTY option. gcc/cp: 2010-06-08 Laurynas Biveinis * typeck2.c (abstract_virtuals_error): Likewise. * pt.c (maybe_process_partial_specialization): Likewise. (register_specialization): Likewise. (add_pending_template): Likewise. (lookup_template_class): Likewise. (push_tinst_level): Likewise. * parser.c (cp_lexer_new_main): Likewise. (cp_lexer_new_from_tokens): Likewise. (cp_token_cache_new): Likewise. (cp_parser_context_new): Likewise. (cp_parser_new): Likewise. (cp_parser_nested_name_specifier_opt): Likewise. (cp_parser_template_id): Likewise. * name-lookup.c (binding_entry_make): Likewise. (binding_table_construct): Likewise. (binding_table_new): Likewise. (cxx_binding_make): Likewise. (pushdecl_maybe_friend): Likewise. (begin_scope): Likewise. (push_to_top_level): Likewise. * lex.c (init_reswords): Likewise. (retrofit_lang_decl): Likewise. (cxx_dup_lang_specific_decl): Likewise. (copy_lang_type): Likewise. (cxx_make_type): Likewise. * decl.c (make_label_decl): Likewise. (check_goto): Likewise. (start_preparsed_function): Likewise. (save_function_data): Likewise. * cp-tree.h (TYPE_SET_PTRMEMFUNC_TYPE): Likewise. * cp-objcp-common.c (decl_shadowed_for_var_insert): Likewise. * class.c (finish_struct_1): Likewise. * cp-tree.h (struct lang_type): Add variable_size GTY option. (struct lang_decl): Likewise. * parser.c (cp_parser_new): Update comment to not reference ggc_alloc. gcc/fortran: 2010-06-08 Laurynas Biveinis * trans-types.c (gfc_get_nodesc_array_type): Use typed GC allocation. (gfc_get_array_type_bounds): Likewise. * trans-decl.c (gfc_allocate_lang_decl): Likewise. (gfc_find_module): Likewise. * f95-lang.c (pushlevel): Likewise. * trans.h (struct lang_type): Add variable_size GTY option. (struct lang_decl): Likewise. gcc/java: 2010-06-08 Laurynas Biveinis * jcf-reader.c (jcf_parse_constant_pool): Use typed GC allocation. * jcf-parse.c (java_parse_file): Likewise. (process_zip_dir): Likewise. * java-tree.h (MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC): Likewise. (MAYBE_CREATE_TYPE_TYPE_LANG_SPECIFIC): Likewise. * expr.c (add_type_assertion): Likewise. * decl.c (make_binding_level): Likewise. (java_dup_lang_specific_decl): Likewise. * constants.c (set_constant_entry): Likewise. (cpool_for_class): Likewise. * class.c (add_method_1): Likewise. (java_treetreehash_new): Likewise. * java-tree.h (struct lang_type): Add variable_size GTY option. (struct lang_decl): Likewise. * jch.h (struct cpool_entry): Likewise. * java-tree.h (java_treetreehash_create): Remove parameter ggc. * except.c (prepare_eh_table_type): Update java_treetreehash_create call. * class.c (add_method_1): Update java_treetreehash_create call. (java_treetreehash_create): Remove parameter gc. Use htab_create_ggc. gcc/lto: 2010-06-08 Laurynas Biveinis * lto.c (lto_read_in_decl_state): Use typed GC allocation. (lto_file_read): Likewise. (new_partition): Likewise. (read_cgraph_and_symbols): Likewise. gcc/objc: 2010-06-08 Laurynas Biveinis * objc-act.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC allocation. * objc-act.c (objc_volatilize_decl): Likewise. (objc_build_string_object): Likewise. (hash_init): Likewise. (hash_enter): Likewise. (hash_add_attr): Likewise. (add_class): Likewise. (start_class): Likewise. gcc/objcp: 2010-06-08 Laurynas Biveinis * objcp-decl.h (ALLOC_OBJC_TYPE_LANG_SPECIFIC): Use typed GC allocation. gcc: 2010-06-08 Laurynas Biveinis * doc/tm.texi (Per-Function Data): Do not reference ggc_alloc. * doc/gty.texi (GTY Options): Document typed GC allocation and variable_size GTY option. * ggc-internal.h: New. * ggc.h: Update copyright year. (digit_string): Move to stringpool.c. (ggc_mark_stringpool, ggc_purge_stringpool, ggc_mark_roots) (gt_pch_save_stringpool, gt_pch_fixup_stringpool) (gt_pach_restore_stringpool, gt_pch_p_S, gt_pch_note_object) (init_ggc_pch, ggc_pch_count_object, ggc_pch_total_size) (ggc_pch_this_base, ggc_pch_alloc_object, ggc_pch_prepare_write) (ggc_pch_write_object, ggc_pch_finish, ggc_pch_read) (ggc_force_collect, ggc_get_size, ggc_statistics) (ggc_print_common_statistics): Move to ggc-internal.h. (digit_vector, new_ggc_zone, destroy_ggc_zone, ggc_alloc_stat) (ggc_alloc, ggc_alloc_cleared, ggc_realloc, ggc_calloc, GGC_NEW) (GGC_CNEW, GGC_NEWVEC, GGC_CNEWVEC, GGC_NEWVAR, ggc_alloc_rtvec) (ggc_alloc_tree, gt_pch_save, ggc_min_expand_heuristic) (ggc_min_heapsize_heuristic, ggc_alloc_zone) (ggc_alloc_zone_pass_stat): Remove. (ggc_internal_alloc_stat, ggc_internal_alloc) (ggc_internal_cleared_alloc_stat): New. (GGC_RESIZEVEC, GGC_RESIZEVAR): Redefine. (ggc_internal_vec_alloc_stat) (ggc_internal_cleared_vec_alloc_stat) (ggc_internal_vec_alloc_stat, ggc_internal_cleared_vec_alloc) (ggc_alloc_atomic_stat, ggc_alloc_atomic) (ggc_alloc_cleared_atomic, ggc_cleared_alloc_htab_ignore_args) (ggc_cleared_alloc_ptr_array_two_args): New. (htab_create_ggc, splay_tree_new_ggc): Redefine. (ggc_splay_alloc): Change the type of the first argument to enum gt_types_enum. (ggc_alloc_string): Make macro. (ggc_alloc_string_stat): New. (ggc_strdup): Redefine. (rtl_zone, tree_zone, tree_id_zone): Declare unconditionally. (ggc_alloc_rtvec_sized): New. (ggc_alloc_zone_stat): Rename to ggc_internal_alloc_zone_stat. (ggc_internal_alloc_zone_pass_stat, ggc_internal_alloc_zone_stat) (ggc_internal_cleared_alloc_zone_stat) (ggc_internal_zone_alloc_stat) (ggc_internal_zone_cleared_alloc_stat) (ggc_internal_zone_vec_alloc_stat) (ggc_alloc_zone_rtx_def_stat) (ggc_alloc_zone_tree_node_stat) (ggc_alloc_zone_cleared_tree_node_stat) (ggc_alloc_cleared_gimple_statement_d_stat): New. * ggc-common.c: Include ggc-internal.h. (ggc_internal_cleared_alloc_stat): Rename from ggc_alloc_cleared_stat. (ggc_realloc_stat): Use ggc_internal_alloc_stat. (ggc_calloc): Remove. (ggc_cleared_alloc_htab_ignore_args): New. (ggc_cleared_alloc_ptr_array_two_args): New. (ggc_splay_alloc): Add obj_type parameter. (init_ggc_heuristics): Formatting fixes. * ggc-none.c: Update copyright year. (ggc_alloc_stat): Rename to ggc_alloc_stat. (ggc_alloc_cleared_stat): Rename to ggc_internal_cleared_alloc_stat. (struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New. * ggc-page.c: Update copyright year. Include ggc-internal.h. Remove references to ggc_alloc in comments. (ggc_alloc_typed_stat): Call ggc_internal_alloc_stat. (ggc_alloc_stat): Rename to ggc_internal_alloc_stat. (new_ggc_zone, destroy_ggc_zone): Remove. (struct alloc_zone, rtl_zone, tree_zone, tree_id_zone): New. * ggc-zone.c: Include ggc-internal.h. Remove references to ggc_alloc in comments. (ggc_alloc_zone_stat): ggc_internal_alloc_zone_stat. (ggc_internal_alloc_zone_pass_stat): New. (ggc_internal_cleared_alloc_zone_stat): New. (ggc_alloc_typed_stat): Use ggc_internal_alloc_zone_pass_stat. (ggc_alloc_stat): Rename ggc_internal_alloc_stat. (new_ggc_zone, destroy_ggc_zone): Remove. * stringpool.c: Update copyright year. Include ggc-internal.h (digit_vector): Make static. (digit_string): Moved from ggc.h. (stringpool_ggc_alloc): Use ggc_alloc_atomic. (ggc_alloc_string): Rename to ggc_alloc_string_stat. * Makefile.in (GGC_INTERNAL_H): New. (ggc_common.o, ggc-page.o, ggc-zone.o, stringpool.o): Add $(GGC_INTERNAL_H) to dependencies. * gentype.c: Update copyright year. (walk_type): Accept variable_size GTY option. (USED_BY_TYPED_GC_P): New macro. (write_enum_defn): Use USED_BY_TYPED_GC_P. Do not output whitespace at the end of strings. (get_type_specifier, variable_size_p): New functions. (alloc_quantity, alloc_zone): New enums. (write_typed_alloc_def): New function. (write_typed_struct_alloc_def): Likewise. (write_typed_typed_typedef_alloc_def): Likewise. (write_typed_alloc_defns): Likewise. (output_typename, write_splay_tree_allocator_def): Likewise. (write_splay_tree_allocators): Likewise. (main): Call write_typed_alloc_defns and write_splay_tree_allocators. * lto-streamer.h (lto_file_decl_data_ptr): New. * passes.c (order): Define using cgraph_node_ptr. * strinpool.c (struct string_pool_data): Declare nested_ptr using ht_identifier_ptr. * gimple.h (union gimple_statement_d): Likewise. * rtl.h (struct rtx_def): Likewise. (struct rtvec_def): Likewise. * tree.h (union tree_node): Likewise. * tree-ssa-operands.h (struct ssa_operand_memory_d): Likewise. * cfgloop.c (record_loop_exits): Use htab_create_ggc. * tree-scalar-evolution.c (scev_initialize): Likewise. * alias.c (record_alias_subset): Update splay_tree_new_ggc call. * dwarf2asm.c (dw2_force_const_mem): Likewise. * omp-low.c (lower_omp_critical): Likewise. * bitmap.h (struct bitmap_head_def): Update comment to not reference ggc_alloc. * config/pa/pa.c (get_deferred_label): Use GGC_RESIZEVEC. * ira.c (fix_reg_equiv_init): Use GGC_RESIZEVEC. * ipa-prop.c (duplicate_ggc_array): Rename to duplicate_ipa_jump_func_array. Use typed GC allocation. (ipa_edge_duplication_hook): Call duplicate_ipa_jump_func_array. * gimple.c (gimple_alloc_stat): Use ggc_alloc_cleared_gimple_statement_d_stat. * varasm.c (create_block_symbol): Use ggc_alloc_zone_rtx_def. * tree.c (make_node_stat): Use ggc_alloc_zone_cleared_tree_node_stat. (make_tree_vec_stat): Likewise. (build_vl_exp_stat): Likewise. (copy_node_stat): Use ggc_alloc_zone_tree_node_stat. (make_tree_binfo_stat): Likewise. (tree_cons_stat): Likewise. * rtl.c (rtx_alloc_stat): Use ggc_alloc_zone_rtx_def_stat. (shallow_copy_rtx_stat): Likewise. (make_node_stat): Likewise. * lto-symtab.c: Fix comment. * tree-cfg.c (create_bb): Update comment to not reference ggc_alloc_cleared. * tree-ssa-structalias.c (struct heapvar_for_stmt): Fix param_is value. * varpool.c (varpool_node): Use typed GC allocation. (varpool_extra_name_alias): Likewise. * varasm.c (emutls_decl): Likewise. (get_unnamed_section): Likewise. (get_noswitch_section): Likewise. (get_section): Likewise. (get_block_for_section): Likewise. (build_constant_desc): Likewise. (create_constant_pool): Likewise. (force_const_mem): Likewise. * tree.c (build_vl_exp_stat): Likewise. (build_real): Likewise. (build_string): Likewise. (decl_debug_expr_insert): Likewise. (decl_value_expr_insert): Likewise. (type_hash_add): Likewise. (build_omp_clause): Likewise. * tree-ssanames.c (duplicate_ssa_name_ptr_info): Likewise. * tree-ssa.c (init_tree_ssa): Likewise. * tree-ssa-structalias.c (heapvar_insert): Likewise. * tree-ssa-operands.c (ssa_operand_alloc): Likewise. * tree-ssa-loop-niter.c (record_estimate): Likewise. * tree-ssa-alias.c (get_ptr_info): Likewise. * tree-scalar-evolution.c (new_scev_info_str): Likewise. * tree-phinodes.c (allocate_phi_node): Likewise. * tree-iterator.c (tsi_link_before): Likewise. (tsi_link_after): Likewise. * tree-eh.c (add_stmt_to_eh_lp_fn): Likewise. * tree-dfa.c (create_var_ann): Likewise. * tree-cfg.c (create_bb): Likewise. * toplev.c (alloc_for_identifier_to_locale): Likewise. (general_init): Likewise. * stringpool.c (stringpool_ggc_alloc): Likewise. (gt_pch_save_stringpool): Likewise. * sese.c (if_region_set_false_region): Likewise. * passes.c (do_per_function_toporder): Likewise. * optabs.c (set_optab_libfunc): Likewise. (set_conv_libfunc): Likewise. * lto-symtab.c (lto_symtab_register_decl): Likewise. * lto-streamer-in.c (lto_input_eh_catch_list): Likewise. (input_eh_region): Likewise. (input_eh_lp): Likewise. (make_new_block): Likewise. (unpack_ts_real_cst_value_fields): Likewise. * lto-section-in.c (lto_new_in_decl_state): Likewise. * lto-cgraph.c (input_node_opt_summary): Likewise. * loop-init.c (loop_optimizer_init): Likewise. * lambda.h (lambda_vector_new): Likewise. * lambda-code.c (replace_uses_equiv_to_x_with_y): Likewise. * ira.c (update_equiv_regs): Likewise. * ipa.c (cgraph_node_set_new): Likewise. (cgraph_node_set_add): Likewise. (varpool_node_set_new): Likewise. (varpool_node_set_add): Likewise. * ipa-prop.c (ipa_compute_jump_functions_for_edge): Likewise. (duplicate_ipa_jump_func_array): Likewise. (ipa_read_node_info): Likewise. * ipa-cp.c (ipcp_create_replace_map): Likewise. * integrate.c (get_hard_reg_initial_val): Likewise. * gimple.c (gimple_alloc_stat): Likewise. (gimple_build_omp_for): Likewise. (gimple_seq_alloc): Likewise. (gimple_copy): Likewise. * gimple-iterator.c (gsi_insert_before_without_update): Likewise. (gsi_insert_after_without_update): Likewise. * function.c (add_frame_space): Likewise. (insert_temp_slot_address): Likewise. (assign_stack_temp_for_type): Likewise. (allocate_struct_function): Likewise. (types_used_by_var_decl_insert): Likewise. * except.c (init_eh_for_function): Likewise. (gen_eh_region): Likewise. (gen_eh_region_catch): Likewise. (gen_eh_landing_pad): Likewise. (add_call_site): Likewise. * emit-rtl.c (get_mem_attrs): Likewise. (get_reg_attrs): Likewise. (start_sequence): Likewise. (init_emit): Likewise. * dwarf2out.c (new_cfi): Likewise. (queue_reg_save): Likewise. (dwarf2out_frame_init): Likewise. (new_loc_descr): Likewise. (find_AT_string): Likewise. (new_die): Likewise. (add_var_loc_to_decl): Likewise. (clone_die): Likewise. (clone_as_declaration): Likewise. (break_out_comdat_types): Likewise. (new_loc_list): Likewise. (loc_descriptor): Likewise. (add_loc_descr_to_each): Likewise. (add_const_value_attribute): Likewise. (tree_add_const_value_attribute): Likewise. (add_comp_dir_attribute): Likewise. (add_name_and_src_coords_attributes): Likewise. (lookup_filename): Likewise. (store_vcall_insn): Likewise. (dwarf2out_init): Likewise. * dbxout.c (dbxout_init): Likewise. * config/xtensa/xtensa.c (xtensa_init_machine_status): Likewise. * config/sparc/sparc.c (sparc_init_machine_status): Likewise. * config/score/score7.c (score7_output_external): Likewise. * config/score/score3.c (score3_output_external): Likewise. * config/s390/s390.c (s390_init_machine_status): Likewise. * config/rs6000/rs6000.c (builtin_function_type): Likewise. (rs6000_init_machine_status): Likewise. (output_toc): Likewise. * config/pa/pa.c (pa_init_machine_status): Likewise. (get_deferred_plabel): Likewise. * config/moxie/moxie.c (moxie_init_machine_status): Likewise. * config/mmix/mmix.c (mmix_init_machine_status): Likewise. * config/mips/mips.c (mflip_mips16_use_mips16_p): Likewise. * config/mep/mep.c (mep_init_machine_status): Likewise. (mep_note_pragma_flag): Likewise. * config/m32c/m32c.c (m32c_init_machine_status): Likewise. * config/iq2000/iq2000.c (iq2000_init_machine_status): Likewise. * config/ia64/ia64.c (ia64_init_machine_status): Likewise. * config/i386/winnt.c (i386_pe_record_external_function): Likewise. (i386_pe_maybe_record_exported_symbol): Likewise. * config/i386/i386.c (get_dllimport_decl): Likewise. (ix86_init_machine_status): Likewise. (assign_386_stack_local): Likewise. * config/frv/frv.c (frv_init_machine_status): Likewise. * config/darwin.c (machopic_indirection_name): Likewise. * config/cris/cris.c (cris_init_machine_status): Likewise. * config/bfin/bfin.c (bfin_init_machine_status): Likewise. * config/avr/avr.c (avr_init_machine_status): Likewise. * config/arm/arm.c (arm_init_machine_status): Likewise. * config/alpha/alpha.c (alpha_init_machine_status): Likewise. (alpha_need_linkage): Likewise. (alpha_use_linkage): Likewise. * cgraph.c (cgraph_allocate_node): Likewise. (cgraph_create_edge_1): Likewise. (cgraph_create_indirect_edge): Likewise. (cgraph_add_asm_node): Likewise. * cfgrtl.c (init_rtl_bb_info): Likewise. * cfgloop.c (alloc_loop): Likewise. (rescan_loop_exit): Likewise. * cfg.c (init_flow): Likewise. (alloc_block): Likewise. (unchecked_make_edge): Likewise. * c-parser.c (c_parse_init): Likewise. (c_parse_file): Likewise. * c-decl.c (bind): Likewise. (record_inline_static): Likewise. (push_scope): Likewise. (make_label): Likewise. (lookup_label_for_goto): Likewise. (finish_struct): Likewise. (finish_enum): Likewise. (c_push_function_context): Likewise. * bitmap.c (bitmap_element_allocate): Likewise. (bitmap_gc_alloc_stat): Likewise. * alias.c (record_alias_subset): Likewise. (init_alias_analysis): Likewise. include: 2010-06-08 Laurynas Biveinis * splay-tree.h: Update copyright years. (splay_tree_s): Document fields. (splay_tree_new_typed_alloc): New. * hashtab.h: Update copyright years. (htab_create_typed_alloc): New. libcpp: 2010-06-08 Laurynas Biveinis * include/symtab.h (ht_identifier_ptr): New. libiberty: 2010-06-08 Laurynas Biveinis * splay-tree.c: Update copyright years. (splay_tree_new_typed_alloc): New. (splay_tree_new_with_allocator): Use it. * hashtab.c: Update copyright years. (htab_create_typed_alloc): New. (htab_create_alloc): Use it. * functions.texi: Regenerate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160425 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index c6da4cd28bb..14224aa694d 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5437,9 +5437,8 @@ finish_struct_1 (tree t) n_fields = count_fields (TYPE_FIELDS (t)); if (n_fields > 7) { - struct sorted_fields_type *field_vec = GGC_NEWVAR - (struct sorted_fields_type, - sizeof (struct sorted_fields_type) + n_fields * sizeof (tree)); + struct sorted_fields_type *field_vec = ggc_alloc_sorted_fields_type + (sizeof (struct sorted_fields_type) + n_fields * sizeof (tree)); field_vec->len = n_fields; add_fields_to_record_type (TYPE_FIELDS (t), field_vec, 0); qsort (field_vec->elts, n_fields, sizeof (tree), -- cgit v1.2.1 From a0eca0c270319e3e299fd466fba02aab53fab4f9 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 15 Jun 2010 19:58:45 +0000 Subject: * class.c (type_has_user_provided_default_constructor): Use sufficient_parms_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160805 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 14224aa694d..340fe876d21 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4247,7 +4247,7 @@ type_has_user_provided_constructor (tree t) bool type_has_user_provided_default_constructor (tree t) { - tree fns, args; + tree fns; if (!TYPE_HAS_USER_CONSTRUCTOR (t)) return false; @@ -4256,14 +4256,9 @@ type_has_user_provided_default_constructor (tree t) { tree fn = OVL_CURRENT (fns); if (TREE_CODE (fn) == FUNCTION_DECL - && user_provided_p (fn)) - { - args = FUNCTION_FIRST_USER_PARMTYPE (fn); - while (args && TREE_PURPOSE (args)) - args = TREE_CHAIN (args); - if (!args || args == void_list_node) - return true; - } + && user_provided_p (fn) + && sufficient_parms_p (FUNCTION_FIRST_USER_PARMTYPE (fn))) + return true; } return false; -- cgit v1.2.1 From 523ff179e33d73d02e56f81fd940ee8b6929e735 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 15 Jun 2010 20:11:00 +0000 Subject: * class.c (add_implicitly_declared_members): Implicit assignment operators can also be virtual overriders. * method.c (lazily_declare_fn): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160810 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 74 +++++++++++++++++++++++++++------------------------------- 1 file changed, 34 insertions(+), 40 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 340fe876d21..60908ffb5d5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2618,47 +2618,13 @@ add_implicitly_declared_members (tree t, { /* In general, we create destructors lazily. */ CLASSTYPE_LAZY_DESTRUCTOR (t) = 1; - /* However, if the implicit destructor is non-trivial - destructor, we sometimes have to create it at this point. */ - if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) - { - bool lazy_p = true; - - if (TYPE_FOR_JAVA (t)) - /* If this a Java class, any non-trivial destructor is - invalid, even if compiler-generated. Therefore, if the - destructor is non-trivial we create it now. */ - lazy_p = false; - else - { - tree binfo; - tree base_binfo; - int ix; - - /* If the implicit destructor will be virtual, then we must - generate it now because (unfortunately) we do not - generate virtual tables lazily. */ - binfo = TYPE_BINFO (t); - for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ix++) - { - tree base_type; - tree dtor; - - base_type = BINFO_TYPE (base_binfo); - dtor = CLASSTYPE_DESTRUCTORS (base_type); - if (dtor && DECL_VIRTUAL_P (dtor)) - { - lazy_p = false; - break; - } - } - } - /* If we can't get away with being lazy, generate the destructor - now. */ - if (!lazy_p) - lazily_declare_fn (sfk_destructor, t); - } + if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) + && TYPE_FOR_JAVA (t)) + /* But if this is a Java class, any non-trivial destructor is + invalid, even if compiler-generated. Therefore, if the + destructor is non-trivial we create it now. */ + lazily_declare_fn (sfk_destructor, t); } /* [class.ctor] @@ -2697,6 +2663,34 @@ add_implicitly_declared_members (tree t, TYPE_HAS_CONST_ASSIGN_REF (t) = !cant_have_const_assignment; CLASSTYPE_LAZY_ASSIGNMENT_OP (t) = 1; } + + /* We can't be lazy about declaring functions that might override + a virtual function from a base class. */ + if (TYPE_POLYMORPHIC_P (t) + && (CLASSTYPE_LAZY_ASSIGNMENT_OP (t) + || CLASSTYPE_LAZY_DESTRUCTOR (t))) + { + tree binfo = TYPE_BINFO (t); + tree base_binfo; + int ix; + tree opname = ansi_assopname (NOP_EXPR); + for (ix = 0; BINFO_BASE_ITERATE (binfo, ix, base_binfo); ++ix) + { + tree bv; + for (bv = BINFO_VIRTUALS (base_binfo); bv; bv = TREE_CHAIN (bv)) + { + tree fn = BV_FN (bv); + if (DECL_NAME (fn) == opname) + { + if (CLASSTYPE_LAZY_ASSIGNMENT_OP (t)) + lazily_declare_fn (sfk_assignment_operator, t); + } + else if (DECL_DESTRUCTOR_P (fn) + && CLASSTYPE_LAZY_DESTRUCTOR (t)) + lazily_declare_fn (sfk_destructor, t); + } + } + } } /* Subroutine of finish_struct_1. Recursively count the number of fields -- cgit v1.2.1 From 7c15eccdd8f2b2b1399f74262310676e559074c7 Mon Sep 17 00:00:00 2001 From: froydnj Date: Wed, 16 Jun 2010 18:07:09 +0000 Subject: * class.c (build_vtbl_initializer): Adjust computation of new_position and which entry to add padding for. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160856 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 60908ffb5d5..f945923ddc4 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -7607,14 +7607,15 @@ build_vtbl_initializer (tree binfo, ix--) { int j; - int new_position = TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix; + int new_position = (TARGET_VTABLE_DATA_ENTRY_DISTANCE * ix + + (TARGET_VTABLE_DATA_ENTRY_DISTANCE - 1)); VEC_replace (constructor_elt, vid.inits, new_position, e); for (j = 1; j < TARGET_VTABLE_DATA_ENTRY_DISTANCE; ++j) { - constructor_elt *f = VEC_index (constructor_elt, *inits, - new_position + j); + constructor_elt *f = VEC_index (constructor_elt, vid.inits, + new_position - j); f->index = NULL_TREE; f->value = build1 (NOP_EXPR, vtable_entry_type, null_pointer_node); -- cgit v1.2.1 From db2273f6245e672110364f8a9bbd989418e8c932 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 28 Jun 2010 20:12:31 +0000 Subject: PR c++/44682 * class.c (build_base_path): If want_pointer, call mark_rvalue_use on expr. * g++.dg/warn/Wunused-var-14.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161511 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index f945923ddc4..51f749f61b0 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -283,6 +283,8 @@ build_base_path (enum tree_code code, if (!want_pointer) /* This must happen before the call to save_expr. */ expr = cp_build_unary_op (ADDR_EXPR, expr, 0, tf_warning_or_error); + else + mark_rvalue_use (expr); offset = BINFO_OFFSET (binfo); fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull); -- cgit v1.2.1 From ab8002def2756caef8dab23e0fd27c446dbd343e Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Jun 2010 00:50:34 +0000 Subject: * cp-tree.h (TYPE_HAS_ASSIGN_REF): Rename to TYPE_HAS_COPY_ASSIGN. (TYPE_HAS_CONST_ASSIGN_REF): Rename to TYPE_HAS_CONST_COPY_ASSIGN. (TYPE_HAS_INIT_REF): Rename to TYPE_HAS_COPY_CTOR. (TYPE_HAS_CONST_INIT_REF): Rename to TYPE_HAS_CONST_COPY_CTOR. (TYPE_HAS_COMPLEX_ASSIGN_REF): Rename to TYPE_HAS_COMPLEX_COPY_ASSIGN. (TYPE_HAS_COMPLEX_INIT_REF): Rename to TYPE_HAS_COMPLEX_COPY_CTOR. (TYPE_HAS_TRIVIAL_ASSIGN_REF): Rename to TYPE_HAS_TRIVIAL_COPY_ASSIGN. (TYPE_HAS_TRIVIAL_INIT_REF): Rename to TYPE_HAS_TRIVIAL_COPY_CTOR. (CLASSTYPE_LAZY_ASSIGNMENT_OP): Rename to CLASSTYPE_LAZY_COPY_ASSIGN. (sfk_assignment_operator): Rename to sfk_copy_assignment. * decl.c, call.c, class.c, init.c, method.c, pt.c, ptree.c: Adjust. * search.c, semantics.c, tree.c: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161577 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 74 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 51f749f61b0..3a87555876c 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1282,10 +1282,10 @@ check_bases (tree t, assignment operators that take const references, then the derived class cannot have such a member automatically generated. */ - if (! TYPE_HAS_CONST_INIT_REF (basetype)) + if (! TYPE_HAS_CONST_COPY_CTOR (basetype)) *cant_have_const_ctor_p = 1; - if (TYPE_HAS_ASSIGN_REF (basetype) - && !TYPE_HAS_CONST_ASSIGN_REF (basetype)) + if (TYPE_HAS_COPY_ASSIGN (basetype) + && !TYPE_HAS_CONST_COPY_ASSIGN (basetype)) *no_const_asn_ref_p = 1; if (BINFO_VIRTUAL_P (base_binfo)) @@ -1311,9 +1311,9 @@ check_bases (tree t, TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (basetype); TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) |= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype); - TYPE_HAS_COMPLEX_ASSIGN_REF (t) - |= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype); - TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype); + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) + |= TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype); + TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (basetype); TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype); CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); @@ -1541,7 +1541,7 @@ finish_struct_bits (tree t) mode to be BLKmode, and force its TREE_ADDRESSABLE bit to be nonzero. This will cause it to be passed by invisible reference and prevent it from being returned in a register. */ - if (! TYPE_HAS_TRIVIAL_INIT_REF (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) + if (! TYPE_HAS_TRIVIAL_COPY_CTOR (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) { tree variants; DECL_MODE (TYPE_MAIN_DECL (t)) = BLKmode; @@ -1668,10 +1668,10 @@ maybe_warn_about_overly_private_class (tree t) template class C { private: C(); }; - To avoid this asymmetry, we check TYPE_HAS_INIT_REF. All + To avoid this asymmetry, we check TYPE_HAS_COPY_CTOR. All complete non-template or fully instantiated classes have this flag set. */ - if (!TYPE_HAS_INIT_REF (t)) + if (!TYPE_HAS_COPY_CTOR (t)) nonprivate_ctor = 1; else for (fn = CLASSTYPE_CONSTRUCTORS (t); fn; fn = OVL_NEXT (fn)) @@ -2643,14 +2643,14 @@ add_implicitly_declared_members (tree t, If a class definition does not explicitly declare a copy constructor, one is declared implicitly. */ - if (! TYPE_HAS_INIT_REF (t) && ! TYPE_FOR_JAVA (t)) + if (! TYPE_HAS_COPY_CTOR (t) && ! TYPE_FOR_JAVA (t)) { - TYPE_HAS_INIT_REF (t) = 1; - TYPE_HAS_CONST_INIT_REF (t) = !cant_have_const_cctor; + TYPE_HAS_COPY_CTOR (t) = 1; + TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor; CLASSTYPE_LAZY_COPY_CTOR (t) = 1; } - /* Currently only lambdas get a lazy move ctor, but N2987 adds them for + /* Currently only lambdas get a lazy move ctor, but N3053 adds them for other classes. */ if (LAMBDA_TYPE_P (t)) CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; @@ -2659,17 +2659,17 @@ add_implicitly_declared_members (tree t, when it is needed. For now, just record whether or not the type of the parameter to the assignment operator will be a const or non-const reference. */ - if (!TYPE_HAS_ASSIGN_REF (t) && !TYPE_FOR_JAVA (t)) + if (!TYPE_HAS_COPY_ASSIGN (t) && !TYPE_FOR_JAVA (t)) { - TYPE_HAS_ASSIGN_REF (t) = 1; - TYPE_HAS_CONST_ASSIGN_REF (t) = !cant_have_const_assignment; - CLASSTYPE_LAZY_ASSIGNMENT_OP (t) = 1; + TYPE_HAS_COPY_ASSIGN (t) = 1; + TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment; + CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1; } /* We can't be lazy about declaring functions that might override a virtual function from a base class. */ if (TYPE_POLYMORPHIC_P (t) - && (CLASSTYPE_LAZY_ASSIGNMENT_OP (t) + && (CLASSTYPE_LAZY_COPY_ASSIGN (t) || CLASSTYPE_LAZY_DESTRUCTOR (t))) { tree binfo = TYPE_BINFO (t); @@ -2684,8 +2684,8 @@ add_implicitly_declared_members (tree t, tree fn = BV_FN (bv); if (DECL_NAME (fn) == opname) { - if (CLASSTYPE_LAZY_ASSIGNMENT_OP (t)) - lazily_declare_fn (sfk_assignment_operator, t); + if (CLASSTYPE_LAZY_COPY_ASSIGN (t)) + lazily_declare_fn (sfk_copy_assignment, t); } else if (DECL_DESTRUCTOR_P (fn) && CLASSTYPE_LAZY_DESTRUCTOR (t)) @@ -2819,7 +2819,7 @@ check_field_decl (tree field, the settings of CANT_HAVE_CONST_CTOR and friends. */ if (ANON_UNION_TYPE_P (type)) ; - /* And, we don't set TYPE_HAS_CONST_INIT_REF, etc., for anonymous + /* And, we don't set TYPE_HAS_CONST_COPY_CTOR, etc., for anonymous structs. So, we recurse through their fields here. */ else if (ANON_AGGR_TYPE_P (type)) { @@ -2845,7 +2845,7 @@ check_field_decl (tree field, field); if (TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)) error ("member %q+#D with destructor not allowed in union", field); - if (TYPE_HAS_COMPLEX_ASSIGN_REF (type)) + if (TYPE_HAS_COMPLEX_COPY_ASSIGN (type)) error ("member %q+#D with copy assignment operator not allowed in union", field); } @@ -2854,15 +2854,15 @@ check_field_decl (tree field, TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (type); TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) |= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type); - TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_HAS_COMPLEX_ASSIGN_REF (type); - TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (type); + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_HAS_COMPLEX_COPY_ASSIGN (type); + TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (type); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_HAS_COMPLEX_DFLT (type); } - if (!TYPE_HAS_CONST_INIT_REF (type)) + if (!TYPE_HAS_CONST_COPY_CTOR (type)) *cant_have_const_ctor = 1; - if (!TYPE_HAS_CONST_ASSIGN_REF (type)) + if (!TYPE_HAS_CONST_COPY_ASSIGN (type)) *no_const_asn_ref = 1; } if (DECL_INITIAL (field) != NULL_TREE) @@ -3021,7 +3021,7 @@ check_field_decls (tree t, tree *access_decls, aggregate, initialization by a brace-enclosed list) is the only way to initialize nonstatic const and reference members. */ - TYPE_HAS_COMPLEX_ASSIGN_REF (t) = 1; + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; } type = strip_array_types (type); @@ -3107,7 +3107,7 @@ check_field_decls (tree t, tree *access_decls, aggregate, initialization by a brace-enclosed list) is the only way to initialize nonstatic const and reference members. */ - TYPE_HAS_COMPLEX_ASSIGN_REF (t) = 1; + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; } /* A field that is pseudo-const makes the structure likewise. */ else if (CLASS_TYPE_P (type)) @@ -3144,18 +3144,18 @@ check_field_decls (tree t, tree *access_decls, && has_pointers && TYPE_HAS_USER_CONSTRUCTOR (t) && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) - && !(TYPE_HAS_INIT_REF (t) && TYPE_HAS_ASSIGN_REF (t))) + && !(TYPE_HAS_COPY_CTOR (t) && TYPE_HAS_COPY_ASSIGN (t))) { warning (OPT_Weffc__, "%q#T has pointer data members", t); - if (! TYPE_HAS_INIT_REF (t)) + if (! TYPE_HAS_COPY_CTOR (t)) { warning (OPT_Weffc__, " but does not override %<%T(const %T&)%>", t, t); - if (!TYPE_HAS_ASSIGN_REF (t)) + if (!TYPE_HAS_COPY_ASSIGN (t)) warning (OPT_Weffc__, " or %", t); } - else if (! TYPE_HAS_ASSIGN_REF (t)) + else if (! TYPE_HAS_COPY_ASSIGN (t)) warning (OPT_Weffc__, " but does not override %", t); } @@ -4375,7 +4375,7 @@ check_bases_and_members (tree t) /* Save the initial values of these flags which only indicate whether or not the class has user-provided functions. As we analyze the bases and members we can set these flags for other reasons. */ - saved_complex_asn_ref = TYPE_HAS_COMPLEX_ASSIGN_REF (t); + saved_complex_asn_ref = TYPE_HAS_COMPLEX_COPY_ASSIGN (t); saved_nontrivial_dtor = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t); /* Check all the data member declarations. We cannot call @@ -4393,7 +4393,7 @@ check_bases_and_members (tree t) /* Do some bookkeeping that will guide the generation of implicitly declared member functions. */ - TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_CONTAINS_VPTR_P (t); + TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_CONTAINS_VPTR_P (t); /* We need to call a constructor for this class if it has a user-provided constructor, or if the default constructor is going to initialize the vptr. (This is not an if-and-only-if; @@ -4416,7 +4416,7 @@ check_bases_and_members (tree t) |= (CLASSTYPE_NON_AGGREGATE (t) || saved_nontrivial_dtor || saved_complex_asn_ref); CLASSTYPE_NON_STD_LAYOUT (t) |= TYPE_CONTAINS_VPTR_P (t); - TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_CONTAINS_VPTR_P (t); + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_CONTAINS_VPTR_P (t); /* If the class has no user-declared constructor, but does have @@ -4488,8 +4488,8 @@ check_bases_and_members (tree t) TYPE_NEEDS_CONSTRUCTING (t) = 1; TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0; CLASSTYPE_LAZY_DEFAULT_CTOR (t) = 0; - TYPE_HAS_ASSIGN_REF (t) = 0; - CLASSTYPE_LAZY_ASSIGNMENT_OP (t) = 0; + TYPE_HAS_COPY_ASSIGN (t) = 0; + CLASSTYPE_LAZY_COPY_ASSIGN (t) = 0; /* "This class type is not an aggregate." */ CLASSTYPE_NON_AGGREGATE (t) = 1; -- cgit v1.2.1 From 0f16033eb5a6958bbd90e80ac693e10d37439c78 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Jun 2010 00:50:45 +0000 Subject: * class.c (type_has_virtual_destructor): New. * cp-tree.h: Declare it. * semantics.c (trait_expr_value): Use it. * call.c (build_over_call): Only give warnings with tf_warning. * name-lookup.c (pop_scope): Handle NULL_TREE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161578 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3a87555876c..bfd311382e1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -3838,7 +3838,9 @@ check_methods (tree t) if (DECL_PURE_VIRTUAL_P (x)) VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); } - /* All user-provided destructors are non-trivial. */ + /* All user-provided destructors are non-trivial. + Constructors and assignment ops are handled in + grok_special_member_properties. */ if (DECL_DESTRUCTOR_P (x) && user_provided_p (x)) TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) = 1; } @@ -4260,6 +4262,21 @@ type_has_user_provided_default_constructor (tree t) return false; } +/* Returns true iff class TYPE has a virtual destructor. */ + +bool +type_has_virtual_destructor (tree type) +{ + tree dtor; + + if (!CLASS_TYPE_P (type)) + return false; + + gcc_assert (COMPLETE_TYPE_P (type)); + dtor = CLASSTYPE_DESTRUCTORS (type); + return (dtor && DECL_VIRTUAL_P (dtor)); +} + /* Remove all zero-width bit-fields from T. */ static void -- cgit v1.2.1 From 2ee92e2716a9d11609dbcb1d29f07ae3f7b39b75 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Jun 2010 00:50:57 +0000 Subject: Machinery to support implicit delete/move. * cp-tree.h: (struct lang_type_class): Add lazy_move_assign, has_complex_move_ctor, has_complex_move_assign bitfields. (CLASSTYPE_LAZY_MOVE_ASSIGN): New. (TYPE_HAS_COMPLEX_MOVE_ASSIGN): New. (TYPE_HAS_COMPLEX_MOVE_CTOR): New. (enum special_function_kind): Add sfk_move_assignment. (LOOKUP_SPECULATIVE): New. * call.c (build_over_call): Return early if it's set. (build_over_call): Use trivial_fn_p. * class.c (check_bases): If the base has no default constructor, the derived one is non-trivial. Handle move ctor/op=. (check_field_decl): Likewise. (check_bases_and_members): Handle move ctor/op=. (add_implicitly_declared_members): Handle CLASSTYPE_LAZY_MOVE_ASSIGN. (type_has_move_constructor, type_has_move_assign): New. * decl.c (grok_special_member_properties): Handle move ctor/op=. * method.c (type_has_trivial_fn, type_set_nontrivial_flag): New. (trivial_fn_p): New. (do_build_copy_constructor): Use it. (do_build_assign_ref): Likewise. Handle move assignment. (build_stub_type, build_stub_object, locate_fn_flags): New. (locate_ctor): Use locate_fn_flags. (locate_copy, locate_dtor): Remove. (get_dtor, get_default_ctor, get_copy_ctor, get_copy_assign): New. (process_subob_fn, synthesized_method_walk): New. (maybe_explain_implicit_delete): New. (implicitly_declare_fn): Use synthesized_method_walk, type_has_trivial_fn, and type_set_nontrivial_flag. (defaulted_late_check): Set DECL_DELETED_FN. (defaultable_fn_check): Handle sfk_move_assignment. (lazily_declare_fn): Clear CLASSTYPE_LAZY_* early. Don't declare implicitly deleted move ctor/op=. * search.c (lookup_fnfields_1): Handle sfk_move_assignment. (lookup_fnfields_slot): New. * semantics.c (omp_clause_info_fndecl): Remove. (cxx_omp_create_clause_info): Use get_default_ctor, get_copy_ctor, get_copy_assign, trivial_fn_p. (trait_expr_value): Adjust call to locate_ctor. * tree.c (special_function_p): Handle sfk_move_assignment. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161579 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index bfd311382e1..6f6aab6d63f 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1314,10 +1314,14 @@ check_bases (tree t, TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype); TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (basetype); + TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) + |= TYPE_HAS_COMPLEX_MOVE_ASSIGN (basetype); + TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (basetype); TYPE_POLYMORPHIC_P (t) |= TYPE_POLYMORPHIC_P (basetype); CLASSTYPE_CONTAINS_EMPTY_CLASS_P (t) |= CLASSTYPE_CONTAINS_EMPTY_CLASS_P (basetype); - TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_HAS_COMPLEX_DFLT (basetype); + TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype) + || TYPE_HAS_COMPLEX_DFLT (basetype)); /* A standard-layout class is a class that: ... @@ -2670,6 +2674,7 @@ add_implicitly_declared_members (tree t, a virtual function from a base class. */ if (TYPE_POLYMORPHIC_P (t) && (CLASSTYPE_LAZY_COPY_ASSIGN (t) + || CLASSTYPE_LAZY_MOVE_ASSIGN (t) || CLASSTYPE_LAZY_DESTRUCTOR (t))) { tree binfo = TYPE_BINFO (t); @@ -2686,6 +2691,8 @@ add_implicitly_declared_members (tree t, { if (CLASSTYPE_LAZY_COPY_ASSIGN (t)) lazily_declare_fn (sfk_copy_assignment, t); + if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) + lazily_declare_fn (sfk_move_assignment, t); } else if (DECL_DESTRUCTOR_P (fn) && CLASSTYPE_LAZY_DESTRUCTOR (t)) @@ -2848,6 +2855,8 @@ check_field_decl (tree field, if (TYPE_HAS_COMPLEX_COPY_ASSIGN (type)) error ("member %q+#D with copy assignment operator not allowed in union", field); + /* Don't bother diagnosing move assop now; C++0x has more + flexible unions. */ } else { @@ -2856,7 +2865,10 @@ check_field_decl (tree field, |= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type); TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_HAS_COMPLEX_COPY_ASSIGN (type); TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (type); - TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_HAS_COMPLEX_DFLT (type); + TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) |= TYPE_HAS_COMPLEX_MOVE_ASSIGN (type); + TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (type); + TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (type) + || TYPE_HAS_COMPLEX_DFLT (type)); } if (!TYPE_HAS_CONST_COPY_CTOR (type)) @@ -3022,6 +3034,7 @@ check_field_decls (tree t, tree *access_decls, only way to initialize nonstatic const and reference members. */ TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; + TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1; } type = strip_array_types (type); @@ -3108,6 +3121,7 @@ check_field_decls (tree t, tree *access_decls, only way to initialize nonstatic const and reference members. */ TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; + TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) = 1; } /* A field that is pseudo-const makes the structure likewise. */ else if (CLASS_TYPE_P (type)) @@ -4277,6 +4291,50 @@ type_has_virtual_destructor (tree type) return (dtor && DECL_VIRTUAL_P (dtor)); } +/* Returns true iff class T has a move constructor. */ + +bool +type_has_move_constructor (tree t) +{ + tree fns; + + if (CLASSTYPE_LAZY_MOVE_CTOR (t)) + { + gcc_assert (COMPLETE_TYPE_P (t)); + lazily_declare_fn (sfk_move_constructor, t); + } + + if (!CLASSTYPE_METHOD_VEC (t)) + return false; + + for (fns = CLASSTYPE_CONSTRUCTORS (t); fns; fns = OVL_NEXT (fns)) + if (move_fn_p (OVL_CURRENT (fns))) + return true; + + return false; +} + +/* Returns true iff class T has a move assignment operator. */ + +bool +type_has_move_assign (tree t) +{ + tree fns; + + if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) + { + gcc_assert (COMPLETE_TYPE_P (t)); + lazily_declare_fn (sfk_move_assignment, t); + } + + for (fns = lookup_fnfields_slot (t, ansi_assopname (NOP_EXPR)); + fns; fns = OVL_NEXT (fns)) + if (move_fn_p (OVL_CURRENT (fns))) + return true; + + return false; +} + /* Remove all zero-width bit-fields from T. */ static void @@ -4411,6 +4469,7 @@ check_bases_and_members (tree t) /* Do some bookkeeping that will guide the generation of implicitly declared member functions. */ TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_CONTAINS_VPTR_P (t); + TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_CONTAINS_VPTR_P (t); /* We need to call a constructor for this class if it has a user-provided constructor, or if the default constructor is going to initialize the vptr. (This is not an if-and-only-if; @@ -4434,6 +4493,7 @@ check_bases_and_members (tree t) || saved_nontrivial_dtor || saved_complex_asn_ref); CLASSTYPE_NON_STD_LAYOUT (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_CONTAINS_VPTR_P (t); + TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) |= TYPE_CONTAINS_VPTR_P (t); TYPE_HAS_COMPLEX_DFLT (t) |= TYPE_CONTAINS_VPTR_P (t); /* If the class has no user-declared constructor, but does have -- cgit v1.2.1 From 4973dd77b950e66499d7df25595f714609a69f7c Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Jun 2010 00:51:29 +0000 Subject: Enable implicitly deleted functions (N2346) * class.c (check_bases_and_members): Adjust lambda flags. * method.c (implicitly_declare_fn): Set DECL_DELETED_FN if appropriate. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161581 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 6f6aab6d63f..031a4ea79c3 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -4563,10 +4563,9 @@ check_bases_and_members (tree t) /* "The closure type associated with a lambda-expression has a deleted default constructor and a deleted copy assignment operator." */ TYPE_NEEDS_CONSTRUCTING (t) = 1; - TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0; - CLASSTYPE_LAZY_DEFAULT_CTOR (t) = 0; - TYPE_HAS_COPY_ASSIGN (t) = 0; - CLASSTYPE_LAZY_COPY_ASSIGN (t) = 0; + TYPE_HAS_COMPLEX_DFLT (t) = 1; + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) = 1; + CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 0; /* "This class type is not an aggregate." */ CLASSTYPE_NON_AGGREGATE (t) = 1; -- cgit v1.2.1 From bde2eab67c0f63e6dcafc495585ee57d7d810adf Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Jun 2010 00:51:44 +0000 Subject: Enable implicitly declared move constructor/operator= (N3053). gcc/cp/ * class.c (add_implicitly_declared_members): A class with no explicitly declared copy or move constructor gets both declared implicitly, and similarly for operator=. (check_bases): A type with no copy ctor does not inhibit a const copy ctor in a derived class. (check_field_decl): Likewise. (check_bases_and_members): A nonexistent copy ctor/op= is non-trivial. * tree.c (type_has_nontrivial_copy_init): Adjust semantics. (trivially_copyable_p): Likewise. * call.c (convert_like_real): Use type_has_nontrivial_copy_init. * class.c (finish_struct_bits): Likewise. * tree.c (build_target_expr_with_type): Likewise. * typeck2.c (store_init_value): Likewise. libstdc++-v3/ * include/bits/unordered_map.h: Explicitly default copy constructors. * include/bits/unordered_set.h: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161582 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 40 +++++++++++++++++++++++++--------------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 031a4ea79c3..a2ed86334b5 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -1282,7 +1282,8 @@ check_bases (tree t, assignment operators that take const references, then the derived class cannot have such a member automatically generated. */ - if (! TYPE_HAS_CONST_COPY_CTOR (basetype)) + if (TYPE_HAS_COPY_CTOR (basetype) + && ! TYPE_HAS_CONST_COPY_CTOR (basetype)) *cant_have_const_ctor_p = 1; if (TYPE_HAS_COPY_ASSIGN (basetype) && !TYPE_HAS_CONST_COPY_ASSIGN (basetype)) @@ -1312,8 +1313,10 @@ check_bases (tree t, TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) |= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (basetype); TYPE_HAS_COMPLEX_COPY_ASSIGN (t) - |= TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype); - TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (basetype); + |= (TYPE_HAS_COMPLEX_COPY_ASSIGN (basetype) + || !TYPE_HAS_COPY_ASSIGN (basetype)); + TYPE_HAS_COMPLEX_COPY_CTOR (t) |= (TYPE_HAS_COMPLEX_COPY_CTOR (basetype) + || !TYPE_HAS_COPY_CTOR (basetype)); TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) |= TYPE_HAS_COMPLEX_MOVE_ASSIGN (basetype); TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (basetype); @@ -1545,7 +1548,8 @@ finish_struct_bits (tree t) mode to be BLKmode, and force its TREE_ADDRESSABLE bit to be nonzero. This will cause it to be passed by invisible reference and prevent it from being returned in a register. */ - if (! TYPE_HAS_TRIVIAL_COPY_CTOR (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) + if (type_has_nontrivial_copy_init (t) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)) { tree variants; DECL_MODE (TYPE_MAIN_DECL (t)) = BLKmode; @@ -2647,27 +2651,28 @@ add_implicitly_declared_members (tree t, If a class definition does not explicitly declare a copy constructor, one is declared implicitly. */ - if (! TYPE_HAS_COPY_CTOR (t) && ! TYPE_FOR_JAVA (t)) + if (! TYPE_HAS_COPY_CTOR (t) && ! TYPE_FOR_JAVA (t) + && !type_has_move_constructor (t)) { TYPE_HAS_COPY_CTOR (t) = 1; TYPE_HAS_CONST_COPY_CTOR (t) = !cant_have_const_cctor; CLASSTYPE_LAZY_COPY_CTOR (t) = 1; + if (cxx_dialect >= cxx0x) + CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; } - /* Currently only lambdas get a lazy move ctor, but N3053 adds them for - other classes. */ - if (LAMBDA_TYPE_P (t)) - CLASSTYPE_LAZY_MOVE_CTOR (t) = 1; - /* If there is no assignment operator, one will be created if and when it is needed. For now, just record whether or not the type of the parameter to the assignment operator will be a const or non-const reference. */ - if (!TYPE_HAS_COPY_ASSIGN (t) && !TYPE_FOR_JAVA (t)) + if (!TYPE_HAS_COPY_ASSIGN (t) && !TYPE_FOR_JAVA (t) + && !type_has_move_assign (t)) { TYPE_HAS_COPY_ASSIGN (t) = 1; TYPE_HAS_CONST_COPY_ASSIGN (t) = !cant_have_const_assignment; CLASSTYPE_LAZY_COPY_ASSIGN (t) = 1; + if (cxx_dialect >= cxx0x) + CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } /* We can't be lazy about declaring functions that might override @@ -2863,18 +2868,23 @@ check_field_decl (tree field, TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (type); TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) |= TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type); - TYPE_HAS_COMPLEX_COPY_ASSIGN (t) |= TYPE_HAS_COMPLEX_COPY_ASSIGN (type); - TYPE_HAS_COMPLEX_COPY_CTOR (t) |= TYPE_HAS_COMPLEX_COPY_CTOR (type); + TYPE_HAS_COMPLEX_COPY_ASSIGN (t) + |= (TYPE_HAS_COMPLEX_COPY_ASSIGN (type) + || !TYPE_HAS_COPY_ASSIGN (type)); + TYPE_HAS_COMPLEX_COPY_CTOR (t) |= (TYPE_HAS_COMPLEX_COPY_CTOR (type) + || !TYPE_HAS_COPY_CTOR (type)); TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) |= TYPE_HAS_COMPLEX_MOVE_ASSIGN (type); TYPE_HAS_COMPLEX_MOVE_CTOR (t) |= TYPE_HAS_COMPLEX_MOVE_CTOR (type); TYPE_HAS_COMPLEX_DFLT (t) |= (!TYPE_HAS_DEFAULT_CONSTRUCTOR (type) || TYPE_HAS_COMPLEX_DFLT (type)); } - if (!TYPE_HAS_CONST_COPY_CTOR (type)) + if (TYPE_HAS_COPY_CTOR (type) + && !TYPE_HAS_CONST_COPY_CTOR (type)) *cant_have_const_ctor = 1; - if (!TYPE_HAS_CONST_COPY_ASSIGN (type)) + if (TYPE_HAS_COPY_ASSIGN (type) + && !TYPE_HAS_CONST_COPY_ASSIGN (type)) *no_const_asn_ref = 1; } if (DECL_INITIAL (field) != NULL_TREE) -- cgit v1.2.1 From 6ac80fa2b1c32357664b0ece0231b0fb4239cc99 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 2 Jul 2010 20:22:32 +0000 Subject: PR c++/44780 * typeck.c (convert_for_assignment): When converting a convertible vector type or objc++ types, call mark_rvalue_use. * typeck2.c (build_m_component_ref): Use return values from mark_rvalue_use or mark_lvalue_use. * class.c (build_base_path): Likewise. * call.c (build_conditional_expr): Likewise. * c-c++-common/Wunused-var-12.c: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161742 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a2ed86334b5..3c4830e857e 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -284,7 +284,7 @@ build_base_path (enum tree_code code, /* This must happen before the call to save_expr. */ expr = cp_build_unary_op (ADDR_EXPR, expr, 0, tf_warning_or_error); else - mark_rvalue_use (expr); + expr = mark_rvalue_use (expr); offset = BINFO_OFFSET (binfo); fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull); -- cgit v1.2.1 From 84e4d4a4f64642e49df707692d3cc9d5ca6b1f57 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 8 Jul 2010 14:00:26 +0000 Subject: PR c++/43120 * class.c (update_vtable_entry_for_fn): Fix handling of dummy virtual bases for covariant thunks. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161954 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 3c4830e857e..20b8c1245c1 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2058,8 +2058,9 @@ get_vcall_index (tree fn, tree type) } /* Update an entry in the vtable for BINFO, which is in the hierarchy - dominated by T. FN has been overridden in BINFO; VIRTUALS points to the - corresponding position in the BINFO_VIRTUALS list. */ + dominated by T. FN is the old function; VIRTUALS points to the + corresponding position in the new BINFO_VIRTUALS list. IX is the index + of that entry in the list. */ static void update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, @@ -2252,9 +2253,11 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, virtual_base = probe; if (virtual_base) - /* Even if we find a virtual base, the correct delta is - between the overrider and the binfo we're building a vtable - for. */ + /* OK, first_defn got this function from a (possibly lost) primary + virtual base, so we're going to use the vcall offset for that + primary virtual base. But the caller is passing a first_defn*, + not a virtual_base*, so the correct delta is the delta between + first_defn* and itself, i.e. zero. */ goto virtual_covariant; } @@ -2272,12 +2275,12 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, entry in our vtable. Except possibly in a constructor vtable, if we happen to get our primary back. In that case, the offset will be zero, as it will be a primary base. */ + virtual_covariant: delta = size_zero_node; else /* The `this' pointer needs to be adjusted from pointing to BINFO to pointing at the base where the final overrider appears. */ - virtual_covariant: delta = size_diffop_loc (input_location, convert (ssizetype, BINFO_OFFSET (TREE_VALUE (overrider))), -- cgit v1.2.1 From 0ec820421213c3308258f9241363fda0b3133f40 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 9 Jul 2010 19:36:19 +0000 Subject: PR c++/43120 * cp-tree.h (BV_LOST_PRIMARY): New macro. * class.c (update_vtable_entry_for_fn): Fix covariant thunk logic. Set BV_LOST_PRIMARY. (build_vtbl_initializer): Check BV_LOST_PRIMARY. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162008 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 88 ++++++++++++++++++++++++++-------------------------------- 1 file changed, 40 insertions(+), 48 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 20b8c1245c1..dfb2cd942d7 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2205,6 +2205,40 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, gcc_assert (DECL_INVALID_OVERRIDER_P (overrider_target) || !DECL_THUNK_P (fn)); + /* If we need a covariant thunk, then we may need to adjust first_defn. + The ABI specifies that the thunks emitted with a function are + determined by which bases the function overrides, so we need to be + sure that we're using a thunk for some overridden base; even if we + know that the necessary this adjustment is zero, there may not be an + appropriate zero-this-adjusment thunk for us to use since thunks for + overriding virtual bases always use the vcall offset. + + Furthermore, just choosing any base that overrides this function isn't + quite right, as this slot won't be used for calls through a type that + puts a covariant thunk here. Calling the function through such a type + will use a different slot, and that slot is the one that determines + the thunk emitted for that base. + + So, keep looking until we find the base that we're really overriding + in this slot: the nearest primary base that doesn't use a covariant + thunk in this slot. */ + if (overrider_target != overrider_fn) + { + if (BINFO_TYPE (b) == DECL_CONTEXT (overrider_target)) + /* We already know that the overrider needs a covariant thunk. */ + b = get_primary_binfo (b); + for (; ; b = get_primary_binfo (b)) + { + tree main_binfo = TYPE_BINFO (BINFO_TYPE (b)); + tree bv = chain_index (ix, BINFO_VIRTUALS (main_binfo)); + if (BINFO_LOST_PRIMARY_P (b)) + lost = true; + if (!DECL_THUNK_P (TREE_VALUE (bv))) + break; + } + first_defn = b; + } + /* Assume that we will produce a thunk that convert all the way to the final overrider, and not to an intermediate virtual base. */ virtual_base = NULL_TREE; @@ -2229,38 +2263,6 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, } } - if (overrider_fn != overrider_target && !virtual_base) - { - /* The ABI specifies that a covariant thunk includes a mangling - for a this pointer adjustment. This-adjusting thunks that - override a function from a virtual base have a vcall - adjustment. When the virtual base in question is a primary - virtual base, we know the adjustments are zero, (and in the - non-covariant case, we would not use the thunk). - Unfortunately we didn't notice this could happen, when - designing the ABI and so never mandated that such a covariant - thunk should be emitted. Because we must use the ABI mandated - name, we must continue searching from the binfo where we - found the most recent definition of the function, towards the - primary binfo which first introduced the function into the - vtable. If that enters a virtual base, we must use a vcall - this-adjusting thunk. Bleah! */ - tree probe = first_defn; - - while ((probe = get_primary_binfo (probe)) - && (unsigned) list_length (BINFO_VIRTUALS (probe)) > ix) - if (BINFO_VIRTUAL_P (probe)) - virtual_base = probe; - - if (virtual_base) - /* OK, first_defn got this function from a (possibly lost) primary - virtual base, so we're going to use the vcall offset for that - primary virtual base. But the caller is passing a first_defn*, - not a virtual_base*, so the correct delta is the delta between - first_defn* and itself, i.e. zero. */ - goto virtual_covariant; - } - /* Compute the constant adjustment to the `this' pointer. The `this' pointer, when this function is called, will point at BINFO (or one of its primary bases, which are at the same offset). */ @@ -2275,7 +2277,6 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, entry in our vtable. Except possibly in a constructor vtable, if we happen to get our primary back. In that case, the offset will be zero, as it will be a primary base. */ - virtual_covariant: delta = size_zero_node; else /* The `this' pointer needs to be adjusted from pointing to @@ -2293,6 +2294,9 @@ update_vtable_entry_for_fn (tree t, tree binfo, tree fn, tree* virtuals, = get_vcall_index (overrider_target, BINFO_TYPE (virtual_base)); else BV_VCALL_INDEX (*virtuals) = NULL_TREE; + + if (lost) + BV_LOST_PRIMARY (*virtuals) = true; } /* Called from modify_all_vtables via dfs_walk. */ @@ -7648,7 +7652,7 @@ build_vtbl_initializer (tree binfo, int* non_fn_entries_p, VEC(constructor_elt,gc) **inits) { - tree v, b; + tree v; vtbl_init_data vid; unsigned ix, jx; tree vbinfo; @@ -7762,20 +7766,8 @@ build_vtbl_initializer (tree binfo, zero out unused slots in ctor vtables, rather than filling them with erroneous values (though harmless, apart from relocation costs). */ - for (b = binfo; ; b = get_primary_binfo (b)) - { - /* We found a defn before a lost primary; go ahead as normal. */ - if (look_for_overrides_here (BINFO_TYPE (b), fn_original)) - break; - - /* The nearest definition is from a lost primary; clear the - slot. */ - if (BINFO_LOST_PRIMARY_P (b)) - { - init = size_zero_node; - break; - } - } + if (BV_LOST_PRIMARY (v)) + init = size_zero_node; if (! init) { -- cgit v1.2.1 From 9258799505fbbd189d35d3a688b16cf4199b9860 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 13 Jul 2010 22:23:49 +0000 Subject: PR c++/44909 * cp-tree.h (struct lang_type_class): Add has_user_opeq. (TYPE_HAS_USER_OPEQ): New. * decl.c (grok_special_member_properties): Set it. * class.c (add_implicitly_declared_members): Don't lazily declare constructors/operator= if a base or member has a user-declared one. (check_bases_and_members, check_bases): Adjust. (check_field_decls, check_field_decl): Adjust. * method.c (synthesized_method_walk): Initialize check_vdtor. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162159 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 13 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index dfb2cd942d7..ed7367c95c4 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -130,7 +130,7 @@ static void finish_struct_methods (tree); static void maybe_warn_about_overly_private_class (tree); static int method_name_cmp (const void *, const void *); static int resort_method_name_cmp (const void *, const void *); -static void add_implicitly_declared_members (tree, int, int); +static void add_implicitly_declared_members (tree, int, int, int, int); static tree fixed_type_or_null (tree, int *, int *); static tree build_simple_base_path (tree expr, tree binfo); static tree build_vtbl_ref_1 (tree, tree); @@ -139,13 +139,13 @@ static void build_vtbl_initializer (tree, tree, tree, tree, int *, static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); static bool check_bitfield_decl (tree); -static void check_field_decl (tree, tree, int *, int *, int *); -static void check_field_decls (tree, tree *, int *, int *); +static void check_field_decl (tree, tree, int *, int *, int *, int *, int *); +static void check_field_decls (tree, tree *, int *, int *, int *, int *); static tree *build_base_field (record_layout_info, tree, splay_tree, tree *); static void build_base_fields (record_layout_info, splay_tree, tree *); static void check_methods (tree); static void remove_zero_width_bit_fields (tree); -static void check_bases (tree, int *, int *); +static void check_bases (tree, int *, int *, int *, int *); static void check_bases_and_members (tree); static tree create_vtable_ptr (tree, tree *); static void include_empty_classes (record_layout_info); @@ -1249,7 +1249,9 @@ handle_using_decl (tree using_decl, tree t) static void check_bases (tree t, int* cant_have_const_ctor_p, - int* no_const_asn_ref_p) + int* no_const_asn_ref_p, + int* cant_have_lazy_ctor, + int* cant_have_lazy_opeq) { int i; int seen_non_virtual_nearly_empty_base_p; @@ -1288,6 +1290,10 @@ check_bases (tree t, if (TYPE_HAS_COPY_ASSIGN (basetype) && !TYPE_HAS_CONST_COPY_ASSIGN (basetype)) *no_const_asn_ref_p = 1; + if (TYPE_HAS_USER_CONSTRUCTOR (basetype)) + *cant_have_lazy_ctor = 1; + if (TYPE_HAS_USER_OPEQ (basetype)) + *cant_have_lazy_opeq = 1; if (BINFO_VIRTUAL_P (base_binfo)) /* A virtual base does not effect nearly emptiness. */ @@ -2628,7 +2634,9 @@ maybe_add_class_template_decl_list (tree type, tree t, int friend_p) static void add_implicitly_declared_members (tree t, int cant_have_const_cctor, - int cant_have_const_assignment) + int cant_have_const_assignment, + int cant_have_lazy_ctor, + int cant_have_lazy_opeq) { /* Destructor. */ if (!CLASSTYPE_DESTRUCTORS (t)) @@ -2682,6 +2690,26 @@ add_implicitly_declared_members (tree t, CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } + /* If a base or member type has a user-declared constructor or operator=, + we need to declare ours now to avoid issues with circular lazy + declarations (cpp0x/implicit6.C). */ + if (cant_have_lazy_ctor) + { + if (CLASSTYPE_LAZY_DEFAULT_CTOR (t)) + lazily_declare_fn (sfk_constructor, t); + if (CLASSTYPE_LAZY_COPY_CTOR (t)) + lazily_declare_fn (sfk_copy_constructor, t); + if (CLASSTYPE_LAZY_MOVE_CTOR (t)) + lazily_declare_fn (sfk_move_constructor, t); + } + if (cant_have_lazy_opeq) + { + if (CLASSTYPE_LAZY_COPY_ASSIGN (t)) + lazily_declare_fn (sfk_copy_assignment, t); + if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) + lazily_declare_fn (sfk_move_assignment, t); + } + /* We can't be lazy about declaring functions that might override a virtual function from a base class. */ if (TYPE_POLYMORPHIC_P (t) @@ -2830,7 +2858,9 @@ check_field_decl (tree field, tree t, int* cant_have_const_ctor, int* no_const_asn_ref, - int* any_default_members) + int* any_default_members, + int* cant_have_lazy_ctor, + int* cant_have_lazy_opeq) { tree type = strip_array_types (TREE_TYPE (field)); @@ -2847,7 +2877,8 @@ check_field_decl (tree field, for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) if (TREE_CODE (fields) == FIELD_DECL && !DECL_C_BIT_FIELD (field)) check_field_decl (fields, t, cant_have_const_ctor, - no_const_asn_ref, any_default_members); + no_const_asn_ref, any_default_members, + cant_have_lazy_ctor, cant_have_lazy_opeq); } /* Check members with class type for constructors, destructors, etc. */ @@ -2893,6 +2924,11 @@ check_field_decl (tree field, if (TYPE_HAS_COPY_ASSIGN (type) && !TYPE_HAS_CONST_COPY_ASSIGN (type)) *no_const_asn_ref = 1; + + if (TYPE_HAS_USER_CONSTRUCTOR (type)) + *cant_have_lazy_ctor = 1; + if (TYPE_HAS_USER_OPEQ (type)) + *cant_have_lazy_opeq = 1; } if (DECL_INITIAL (field) != NULL_TREE) { @@ -2932,7 +2968,9 @@ check_field_decl (tree field, static void check_field_decls (tree t, tree *access_decls, int *cant_have_const_ctor_p, - int *no_const_asn_ref_p) + int *no_const_asn_ref_p, + int *cant_have_lazy_ctor_p, + int *cant_have_lazy_opeq_p) { tree *field; tree *next; @@ -3124,7 +3162,9 @@ check_field_decls (tree t, tree *access_decls, check_field_decl (x, t, cant_have_const_ctor_p, no_const_asn_ref_p, - &any_default_members); + &any_default_members, + cant_have_lazy_ctor_p, + cant_have_lazy_opeq_p); /* If any field is const, the structure type is pseudo-const. */ if (CP_TYPE_CONST_P (type)) @@ -4447,6 +4487,8 @@ check_bases_and_members (tree t) /* Nonzero if the implicitly generated assignment operator should take a non-const reference argument. */ int no_const_asn_ref; + int cant_have_lazy_ctor = 0; + int cant_have_lazy_opeq = 0; tree access_decls; bool saved_complex_asn_ref; bool saved_nontrivial_dtor; @@ -4459,7 +4501,8 @@ check_bases_and_members (tree t) /* Check all the base-classes. */ check_bases (t, &cant_have_const_ctor, - &no_const_asn_ref); + &no_const_asn_ref, &cant_have_lazy_ctor, + &cant_have_lazy_opeq); /* Check all the method declarations. */ check_methods (t); @@ -4476,7 +4519,9 @@ check_bases_and_members (tree t) being set appropriately. */ check_field_decls (t, &access_decls, &cant_have_const_ctor, - &no_const_asn_ref); + &no_const_asn_ref, + &cant_have_lazy_ctor, + &cant_have_lazy_opeq); /* A nearly-empty class has to be vptr-containing; a nearly empty class contains just a vptr. */ @@ -4548,7 +4593,9 @@ check_bases_and_members (tree t) /* Synthesize any needed methods. */ add_implicitly_declared_members (t, cant_have_const_ctor, - no_const_asn_ref); + no_const_asn_ref, + cant_have_lazy_ctor, + cant_have_lazy_opeq); /* Check defaulted declarations here so we have cant_have_const_ctor and don't need to worry about clones. */ -- cgit v1.2.1 From 80e5473297f3b9131a8e689f9a60714e486c72fb Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 14 Jul 2010 17:00:51 +0000 Subject: Implement C++0x unrestricted unions (N2544) * class.c (check_field_decl): Loosen union handling in C++0x. * method.c (walk_field_subobs): Split out from... (synthesized_method_walk): ...here. Set msg before loops. (process_subob_fn): Check for triviality in union members. * init.c (sort_mem_initializers): Splice out uninitialized anonymous unions and union members. (push_base_cleanups): Don't automatically destroy anonymous unions and union members. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162187 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index ed7367c95c4..a572af83f63 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -2864,9 +2864,9 @@ check_field_decl (tree field, { tree type = strip_array_types (TREE_TYPE (field)); - /* An anonymous union cannot contain any fields which would change + /* In C++98 an anonymous union cannot contain any fields which would change the settings of CANT_HAVE_CONST_CTOR and friends. */ - if (ANON_UNION_TYPE_P (type)) + if (ANON_UNION_TYPE_P (type) && cxx_dialect < cxx0x) ; /* And, we don't set TYPE_HAS_CONST_COPY_CTOR, etc., for anonymous structs. So, we recurse through their fields here. */ @@ -2888,8 +2888,10 @@ check_field_decl (tree field, make it through without complaint. */ abstract_virtuals_error (field, type); - if (TREE_CODE (t) == UNION_TYPE) + if (TREE_CODE (t) == UNION_TYPE && cxx_dialect < cxx0x) { + static bool warned; + int oldcount = errorcount; if (TYPE_NEEDS_CONSTRUCTING (type)) error ("member %q+#D with constructor not allowed in union", field); @@ -2898,8 +2900,12 @@ check_field_decl (tree field, if (TYPE_HAS_COMPLEX_COPY_ASSIGN (type)) error ("member %q+#D with copy assignment operator not allowed in union", field); - /* Don't bother diagnosing move assop now; C++0x has more - flexible unions. */ + if (!warned && errorcount > oldcount) + { + inform (DECL_SOURCE_LOCATION (field), "unrestricted unions " + "only available with -std=c++0x or -std=gnu++0x"); + warned = true; + } } else { -- cgit v1.2.1 From 1767a056f10a2ccbc900df04d01193da73a3d272 Mon Sep 17 00:00:00 2001 From: froydnj Date: Thu, 15 Jul 2010 14:31:28 +0000 Subject: gcc/ * tree.h (DECL_CHAIN): Define. * alias.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-decl.c: Likewise. * c-parser.c: Likewise. * c-typeck.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arm/arm.c: Likewise. * config/frv/frv.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/som.h: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * coverage.c: Likewise. * dbxout.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimplify.c: Likewise. * integrate.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-split.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-type-escape.c: Likewise. * langhooks.c: Likewise. * lto-cgraph.c: Likewise. * omp-low.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-complex.c: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-inline.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-object-size.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-tailcall.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. * gcc-interface/utils2.c: Likewise. gcc/c-family/ * c-common.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-format.c: Likewise. gcc/cp/ * cp-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * call.c: Likewise. * class.c: Likewise. * cp-gimplify.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * init.c: Likewise. * mangle.c: Likewise. * name-lookup.c: Likewise. * optimize.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * rtti.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * f95-lang.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * trans-common.c: Likewise. * trans-decl.c: Likewise. * trans-types.c: Likewise. * trans.c: Likewise. gcc/java/ * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * boehm.c: Likewise. * class.c: Likewise. * decl.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. gcc/objc/ * objc-act.c: Carefully replace TREE_CHAIN with DECL_CHAIN. gcc/testsuite/ * g++.dg/plugin/attribute_plugin.c: Carefully replace TREE_CHAIN with DECL_CHAIN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 98 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index a572af83f63..79b5a26d775 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -469,7 +469,7 @@ build_simple_base_path (tree expr, tree binfo) expr = build_simple_base_path (expr, d_binfo); for (field = TYPE_FIELDS (BINFO_TYPE (d_binfo)); - field; field = TREE_CHAIN (field)) + field; field = DECL_CHAIN (field)) /* Is this the base field created by build_base_field? */ if (TREE_CODE (field) == FIELD_DECL && DECL_FIELD_IS_BASE (field) @@ -1262,7 +1262,7 @@ check_bases (tree t, seen_non_virtual_nearly_empty_base_p = 0; if (!CLASSTYPE_NON_STD_LAYOUT (t)) - for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL) break; @@ -1351,7 +1351,7 @@ check_bases (tree t, members, or has no base classes with non-static data members */ for (basefield = TYPE_FIELDS (basetype); basefield; - basefield = TREE_CHAIN (basefield)) + basefield = DECL_CHAIN (basefield)) if (TREE_CODE (basefield) == FIELD_DECL) { if (field) @@ -1609,7 +1609,7 @@ maybe_warn_about_overly_private_class (tree t) functions are private. (Since there are no friends or non-private statics, we can't ever call any of the private member functions.) */ - for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) + for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn)) /* We're not interested in compiler-generated methods; they don't provide any way to call private members. */ if (!DECL_ARTIFICIAL (fn)) @@ -1814,7 +1814,7 @@ finish_struct_methods (tree t) /* Clear DECL_IN_AGGR_P for all functions. */ for (fn_fields = TYPE_METHODS (t); fn_fields; - fn_fields = TREE_CHAIN (fn_fields)) + fn_fields = DECL_CHAIN (fn_fields)) DECL_IN_AGGR_P (fn_fields) = 0; /* Issue warnings about private constructors and such. If there are @@ -2545,7 +2545,7 @@ finish_struct_anon (tree t) { tree field; - for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) { if (TREE_STATIC (field)) continue; @@ -2557,7 +2557,7 @@ finish_struct_anon (tree t) { bool is_union = TREE_CODE (TREE_TYPE (field)) == UNION_TYPE; tree elt = TYPE_FIELDS (TREE_TYPE (field)); - for (; elt; elt = TREE_CHAIN (elt)) + for (; elt; elt = DECL_CHAIN (elt)) { /* We're generally only interested in entities the user declared, but we also find nested classes by noticing @@ -2750,7 +2750,7 @@ count_fields (tree fields) { tree x; int n_fields = 0; - for (x = fields; x; x = TREE_CHAIN (x)) + for (x = fields; x; x = DECL_CHAIN (x)) { if (TREE_CODE (x) == FIELD_DECL && ANON_AGGR_TYPE_P (TREE_TYPE (x))) n_fields += count_fields (TYPE_FIELDS (TREE_TYPE (x))); @@ -2767,7 +2767,7 @@ static int add_fields_to_record_type (tree fields, struct sorted_fields_type *field_vec, int idx) { tree x; - for (x = fields; x; x = TREE_CHAIN (x)) + for (x = fields; x; x = DECL_CHAIN (x)) { if (TREE_CODE (x) == FIELD_DECL && ANON_AGGR_TYPE_P (TREE_TYPE (x))) idx = add_fields_to_record_type (TYPE_FIELDS (TREE_TYPE (x)), field_vec, idx); @@ -2874,7 +2874,7 @@ check_field_decl (tree field, { tree fields; - for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields)) + for (fields = TYPE_FIELDS (type); fields; fields = DECL_CHAIN (fields)) if (TREE_CODE (fields) == FIELD_DECL && !DECL_C_BIT_FIELD (field)) check_field_decl (fields, t, cant_have_const_ctor, no_const_asn_ref, any_default_members, @@ -2999,12 +2999,12 @@ check_field_decls (tree t, tree *access_decls, tree type = TREE_TYPE (x); int this_field_access; - next = &TREE_CHAIN (x); + next = &DECL_CHAIN (x); if (TREE_CODE (x) == USING_DECL) { /* Prune the access declaration from the list of fields. */ - *field = TREE_CHAIN (x); + *field = DECL_CHAIN (x); /* Save the access declarations for our caller. */ *access_decls = tree_cons (NULL_TREE, x, *access_decls); @@ -3439,7 +3439,7 @@ walk_subobject_offsets (tree type, } /* Iterate through the fields of TYPE. */ - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !DECL_ARTIFICIAL (field)) { tree field_offset; @@ -3788,9 +3788,9 @@ build_base_field (record_layout_info rli, tree binfo, objects of the same type at the same address. */ layout_nonempty_base_or_field (rli, decl, binfo, offsets); /* Add the new FIELD_DECL to the list of fields for T. */ - TREE_CHAIN (decl) = *next_field; + DECL_CHAIN (decl) = *next_field; *next_field = decl; - next_field = &TREE_CHAIN (decl); + next_field = &DECL_CHAIN (decl); } } else @@ -3902,7 +3902,7 @@ check_methods (tree t) { tree x; - for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x)) + for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x)) { check_for_override (x, t); if (DECL_PURE_VIRTUAL_P (x) && ! DECL_VINDEX (x)) @@ -3941,8 +3941,8 @@ build_clone (tree fn, tree name) /* Remember where this function came from. */ DECL_ABSTRACT_ORIGIN (clone) = fn; /* Make it easy to find the CLONE given the FN. */ - TREE_CHAIN (clone) = TREE_CHAIN (fn); - TREE_CHAIN (fn) = clone; + DECL_CHAIN (clone) = DECL_CHAIN (fn); + DECL_CHAIN (fn) = clone; /* If this is a template, do the rest on the DECL_TEMPLATE_RESULT. */ if (TREE_CODE (clone) == TEMPLATE_DECL) @@ -4006,8 +4006,8 @@ build_clone (tree fn, tree name) /* Remove the in-charge parameter. */ if (DECL_HAS_IN_CHARGE_PARM_P (clone)) { - TREE_CHAIN (DECL_ARGUMENTS (clone)) - = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone))); + DECL_CHAIN (DECL_ARGUMENTS (clone)) + = DECL_CHAIN (DECL_CHAIN (DECL_ARGUMENTS (clone))); DECL_HAS_IN_CHARGE_PARM_P (clone) = 0; } /* And the VTT parm, in a complete [cd]tor. */ @@ -4017,13 +4017,13 @@ build_clone (tree fn, tree name) DECL_HAS_VTT_PARM_P (clone) = 1; else { - TREE_CHAIN (DECL_ARGUMENTS (clone)) - = TREE_CHAIN (TREE_CHAIN (DECL_ARGUMENTS (clone))); + DECL_CHAIN (DECL_ARGUMENTS (clone)) + = DECL_CHAIN (DECL_CHAIN (DECL_ARGUMENTS (clone))); DECL_HAS_VTT_PARM_P (clone) = 0; } } - for (parms = DECL_ARGUMENTS (clone); parms; parms = TREE_CHAIN (parms)) + for (parms = DECL_ARGUMENTS (clone); parms; parms = DECL_CHAIN (parms)) { DECL_CONTEXT (parms) = clone; cxx_dup_lang_specific_decl (parms); @@ -4086,8 +4086,8 @@ clone_function_decl (tree fn, int update_method_vec_p) tree clone; /* Avoid inappropriate cloning. */ - if (TREE_CHAIN (fn) - && DECL_CLONED_FUNCTION_P (TREE_CHAIN (fn))) + if (DECL_CHAIN (fn) + && DECL_CLONED_FUNCTION_P (DECL_CHAIN (fn))) return; if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn)) @@ -4144,8 +4144,8 @@ adjust_clone_args (tree decl) { tree clone; - for (clone = TREE_CHAIN (decl); clone && DECL_CLONED_FUNCTION_P (clone); - clone = TREE_CHAIN (clone)) + for (clone = DECL_CHAIN (decl); clone && DECL_CLONED_FUNCTION_P (clone); + clone = DECL_CHAIN (clone)) { tree orig_clone_parms = TYPE_ARG_TYPES (TREE_TYPE (clone)); tree orig_decl_parms = TYPE_ARG_TYPES (TREE_TYPE (decl)); @@ -4416,9 +4416,9 @@ remove_zero_width_bit_fields (tree t) check_bitfield_decl eventually sets DECL_SIZE (*fieldsp) to that width. */ && integer_zerop (DECL_SIZE (*fieldsp))) - *fieldsp = TREE_CHAIN (*fieldsp); + *fieldsp = DECL_CHAIN (*fieldsp); else - fieldsp = &TREE_CHAIN (*fieldsp); + fieldsp = &DECL_CHAIN (*fieldsp); } } @@ -4577,7 +4577,7 @@ check_bases_and_members (tree t) { tree field; - for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) { tree type; @@ -4605,7 +4605,7 @@ check_bases_and_members (tree t) /* Check defaulted declarations here so we have cant_have_const_ctor and don't need to worry about clones. */ - for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) + for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn)) if (DECL_DEFAULTED_IN_CLASS_P (fn)) { int copy = copy_fn_p (fn); @@ -4671,7 +4671,7 @@ create_vtable_ptr (tree t, tree* virtuals_p) tree fn; /* Collect the virtual functions declared in T. */ - for (fn = TYPE_METHODS (t); fn; fn = TREE_CHAIN (fn)) + for (fn = TYPE_METHODS (t); fn; fn = DECL_CHAIN (fn)) if (DECL_VINDEX (fn) && !DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (fn) && TREE_CODE (DECL_VINDEX (fn)) != INTEGER_CST) { @@ -4806,7 +4806,7 @@ layout_virtual_bases (record_layout_info rli, splay_tree offsets) bases will go after the last extant field to date. */ next_field = &TYPE_FIELDS (t); while (*next_field) - next_field = &TREE_CHAIN (*next_field); + next_field = &DECL_CHAIN (*next_field); /* Go through the virtual bases, allocating space for each virtual base that is not already a primary base class. These are @@ -5047,9 +5047,9 @@ layout_class_type (tree t, tree *virtuals_p) /* The vptr is always the first thing in the class. */ if (vptr) { - TREE_CHAIN (vptr) = TYPE_FIELDS (t); + DECL_CHAIN (vptr) = TYPE_FIELDS (t); TYPE_FIELDS (t) = vptr; - next_field = &TREE_CHAIN (vptr); + next_field = &DECL_CHAIN (vptr); place_field (rli, vptr); } else @@ -5061,7 +5061,7 @@ layout_class_type (tree t, tree *virtuals_p) build_base_fields (rli, empty_base_offsets, next_field); /* Layout the non-static data members. */ - for (field = non_static_data_members; field; field = TREE_CHAIN (field)) + for (field = non_static_data_members; field; field = DECL_CHAIN (field)) { tree type; tree padding; @@ -5342,7 +5342,7 @@ layout_class_type (tree t, tree *virtuals_p) /* Copy the fields from T. */ next_field = &TYPE_FIELDS (base_t); - for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL) { *next_field = build_decl (input_location, @@ -5355,7 +5355,7 @@ layout_class_type (tree t, tree *virtuals_p) = DECL_FIELD_BIT_OFFSET (field); DECL_SIZE (*next_field) = DECL_SIZE (field); DECL_MODE (*next_field) = DECL_MODE (field); - next_field = &TREE_CHAIN (*next_field); + next_field = &DECL_CHAIN (*next_field); } /* Record the base version of the type. */ @@ -5402,7 +5402,7 @@ layout_class_type (tree t, tree *virtuals_p) warn_about_ambiguous_bases (t); /* Now that we're done with layout, give the base fields the real types. */ - for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (t); field; field = DECL_CHAIN (field)) if (DECL_ARTIFICIAL (field) && IS_FAKE_BASE_TYPE (TREE_TYPE (field))) TREE_TYPE (field) = TYPE_CONTEXT (TREE_TYPE (field)); @@ -5434,7 +5434,7 @@ determine_key_method (tree type) key function may not be inline; those targets should not call this function until the end of the translation unit. */ for (method = TYPE_METHODS (type); method != NULL_TREE; - method = TREE_CHAIN (method)) + method = DECL_CHAIN (method)) if (DECL_VINDEX (method) != NULL_TREE && ! DECL_DECLARED_INLINE_P (method) && ! DECL_PURE_VIRTUAL_P (method)) @@ -5558,7 +5558,7 @@ finish_struct_1 (tree t) /* Complete the rtl for any static member objects of the type we're working on. */ - for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x)) + for (x = TYPE_FIELDS (t); x; x = DECL_CHAIN (x)) if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x) && TREE_TYPE (x) != error_mark_node && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (x)), t)) @@ -5655,13 +5655,13 @@ unreverse_member_declarations (tree t) x && TREE_CODE (x) != TYPE_DECL; x = next) { - next = TREE_CHAIN (x); - TREE_CHAIN (x) = prev; + next = DECL_CHAIN (x); + DECL_CHAIN (x) = prev; prev = x; } if (prev) { - TREE_CHAIN (TYPE_FIELDS (t)) = x; + DECL_CHAIN (TYPE_FIELDS (t)) = x; if (prev) TYPE_FIELDS (t) = prev; } @@ -5698,7 +5698,7 @@ finish_struct (tree t, tree attributes) CLASSTYPE_PURE_VIRTUALS contains the list of the inline friends (see CLASSTYPE_INLINE_FRIENDS) so we need to clear it. */ CLASSTYPE_PURE_VIRTUALS (t) = NULL; - for (x = TYPE_METHODS (t); x; x = TREE_CHAIN (x)) + for (x = TYPE_METHODS (t); x; x = DECL_CHAIN (x)) if (DECL_PURE_VIRTUAL_P (x)) VEC_safe_push (tree, gc, CLASSTYPE_PURE_VIRTUALS (t), x); complete_vars (t); @@ -6798,7 +6798,7 @@ is_really_empty_class (tree type) BINFO_BASE_ITERATE (binfo, i, base_binfo); ++i) if (!is_really_empty_class (BINFO_TYPE (base_binfo))) return false; - for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field)) + for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) if (TREE_CODE (field) == FIELD_DECL && !DECL_ARTIFICIAL (field) && !is_really_empty_class (TREE_TYPE (field))) @@ -7251,8 +7251,8 @@ build_vtt (tree t) vtt = build_vtable (t, mangle_vtt_for_type (t), type); initialize_artificial_var (vtt, inits); /* Add the VTT to the vtables list. */ - TREE_CHAIN (vtt) = TREE_CHAIN (CLASSTYPE_VTABLES (t)); - TREE_CHAIN (CLASSTYPE_VTABLES (t)) = vtt; + DECL_CHAIN (vtt) = DECL_CHAIN (CLASSTYPE_VTABLES (t)); + DECL_CHAIN (CLASSTYPE_VTABLES (t)) = vtt; dump_vtt (t, vtt); } @@ -8082,7 +8082,7 @@ add_vcall_offset_vtbl_entries_1 (tree binfo, vtbl_init_data* vid) order. G++ 3.2 used the order in the vtable. */ for (orig_fn = TYPE_METHODS (BINFO_TYPE (binfo)); orig_fn; - orig_fn = TREE_CHAIN (orig_fn)) + orig_fn = DECL_CHAIN (orig_fn)) if (DECL_VINDEX (orig_fn)) add_vcall_offset (orig_fn, binfo, vid); } -- cgit v1.2.1 From c1e4c34a522d131403e31e8786f4a11c40d637d9 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 15 Jul 2010 20:45:35 +0000 Subject: PR c++/44909 * call.c (add_function_candidate): If we're working on an implicit declaration, don't consider candidates that won't match. * typeck.c (same_type_ignoring_top_level_qualifiers_p): Now a fn. * cp-tree.h (same_type_ignoring_top_level_qualifiers_p): Adjust. Revert: * cp-tree.h (struct lang_type_class): Add has_user_opeq. (TYPE_HAS_USER_OPEQ): New. * decl.c (grok_special_member_properties): Set it. * class.c (add_implicitly_declared_members): Don't lazily declare constructors/operator= if a base or member has a user-declared one. (check_bases_and_members, check_bases): Adjust. (check_field_decls, check_field_decl): Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162233 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/class.c | 73 +++++++++++----------------------------------------------- 1 file changed, 13 insertions(+), 60 deletions(-) (limited to 'gcc/cp/class.c') diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 79b5a26d775..73bcb7598ee 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -130,7 +130,7 @@ static void finish_struct_methods (tree); static void maybe_warn_about_overly_private_class (tree); static int method_name_cmp (const void *, const void *); static int resort_method_name_cmp (const void *, const void *); -static void add_implicitly_declared_members (tree, int, int, int, int); +static void add_implicitly_declared_members (tree, int, int); static tree fixed_type_or_null (tree, int *, int *); static tree build_simple_base_path (tree expr, tree binfo); static tree build_vtbl_ref_1 (tree, tree); @@ -139,13 +139,13 @@ static void build_vtbl_initializer (tree, tree, tree, tree, int *, static int count_fields (tree); static int add_fields_to_record_type (tree, struct sorted_fields_type*, int); static bool check_bitfield_decl (tree); -static void check_field_decl (tree, tree, int *, int *, int *, int *, int *); -static void check_field_decls (tree, tree *, int *, int *, int *, int *); +static void check_field_decl (tree, tree, int *, int *, int *); +static void check_field_decls (tree, tree *, int *, int *); static tree *build_base_field (record_layout_info, tree, splay_tree, tree *); static void build_base_fields (record_layout_info, splay_tree, tree *); static void check_methods (tree); static void remove_zero_width_bit_fields (tree); -static void check_bases (tree, int *, int *, int *, int *); +static void check_bases (tree, int *, int *); static void check_bases_and_members (tree); static tree create_vtable_ptr (tree, tree *); static void include_empty_classes (record_layout_info); @@ -1249,9 +1249,7 @@ handle_using_decl (tree using_decl, tree t) static void check_bases (tree t, int* cant_have_const_ctor_p, - int* no_const_asn_ref_p, - int* cant_have_lazy_ctor, - int* cant_have_lazy_opeq) + int* no_const_asn_ref_p) { int i; int seen_non_virtual_nearly_empty_base_p; @@ -1290,10 +1288,6 @@ check_bases (tree t, if (TYPE_HAS_COPY_ASSIGN (basetype) && !TYPE_HAS_CONST_COPY_ASSIGN (basetype)) *no_const_asn_ref_p = 1; - if (TYPE_HAS_USER_CONSTRUCTOR (basetype)) - *cant_have_lazy_ctor = 1; - if (TYPE_HAS_USER_OPEQ (basetype)) - *cant_have_lazy_opeq = 1; if (BINFO_VIRTUAL_P (base_binfo)) /* A virtual base does not effect nearly emptiness. */ @@ -2634,9 +2628,7 @@ maybe_add_class_template_decl_list (tree type, tree t, int friend_p) static void add_implicitly_declared_members (tree t, int cant_have_const_cctor, - int cant_have_const_assignment, - int cant_have_lazy_ctor, - int cant_have_lazy_opeq) + int cant_have_const_assignment) { /* Destructor. */ if (!CLASSTYPE_DESTRUCTORS (t)) @@ -2690,26 +2682,6 @@ add_implicitly_declared_members (tree t, CLASSTYPE_LAZY_MOVE_ASSIGN (t) = 1; } - /* If a base or member type has a user-declared constructor or operator=, - we need to declare ours now to avoid issues with circular lazy - declarations (cpp0x/implicit6.C). */ - if (cant_have_lazy_ctor) - { - if (CLASSTYPE_LAZY_DEFAULT_CTOR (t)) - lazily_declare_fn (sfk_constructor, t); - if (CLASSTYPE_LAZY_COPY_CTOR (t)) - lazily_declare_fn (sfk_copy_constructor, t); - if (CLASSTYPE_LAZY_MOVE_CTOR (t)) - lazily_declare_fn (sfk_move_constructor, t); - } - if (cant_have_lazy_opeq) - { - if (CLASSTYPE_LAZY_COPY_ASSIGN (t)) - lazily_declare_fn (sfk_copy_assignment, t); - if (CLASSTYPE_LAZY_MOVE_ASSIGN (t)) - lazily_declare_fn (sfk_move_assignment, t); - } - /* We can't be lazy about declaring functions that might override a virtual function from a base class. */ if (TYPE_POLYMORPHIC_P (t) @@ -2858,9 +2830,7 @@ check_field_decl (tree field, tree t, int* cant_have_const_ctor, int* no_const_asn_ref, - int* any_default_members, - int* cant_have_lazy_ctor, - int* cant_have_lazy_opeq) + int* any_default_members) { tree type = strip_array_types (TREE_TYPE (field)); @@ -2877,8 +2847,7 @@ check_field_decl (tree field, for (fields = TYPE_FIELDS (type); fields; fields = DECL_CHAIN (fields)) if (TREE_CODE (fields) == FIELD_DECL && !DECL_C_BIT_FIELD (field)) check_field_decl (fields, t, cant_have_const_ctor, - no_const_asn_ref, any_default_members, - cant_have_lazy_ctor, cant_have_lazy_opeq); + no_const_asn_ref, any_default_members); } /* Check members with class type for constructors, destructors, etc. */ @@ -2930,11 +2899,6 @@ check_field_decl (tree field, if (TYPE_HAS_COPY_ASSIGN (type) && !TYPE_HAS_CONST_COPY_ASSIGN (type)) *no_const_asn_ref = 1; - - if (TYPE_HAS_USER_CONSTRUCTOR (type)) - *cant_have_lazy_ctor = 1; - if (TYPE_HAS_USER_OPEQ (type)) - *cant_have_lazy_opeq = 1; } if (DECL_INITIAL (field) != NULL_TREE) { @@ -2974,9 +2938,7 @@ check_field_decl (tree field, static void check_field_decls (tree t, tree *access_decls, int *cant_have_const_ctor_p, - int *no_const_asn_ref_p, - int *cant_have_lazy_ctor_p, - int *cant_have_lazy_opeq_p) + int *no_const_asn_ref_p) { tree *field; tree *next; @@ -3168,9 +3130,7 @@ check_field_decls (tree t, tree *access_decls, check_field_decl (x, t, cant_have_const_ctor_p, no_const_asn_ref_p, - &any_default_members, - cant_have_lazy_ctor_p, - cant_have_lazy_opeq_p); + &any_default_members); /* If any field is const, the structure type is pseudo-const. */ if (CP_TYPE_CONST_P (type)) @@ -4493,8 +4453,6 @@ check_bases_and_members (tree t) /* Nonzero if the implicitly generated assignment operator should take a non-const reference argument. */ int no_const_asn_ref; - int cant_have_lazy_ctor = 0; - int cant_have_lazy_opeq = 0; tree access_decls; bool saved_complex_asn_ref; bool saved_nontrivial_dtor; @@ -4507,8 +4465,7 @@ check_bases_and_members (tree t) /* Check all the base-classes. */ check_bases (t, &cant_have_const_ctor, - &no_const_asn_ref, &cant_have_lazy_ctor, - &cant_have_lazy_opeq); + &no_const_asn_ref); /* Check all the method declarations. */ check_methods (t); @@ -4525,9 +4482,7 @@ check_bases_and_members (tree t) being set appropriately. */ check_field_decls (t, &access_decls, &cant_have_const_ctor, - &no_const_asn_ref, - &cant_have_lazy_ctor, - &cant_have_lazy_opeq); + &no_const_asn_ref); /* A nearly-empty class has to be vptr-containing; a nearly empty class contains just a vptr. */ @@ -4599,9 +4554,7 @@ check_bases_and_members (tree t) /* Synthesize any needed methods. */ add_implicitly_declared_members (t, cant_have_const_ctor, - no_const_asn_ref, - cant_have_lazy_ctor, - cant_have_lazy_opeq); + no_const_asn_ref); /* Check defaulted declarations here so we have cant_have_const_ctor and don't need to worry about clones. */ -- cgit v1.2.1