From 32d008d96c324cc44d8a92b38cb67ed33e24f040 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 4 Jul 2009 04:34:03 +0000 Subject: PR c++/40619 * cp-tree.h (struct lang_decl_parm): New. (struct lang_decl): Add it. (LANG_DECL_PARM_CHECK): New. (DECL_PARM_INDEX): New. * decl2.c (parm_index): Remove. * lex.c (retrofit_lang_decl): Handle parms. (cxx_dup_lang_specific_decl): Likewise. * mangle.c (write_expression): Adjust. * tree.c (cp_tree_equal): Adjust. (decl_linkage): Only check DECL_COMDAT for functions and variables. * parser.c (cp_parser_parameter_declaration_list): Set DECL_PARM_INDEX. * pt.c (iterative_hash_template_arg): Hash it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7c48a3257b3..644e53cef9f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1997,7 +1997,7 @@ cp_tree_equal (tree t1, tree t2) /* For comparing uses of parameters in late-specified return types with an out-of-class definition of the function. */ if (same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)) - && parm_index (t1) == parm_index (t2)) + && DECL_PARM_INDEX (t1) == DECL_PARM_INDEX (t2)) return true; else return false; @@ -2723,7 +2723,8 @@ decl_linkage (tree decl) template instantiations have internal linkage (in the object file), but the symbols should still be treated as having external linkage from the point of view of the language. */ - if (TREE_CODE (decl) != TYPE_DECL && DECL_LANG_SPECIFIC (decl) + if ((TREE_CODE (decl) == FUNCTION_DECL + || TREE_CODE (decl) == VAR_DECL) && DECL_COMDAT (decl)) return lk_external; -- cgit v1.2.1 From 407d66f28ec9aeff9605fd481b43d553bb956b7c Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 12 Jul 2009 19:19:15 +0000 Subject: * cp-tree.h (enum cp_lvalue_kind_flags): Add clk_rvalueref. * tree.c (lvalue_p_1): Return it. Remove treat_class_rvalues_as_lvalues parm. (real_lvalue_p): Disallow pseudo-lvalues here. (lvalue_or_rvalue_with_address_p): New fn. * call.c (initialize_reference): Use it instead of real_lvalue_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149534 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 75 ++++++++++++++++++++++++++++------------------------------- 1 file changed, 36 insertions(+), 39 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 644e53cef9f..698138808ce 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -44,7 +44,7 @@ static tree build_cplus_array_type_1 (tree, tree); static int list_hash_eq (const void *, const void *); static hashval_t list_hash_pieces (tree, tree, tree); static hashval_t list_hash (const void *); -static cp_lvalue_kind lvalue_p_1 (const_tree, int); +static cp_lvalue_kind lvalue_p_1 (const_tree); static tree build_target_expr (tree, tree); static tree count_trees_r (tree *, int *, void *); static tree verify_stmt_tree_r (tree *, int *, void *); @@ -55,12 +55,10 @@ static tree handle_com_interface_attribute (tree *, tree, tree, int, bool *); static tree handle_init_priority_attribute (tree *, tree, tree, int, bool *); /* If REF is an lvalue, returns the kind of lvalue that REF is. - Otherwise, returns clk_none. If TREAT_CLASS_RVALUES_AS_LVALUES is - nonzero, rvalues of class type are considered lvalues. */ + Otherwise, returns clk_none. */ static cp_lvalue_kind -lvalue_p_1 (const_tree ref, - int treat_class_rvalues_as_lvalues) +lvalue_p_1 (const_tree ref) { cp_lvalue_kind op1_lvalue_kind = clk_none; cp_lvalue_kind op2_lvalue_kind = clk_none; @@ -72,8 +70,7 @@ lvalue_p_1 (const_tree ref, if (TREE_CODE (ref) == INDIRECT_REF && TREE_CODE (TREE_TYPE (TREE_OPERAND (ref, 0))) == REFERENCE_TYPE) - return lvalue_p_1 (TREE_OPERAND (ref, 0), - treat_class_rvalues_as_lvalues); + return lvalue_p_1 (TREE_OPERAND (ref, 0)); if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE) { @@ -82,12 +79,7 @@ lvalue_p_1 (const_tree ref, && TREE_CODE (ref) != PARM_DECL && TREE_CODE (ref) != VAR_DECL && TREE_CODE (ref) != COMPONENT_REF) - { - if (CLASS_TYPE_P (TREE_TYPE (TREE_TYPE (ref)))) - return treat_class_rvalues_as_lvalues ? clk_class : clk_none; - else - return clk_none; - } + return clk_rvalueref; /* lvalue references and named rvalue references are lvalues. */ return clk_ordinary; @@ -108,12 +100,10 @@ lvalue_p_1 (const_tree ref, case WITH_CLEANUP_EXPR: case REALPART_EXPR: case IMAGPART_EXPR: - return lvalue_p_1 (TREE_OPERAND (ref, 0), - treat_class_rvalues_as_lvalues); + return lvalue_p_1 (TREE_OPERAND (ref, 0)); case COMPONENT_REF: - op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0), - treat_class_rvalues_as_lvalues); + op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0)); /* Look at the member designator. */ if (!op1_lvalue_kind) ; @@ -164,35 +154,28 @@ lvalue_p_1 (const_tree ref, if (TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 0)) || TREE_SIDE_EFFECTS (TREE_OPERAND (ref, 1))) return clk_none; - op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0), - treat_class_rvalues_as_lvalues); - op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1), - treat_class_rvalues_as_lvalues); + op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 0)); + op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1)); break; case COND_EXPR: op1_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 1) ? TREE_OPERAND (ref, 1) - : TREE_OPERAND (ref, 0), - treat_class_rvalues_as_lvalues); - op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2), - treat_class_rvalues_as_lvalues); + : TREE_OPERAND (ref, 0)); + op2_lvalue_kind = lvalue_p_1 (TREE_OPERAND (ref, 2)); break; case MODIFY_EXPR: return clk_ordinary; case COMPOUND_EXPR: - return lvalue_p_1 (TREE_OPERAND (ref, 1), - treat_class_rvalues_as_lvalues); + return lvalue_p_1 (TREE_OPERAND (ref, 1)); case TARGET_EXPR: - return treat_class_rvalues_as_lvalues ? clk_class : clk_none; + return clk_class; case VA_ARG_EXPR: - return (treat_class_rvalues_as_lvalues - && CLASS_TYPE_P (TREE_TYPE (ref)) - ? clk_class : clk_none); + return (CLASS_TYPE_P (TREE_TYPE (ref)) ? clk_class : clk_none); case CALL_EXPR: /* Any class-valued call would be wrapped in a TARGET_EXPR. */ @@ -209,8 +192,7 @@ lvalue_p_1 (const_tree ref, with a BASELINK. */ /* This CONST_CAST is okay because BASELINK_FUNCTIONS returns its argument unmodified and we assign it to a const_tree. */ - return lvalue_p_1 (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref)), - treat_class_rvalues_as_lvalues); + return lvalue_p_1 (BASELINK_FUNCTIONS (CONST_CAST_TREE (ref))); case NON_DEPENDENT_EXPR: /* We must consider NON_DEPENDENT_EXPRs to be lvalues so that @@ -246,18 +228,33 @@ lvalue_p_1 (const_tree ref, cp_lvalue_kind real_lvalue_p (tree ref) { - return lvalue_p_1 (ref, - /*treat_class_rvalues_as_lvalues=*/0); + cp_lvalue_kind kind = lvalue_p_1 (ref); + if (kind & (clk_rvalueref|clk_class)) + return clk_none; + else + return kind; } -/* This differs from real_lvalue_p in that class rvalues are - considered lvalues. */ +/* This differs from real_lvalue_p in that class rvalues are considered + lvalues. */ bool lvalue_p (const_tree ref) { - return - (lvalue_p_1 (ref, /*class rvalue ok*/ 1) != clk_none); + return (lvalue_p_1 (ref) != clk_none); +} + +/* This differs from real_lvalue_p in that rvalues formed by dereferencing + rvalue references are considered rvalues. */ + +bool +lvalue_or_rvalue_with_address_p (const_tree ref) +{ + cp_lvalue_kind kind = lvalue_p_1 (ref); + if (kind & clk_class) + return false; + else + return (kind != clk_none); } /* Test whether DECL is a builtin that may appear in a -- cgit v1.2.1 From 6ff64d86e5e63794fa292620a25212c292f904df Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 12 Jul 2009 21:10:09 +0000 Subject: PR c++/36628 * tree.c (rvalue): Use lvalue_or_rvalue_with_address_p. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149536 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 698138808ce..a003b44e9de 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -532,7 +532,9 @@ rvalue (tree expr) if (!CLASS_TYPE_P (type) && cp_type_quals (type)) type = TYPE_MAIN_VARIANT (type); - if (!processing_template_decl && real_lvalue_p (expr)) + /* We need to do this for rvalue refs as well to get the right answer + from decltype; see c++/36628. */ + if (!processing_template_decl && lvalue_or_rvalue_with_address_p (expr)) expr = build1 (NON_LVALUE_EXPR, type, expr); else if (type != TREE_TYPE (expr)) expr = build_nop (type, expr); -- 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/tree.c | 116 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 94 insertions(+), 22 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index a003b44e9de..255a297de6f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2238,36 +2238,108 @@ is_dummy_object (const_tree ob) && TREE_OPERAND (ob, 0) == void_zero_node); } +/* Returns 1 iff type T is something we want to treat as a scalar type for + the purpose of deciding whether it is trivial/POD/standard-layout. */ + +static bool +scalarish_type_p (const_tree t) +{ + if (t == error_mark_node) + return 1; + + return (SCALAR_TYPE_P (t) + || TREE_CODE (t) == VECTOR_TYPE); +} + +/* Returns true iff T requires non-trivial default initialization. */ + +bool +type_has_nontrivial_default_init (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return TYPE_HAS_COMPLEX_DFLT (t); + else + return 0; +} + +/* Returns true iff copying an object of type T is non-trivial. */ + +bool +type_has_nontrivial_copy_init (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return TYPE_HAS_COMPLEX_INIT_REF (t); + else + return 0; +} + +/* Returns 1 iff type T is a trivial type, as defined in [basic.types]. */ + +bool +trivial_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !(TYPE_HAS_COMPLEX_DFLT (t) + || TYPE_HAS_COMPLEX_INIT_REF (t) + || TYPE_HAS_COMPLEX_ASSIGN_REF (t) + || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)); + else + return scalarish_type_p (t); +} + /* Returns 1 iff type T is a POD type, as defined in [basic.types]. */ -int +bool pod_type_p (const_tree t) { /* This CONST_CAST is okay because strip_array_types returns its argument unmodified and we assign it to a const_tree. */ t = strip_array_types (CONST_CAST_TREE(t)); - if (t == error_mark_node) - return 1; - if (INTEGRAL_OR_ENUMERATION_TYPE_P (t)) - return 1; /* integral, character or enumeral type */ - if (FLOAT_TYPE_P (t)) - return 1; - if (TYPE_PTR_P (t)) - return 1; /* pointer to non-member */ - if (TYPE_PTR_TO_MEMBER_P (t)) - return 1; /* pointer to member */ - - if (TREE_CODE (t) == VECTOR_TYPE) - return 1; /* vectors are (small) arrays of scalars */ - - if (! RECORD_OR_UNION_CODE_P (TREE_CODE (t))) - return 0; /* other non-class type (reference or function) */ - if (! CLASS_TYPE_P (t)) - return 1; /* struct created by the back end */ - if (CLASSTYPE_NON_POD_P (t)) - return 0; - return 1; + if (CLASS_TYPE_P (t)) + /* [class]/10: A POD struct is a class that is both a trivial class and a + standard-layout class, and has no non-static data members of type + non-POD struct, non-POD union (or array of such types). + + We don't need to check individual members because if a member is + non-std-layout or non-trivial, the class will be too. */ + return (std_layout_type_p (t) && trivial_type_p (t)); + else + return scalarish_type_p (t); +} + +/* Returns true iff T is POD for the purpose of layout, as defined in the + C++ ABI. */ + +bool +layout_pod_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !CLASSTYPE_NON_LAYOUT_POD_P (t); + else + return scalarish_type_p (t); +} + +/* Returns true iff T is a standard-layout type, as defined in + [basic.types]. */ + +bool +std_layout_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return !CLASSTYPE_NON_STD_LAYOUT (t); + else + return scalarish_type_p (t); } /* Nonzero iff type T is a class template implicit specialization. */ -- 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/tree.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 255a297de6f..83869c17a1b 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1595,7 +1595,8 @@ cxx_print_statistics (void) tree array_type_nelts_top (tree type) { - return fold_build2 (PLUS_EXPR, sizetype, + return fold_build2_loc (input_location, + PLUS_EXPR, sizetype, array_type_nelts (type), size_one_node); } @@ -1612,7 +1613,8 @@ array_type_nelts_total (tree type) while (TREE_CODE (type) == ARRAY_TYPE) { tree n = array_type_nelts_top (type); - sz = fold_build2 (MULT_EXPR, sizetype, sz, n); + sz = fold_build2_loc (input_location, + MULT_EXPR, sizetype, sz, n); type = TREE_TYPE (type); } return sz; -- cgit v1.2.1 From dddfd70ebaf761566514211a848dc368f044aacb Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 1 Aug 2009 02:26:13 +0000 Subject: * typeck.c (build_address): Do fold away ADDR_EXPR of INDIRECT_REF. * tree.c (rvalue): Use cp_build_qualified_type, not TYPE_MAIN_VARIANT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150324 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 83869c17a1b..cbadf0438b6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -530,7 +530,7 @@ rvalue (tree expr) Non-class rvalues always have cv-unqualified types. */ type = TREE_TYPE (expr); if (!CLASS_TYPE_P (type) && cp_type_quals (type)) - type = TYPE_MAIN_VARIANT (type); + type = cp_build_qualified_type (type, TYPE_UNQUALIFIED); /* We need to do this for rvalue refs as well to get the right answer from decltype; see c++/36628. */ -- cgit v1.2.1 From f52203692f3c4f9c2fa234520c36e237cb69fd29 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 1 Aug 2009 02:26:21 +0000 Subject: * call.c (reference_binding): Rename lvalue_p to is_lvalue. Do direct binding of "rvalues" in memory to rvalue references. * tree.c (lvalue_p_1): Can't be both non-addressable lvalue and "rvalue" in memory. * typeck.c (build_static_cast_1): Do direct binding of memory "rvalues" to rvalue references. * cvt.c (cp_fold_convert): New. * cp-tree.h: Declare it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150325 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index cbadf0438b6..9e194fca444 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -214,10 +214,14 @@ lvalue_p_1 (const_tree ref) /* Otherwise, it's an lvalue, and it has all the odd properties contributed by either operand. */ op1_lvalue_kind = op1_lvalue_kind | op2_lvalue_kind; - /* It's not an ordinary lvalue if it involves either a bit-field or - a class rvalue. */ + /* It's not an ordinary lvalue if it involves any other kind. */ if ((op1_lvalue_kind & ~clk_ordinary) != clk_none) op1_lvalue_kind &= ~clk_ordinary; + /* It can't be both a pseudo-lvalue and a non-addressable lvalue. + A COND_EXPR of those should be wrapped in a TARGET_EXPR. */ + if ((op1_lvalue_kind & (clk_rvalueref|clk_class)) + && (op1_lvalue_kind & (clk_bitfield|clk_packed))) + op1_lvalue_kind = clk_none; return op1_lvalue_kind; } -- cgit v1.2.1 From 1ce32159f7e7f8ded35c60f44193904780c61ea0 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 17 Aug 2009 11:03:59 +0000 Subject: 2009-08-16 Richard Guenther * decl.c (build_ptrmemfunc_type): Keep variant chain intact. Avoid useless copy. (finish_enum): Keep variant chain intact. * tree.c (cp_build_reference_type): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150839 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9e194fca444..1a406a30690 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -700,12 +700,11 @@ cp_build_reference_type (tree to_type, bool rval) if (TYPE_REF_IS_RVALUE (t)) return t; - t = copy_node (lvalue_ref); + t = build_distinct_type_copy (lvalue_ref); TYPE_REF_IS_RVALUE (t) = true; TYPE_NEXT_REF_TO (t) = TYPE_NEXT_REF_TO (lvalue_ref); TYPE_NEXT_REF_TO (lvalue_ref) = t; - TYPE_MAIN_VARIANT (t) = t; if (TYPE_STRUCTURAL_EQUALITY_P (to_type)) SET_TYPE_STRUCTURAL_EQUALITY (t); -- cgit v1.2.1 From 77288dfba13c459ad6359d418f542ddbf6b48105 Mon Sep 17 00:00:00 2001 From: jakub Date: Fri, 21 Aug 2009 07:08:15 +0000 Subject: PR c++/41131 * tree.c (lvalue_p_1) : Return clk_none if not TREE_STATIC. * g++.dg/expr/unary3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@150985 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 1a406a30690..f09b036e334 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -132,6 +132,12 @@ lvalue_p_1 (const_tree ref) return clk_ordinary; case CONST_DECL: + /* CONST_DECL without TREE_STATIC are enumeration values and + thus not lvalues. With TREE_STATIC they are used by ObjC++ + in objc_build_string_object and need to be considered as + lvalues. */ + if (! TREE_STATIC (ref)) + return clk_none; case VAR_DECL: if (TREE_READONLY (ref) && ! TREE_STATIC (ref) && DECL_LANG_SPECIFIC (ref) -- cgit v1.2.1 From 34e5cced0545b23499caed535a6566a4026b9558 Mon Sep 17 00:00:00 2001 From: dnovillo Date: Thu, 3 Sep 2009 04:07:12 +0000 Subject: 2009-09-01 Diego Novillo * c-lang.c (lang_hooks): Remove const qualifier. java/ChangeLog * lang.c (lang_hooks): Remove const qualifier. objc/ChangeLog * objc-lang.c (lang_hooks): Remove const qualifier. objcp/ChangeLog * objcp-lang.c (lang_hooks): Remove const qualifier. ada/ChangeLog * gcc-interface/misc.c (lang_hooks): Remove const qualifier. fortran/ChangeLog * f95-lang.c (lang_hooks): Remove const qualifier. cp/ChangeLog * cp-lang.c (lang_hooks): Remove const qualifier. 2009-09-01 Diego Novillo * cgraph.c (cgraph_node_for_decl): New. * cgraph.h (cgraph_node_for_decl): Declare. * tree.c (host_integerp): Return 0 if T is NULL. 2009-09-01 Diego Novillo * tree.h (struct alias_pair): Move from varasm.c. (alias_pairs): Likewise. (TYPE_MAXVAL): Define. (TYPE_MINVAL): Define. (iterative_hash_host_wide_int): Declare. (remove_unreachable_alias_pairs): Declare. * tree-pass.h (pass_ipa_free_lang_data): Declare. * diagnostic.c (default_diagnostic_starter): Make extern. (default_diagnostic_finalizer): Make extern. * diagnostic.h (default_diagnostic_starter): Declare. (default_diagnostic_finalizer): Declare. (default_tree_printer): Declare. * toplev.c (default_tree_printer): Make extern. 2009-09-01 Richard Guenther Diego Novillo * cgraph.c (cgraph_add_new_function): Remove gimplification. * cgraphunit.c (cgraph_expand_function): Do not emit associated thunks from here. (cgraph_emit_thunks): New. (cgraph_optimize): Call it. Return if any IPA pass finds an error. * varasm.c (finish_aliases_1): Ignore errorneous aliases used by thunks. 2009-09-01 Simon Baldwin Rafael Espindola Richard Guenther Doug Kwan Diego Novillo * tree.c: Include tree-pass.h, langhooks-def.h, diagnostic.h, cgraph.h, timevar.h, except.h and debug.h. (free_lang_data_in_type): New. (need_assembler_name_p): New. (free_lang_data_in_block): New. (free_lang_data_in_decl): New. (struct free_lang_data_d): New. (add_tree_to_fld_list): New. (find_decls_types_r): New. (get_eh_types_for_runtime): New. (find_decls_types_in_eh_region): New. (find_decls_types_in_node): New. (find_decls_types_in_var): New. (free_lang_data_in_cgraph): New. (free_lang_data): New. (gate_free_lang_data): New. (pass_ipa_free_lang_data): New. 2009-09-01 Diego Novillo * timevar.def (TV_IPA_FREE_LANG_DATA): Define. * langhooks.h (struct lang_hooks): Add field free_lang_data. (lang_hooks): Remove const qualifier. * ipa.c (cgraph_remove_unreachable_nodes): Call remove_unreachable_alias_pairs. * except.c (add_type_for_runtime): Check if TYPE has already been converted. (lookup_type_for_runtime): Likewise. (check_handled): Handle converted types. * varasm.c (remove_unreachable_alias_pairs): New. * gimple.c: Include demangle.h. (gimple_decl_printable_name): New. (gimple_fold_obj_type_ref): New. * gimple.h (gimple_decl_printable_name): Declare. (gimple_fold_obj_type_ref): Declare. * passes.c (init_optimization_passes): Add pass pass_ipa_free_lang_data. * langhooks-def.h (LANG_HOOKS_FREE_LANG_DATA): Define. (LANG_HOOKS_INITIALIZER): Add LANG_HOOKS_FREE_LANG_DATA. testsuite/ChangeLog 2009-09-01 Diego Novillo * gcc.dg/gomp/combined-1.c: Adjust expected pattern. * g++.dg/tree-prof/inline_mismatch_args.C: Likewise. * g++.dg/warn/unit-1.C: Likewise. * g++.dg/ipa/iinline-1.C: Likewise. * g++.dg/template/cond2.C: Adjust expected line location for the error. * g++.dg/template/pr35240.C: Likewise. cp/ChangeLog 2009-09-01 Doug Kwan * tree.c (cp_fix_function_decl_p): New. (cp_free_lang_data): New. 2009-09-01 Diego Novillo * Make-lang.in (decl2.o): Add dependency on $(POINTER_SET_H). * decl2.c: Include pointer-set.h. (collect_candidates_for_java_method_aliases): New. (cp_write_global_declarations): Call it. Add local variable CANDIDATES. If set, call build_java_method_aliases. (build_java_method_aliases): Add argument CANDIDATES. Use it to determine if FNDECL should get a hidden alias. * cp-objcp-common.h (LANG_HOOKS_FREE_LANG_DATA): Define. * cp-tree.h (cp_free_lang_data): Declare. 2009-09-03 Richard Guenther * method.c (use_thunk): Use cgraph_finalize_function to hand off thunks to the cgraph. * semantics.c (emit_associated_thunks): Do not emit thunks for really extern functions. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151360 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f09b036e334..808a18a48ad 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3030,6 +3030,53 @@ cast_valid_in_integral_constant_expression_p (tree type) || type == error_mark_node); } +/* Return true if we need to fix linkage information of DECL. */ + +static bool +cp_fix_function_decl_p (tree decl) +{ + /* Skip if DECL is not externally visible. */ + if (!TREE_PUBLIC (decl)) + return false; + + /* We need to fix DECL if it a appears to be exported but with no + function body. Thunks do not have CFGs and we may need to + handle them specially later. */ + if (!gimple_has_body_p (decl) + && !DECL_THUNK_P (decl) + && !DECL_EXTERNAL (decl)) + return true; + + return false; +} + +/* Clean the C++ specific parts of the tree T. */ + +void +cp_free_lang_data (tree t) +{ + if (TREE_CODE (t) == METHOD_TYPE + || TREE_CODE (t) == FUNCTION_TYPE) + { + /* Default args are not interesting anymore. */ + tree argtypes = TYPE_ARG_TYPES (t); + while (argtypes) + { + TREE_PURPOSE (argtypes) = 0; + argtypes = TREE_CHAIN (argtypes); + } + } + else if (TREE_CODE (t) == FUNCTION_DECL + && cp_fix_function_decl_p (t)) + { + /* If T is used in this translation unit at all, the definition + must exist somewhere else since we have decided to not emit it + in this TU. So make it an external reference. */ + DECL_EXTERNAL (t) = 1; + TREE_STATIC (t) = 0; + } +} + #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) /* Complain that some language-specific thing hanging off a tree -- cgit v1.2.1 From 5f34abf8eb3649c6e1181795469b04845a982b30 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 18 Sep 2009 21:25:18 +0000 Subject: * decl2.c (determine_visibility): Make anonymous types internal. (mark_used): Complain about types without linkage used in decls with internal linkage. (vague_linkage_fn_p): Split out from... * decl.c (maybe_commonize_var): ...here. (grokdeclarator): Adjust linkage when a typedef gives linkage name. * tree.c (no_linkage_check): Check the enclosing class and template arguments. * cp-tree.h (TYPE_NAMESPACE_SCOPE_P): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151868 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 808a18a48ad..51752a3f040 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1513,7 +1513,7 @@ verify_stmt_tree (tree t) /* Check if the type T depends on a type with no linkage and if so, return it. If RELAXED_P then do not consider a class type declared within - a TREE_PUBLIC function to have no linkage. */ + a vague-linkage function to have no linkage. */ tree no_linkage_check (tree t, bool relaxed_p) @@ -1527,8 +1527,6 @@ no_linkage_check (tree t, bool relaxed_p) switch (TREE_CODE (t)) { - tree fn; - case RECORD_TYPE: if (TYPE_PTRMEMFUNC_P (t)) goto ptrmem; @@ -1536,13 +1534,42 @@ no_linkage_check (tree t, bool relaxed_p) case UNION_TYPE: if (!CLASS_TYPE_P (t)) return NULL_TREE; + + /* Check template type-arguments. I think that types with no linkage + can't occur in non-type arguments, though that might change with + constexpr. */ + r = CLASSTYPE_TEMPLATE_INFO (t); + if (r) + { + tree args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (r)); + int i; + + for (i = TREE_VEC_LENGTH (args); i-- > 0; ) + { + tree elt = TREE_VEC_ELT (args, i); + if (TYPE_P (elt) + && (r = no_linkage_check (elt, relaxed_p), r)) + return r; + } + } /* Fall through. */ case ENUMERAL_TYPE: - if (TYPE_ANONYMOUS_P (t)) - return t; - fn = decl_function_context (TYPE_MAIN_DECL (t)); - if (fn && (!relaxed_p || !TREE_PUBLIC (fn))) + /* Only treat anonymous types as having no linkage if they're at + namespace scope. This doesn't have a core issue number yet. */ + if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) return t; + + r = CP_TYPE_CONTEXT (t); + if (TYPE_P (r)) + return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); + else if (TREE_CODE (r) == FUNCTION_DECL) + { + if (!relaxed_p || !TREE_PUBLIC (r) || !vague_linkage_fn_p (r)) + return t; + else + return no_linkage_check (CP_DECL_CONTEXT (r), relaxed_p); + } + return NULL_TREE; case ARRAY_TYPE: -- cgit v1.2.1 From 6cc8fdd3628f50206a1f6c865b90b0df24a5e284 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 21 Sep 2009 16:11:26 +0000 Subject: PR c++/41421 * tree.c (trivial_type_p): Fix logic. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151932 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 51752a3f040..fb812e23303 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2323,10 +2323,10 @@ trivial_type_p (const_tree t) t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return !(TYPE_HAS_COMPLEX_DFLT (t) - || TYPE_HAS_COMPLEX_INIT_REF (t) - || TYPE_HAS_COMPLEX_ASSIGN_REF (t) - || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t)); + return (TYPE_HAS_TRIVIAL_DFLT (t) + && TYPE_HAS_TRIVIAL_INIT_REF (t) + && TYPE_HAS_TRIVIAL_ASSIGN_REF (t) + && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else return scalarish_type_p (t); } -- 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/tree.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index fb812e23303..7476aa03a43 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -456,6 +456,22 @@ build_cplus_new (tree type, tree init) return rval; } +/* Return a TARGET_EXPR which expresses the direct-initialization of one + array from another. */ + +tree +build_array_copy (tree init) +{ + tree type = TREE_TYPE (init); + tree slot = build_local_temp (type); + init = build2 (VEC_INIT_EXPR, type, slot, init); + SET_EXPR_LOCATION (init, input_location); + init = build_target_expr (slot, init); + TARGET_EXPR_IMPLICIT_P (init) = 1; + + return init; +} + /* Build a TARGET_EXPR using INIT to initialize a new temporary of the indicated TYPE. */ @@ -726,6 +742,17 @@ cp_build_reference_type (tree to_type, bool rval) } +/* Returns EXPR cast to rvalue reference type, like std::move. */ + +tree +move (tree expr) +{ + tree type = TREE_TYPE (expr); + gcc_assert (TREE_CODE (type) != REFERENCE_TYPE); + type = cp_build_reference_type (type, /*rval*/true); + return build_static_cast (type, expr, tf_warning_or_error); +} + /* Used by the C++ front end to build qualified array types. However, the C version of this function does not properly maintain canonical types (which are not used in C). */ @@ -1558,6 +1585,8 @@ no_linkage_check (tree t, bool relaxed_p) namespace scope. This doesn't have a core issue number yet. */ if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) return t; + if (no_linkage_lambda_type_p (t)) + return t; r = CP_TYPE_CONTEXT (t); if (TYPE_P (r)) @@ -2759,6 +2788,8 @@ special_function_p (const_tree decl) DECL_LANG_SPECIFIC. */ if (DECL_COPY_CONSTRUCTOR_P (decl)) return sfk_copy_constructor; + if (DECL_MOVE_CONSTRUCTOR_P (decl)) + return sfk_move_constructor; if (DECL_CONSTRUCTOR_P (decl)) return sfk_constructor; if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR) -- cgit v1.2.1 From 17814acad9a3e3e11971c7f6a01c32e6e1ce26bf Mon Sep 17 00:00:00 2001 From: gdr Date: Thu, 1 Oct 2009 05:13:56 +0000 Subject: gcc/ * tree.h (tree_decl_common::lang_flag_8): New. * c-common.c (c_common_reswords): Include "constexpr" as C++0x keyword. * c-common.h (RID_CONSTEXPR): New. gcc/cp/ * decl.c (check_for_uninitialized_const_var): Check constexpr variables too. (build_ptrmemfunc_type): Make the result a literal type. (build_ptrmem_type): Likewise. (grokdeclarator): Handle `constexpr'. (check_tag_decl): Reject `constexpr'. (check_function_type): Check constexpr functions. * cp-tree.h (ds_constexpr): New cp_decl_spec enumerator. (CLASSTYPE_LITERAL_P): New. (lang_type_class::is_literal): New. (lang_type_class::dummy): Adjust width. (literal_type_p): Declare. * parser.c (cp_parser_check_decl_spec): Print it. (cp_parser_decl_specifier_seq): Accept "constexpr". * semantics.c (validate_constexpr_fundecl): Define. (literal_type_p): Define. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152358 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7476aa03a43..19a1270b76d 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -639,7 +639,7 @@ build_cplus_array_type_1 (tree elt_type, tree index_type) else { /* Build a new array type. */ - t = make_node (ARRAY_TYPE); + t = cxx_make_type (ARRAY_TYPE); TREE_TYPE (t) = elt_type; TYPE_DOMAIN (t) = index_type; @@ -942,7 +942,6 @@ cp_build_qualified_type_real (tree type, && (TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result)) == TYPE_LANG_SPECIFIC (TYPE_CANONICAL (type)))) TYPE_LANG_SPECIFIC (TYPE_CANONICAL (result)) = NULL; - return result; } -- cgit v1.2.1 From 18515bc1685c19b5b619abcd84282c73e0324447 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 2 Oct 2009 04:33:51 +0000 Subject: * parser.c (cp_parser_lambda_expression): Compute visibility. (no_linkage_lambda_type_p): Remove. * cp-tree.h: Remove declaration. * tree.c (no_linkage_check): Don't call it. Don't check template args. Don't check TREE_PUBLIC Types. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152395 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 49 ++++++++++++++++++++++--------------------------- 1 file changed, 22 insertions(+), 27 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 19a1270b76d..1cd2bf596f8 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1556,46 +1556,41 @@ no_linkage_check (tree t, bool relaxed_p) case RECORD_TYPE: if (TYPE_PTRMEMFUNC_P (t)) goto ptrmem; + /* Lambda types that don't have mangling scope have no linkage. We + check CLASSTYPE_LAMBDA_EXPR here rather than LAMBDA_TYPE_P because + when we get here from pushtag none of the lambda information is + set up yet, so we want to assume that the lambda has linkage and + fix it up later if not. */ + if (CLASSTYPE_LAMBDA_EXPR (t) + && LAMBDA_TYPE_EXTRA_SCOPE (t) == NULL_TREE) + return t; /* Fall through. */ case UNION_TYPE: if (!CLASS_TYPE_P (t)) return NULL_TREE; - - /* Check template type-arguments. I think that types with no linkage - can't occur in non-type arguments, though that might change with - constexpr. */ - r = CLASSTYPE_TEMPLATE_INFO (t); - if (r) - { - tree args = INNERMOST_TEMPLATE_ARGS (TI_ARGS (r)); - int i; - - for (i = TREE_VEC_LENGTH (args); i-- > 0; ) - { - tree elt = TREE_VEC_ELT (args, i); - if (TYPE_P (elt) - && (r = no_linkage_check (elt, relaxed_p), r)) - return r; - } - } /* Fall through. */ case ENUMERAL_TYPE: /* Only treat anonymous types as having no linkage if they're at namespace scope. This doesn't have a core issue number yet. */ if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) return t; - if (no_linkage_lambda_type_p (t)) - return t; - r = CP_TYPE_CONTEXT (t); - if (TYPE_P (r)) - return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); - else if (TREE_CODE (r) == FUNCTION_DECL) + for (r = CP_TYPE_CONTEXT (t); ; ) { - if (!relaxed_p || !TREE_PUBLIC (r) || !vague_linkage_fn_p (r)) - return t; + /* If we're a nested type of a !TREE_PUBLIC class, we might not + have linkage, or we might just be in an anonymous namespace. + If we're in a TREE_PUBLIC class, we have linkage. */ + if (TYPE_P (r) && !TREE_PUBLIC (TYPE_NAME (r))) + return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); + else if (TREE_CODE (r) == FUNCTION_DECL) + { + if (!relaxed_p || !vague_linkage_fn_p (r)) + return t; + else + r = CP_DECL_CONTEXT (r); + } else - return no_linkage_check (CP_DECL_CONTEXT (r), relaxed_p); + break; } return NULL_TREE; -- cgit v1.2.1 From bc9c0de9117b33db60cd5fb612ddce611bded92c Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 7 Oct 2009 18:56:28 +0000 Subject: PR c++/41038 * tree.c (build_qualified_name): Call convert_from_reference. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152536 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 1cd2bf596f8..156a09e25a6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1284,6 +1284,8 @@ build_qualified_name (tree type, tree scope, tree name, bool template_p) return error_mark_node; t = build2 (SCOPE_REF, type, scope, name); QUALIFIED_NAME_IS_TEMPLATE (t) = template_p; + if (type) + t = convert_from_reference (t); return t; } -- cgit v1.2.1 From 1fc8cb4337139f3aafcb14052788dd2d4613d3c8 Mon Sep 17 00:00:00 2001 From: rguenth Date: Sun, 11 Oct 2009 16:29:57 +0000 Subject: 2009-10-11 Richard Guenther * gimple.c (iterative_hash_type_name): Do not handle special anonymous names. cp/ * tree.c (cp_free_lang_data): Drop anonymous aggregate names. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152643 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 156a09e25a6..76763735b97 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3129,6 +3129,17 @@ cp_free_lang_data (tree t) DECL_EXTERNAL (t) = 1; TREE_STATIC (t) = 0; } + if (CP_AGGREGATE_TYPE_P (t) + && TYPE_NAME (t)) + { + tree name = TYPE_NAME (t); + if (TREE_CODE (name) == TYPE_DECL) + name = DECL_NAME (name); + /* Drop anonymous names. */ + if (name != NULL_TREE + && ANON_AGGRNAME_P (name)) + TYPE_NAME (t) = NULL_TREE; + } } -- cgit v1.2.1 From 6eb7b44b4bf3f69a6286df51dbb06acc6bb10072 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 14 Oct 2009 06:27:41 +0000 Subject: PR c++/40092 * tree.c (cp_tree_equal): Add test for TEMPLATE_PARM_PARAMETER_PACK equality. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152751 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 76763735b97..99ce6562070 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2081,6 +2081,8 @@ cp_tree_equal (tree t1, tree t2) case TEMPLATE_PARM_INDEX: return (TEMPLATE_PARM_IDX (t1) == TEMPLATE_PARM_IDX (t2) && TEMPLATE_PARM_LEVEL (t1) == TEMPLATE_PARM_LEVEL (t2) + && (TEMPLATE_PARM_PARAMETER_PACK (t1) + == TEMPLATE_PARM_PARAMETER_PACK (t2)) && same_type_p (TREE_TYPE (TEMPLATE_PARM_DECL (t1)), TREE_TYPE (TEMPLATE_PARM_DECL (t2)))); -- cgit v1.2.1 From 749ecbf670139a223544beca3160e1ce86d8a440 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 1 Nov 2009 05:07:00 +0000 Subject: * tree.c (cv_unqualified): New fn. * cp-tree.h: Declare it. * typeck.c (decay_conversion): Use it instead of TYPE_MAIN_VARIANT. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153790 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 99ce6562070..b79093a36d5 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -946,6 +946,16 @@ cp_build_qualified_type_real (tree type, return result; } +/* Return TYPE with const and volatile removed. */ + +tree +cv_unqualified (tree type) +{ + int quals = TYPE_QUALS (type); + quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE); + return cp_build_qualified_type (type, quals); +} + /* Builds a qualified variant of T that is not a typedef variant. E.g. consider the following declarations: typedef const int ConstInt; -- 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/tree.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index b79093a36d5..5aea55e792f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1050,6 +1050,10 @@ strip_typedefs (tree t) else result = build_function_type (type, arg_types); + + if (TYPE_RAISES_EXCEPTIONS (t)) + result = build_exception_variant (result, + TYPE_RAISES_EXCEPTIONS (t)); } break; default: @@ -1058,6 +1062,8 @@ strip_typedefs (tree t) if (!result) result = TYPE_MAIN_VARIANT (t); + if (TYPE_ATTRIBUTES (t)) + result = cp_build_type_attribute_variant (result, TYPE_ATTRIBUTES (t)); return cp_build_qualified_type (result, cp_type_quals (t)); } @@ -2609,7 +2615,8 @@ cp_build_type_attribute_variant (tree type, tree attributes) tree new_type; new_type = build_type_attribute_variant (type, attributes); - if (TREE_CODE (new_type) == FUNCTION_TYPE + if ((TREE_CODE (new_type) == FUNCTION_TYPE + || TREE_CODE (new_type) == METHOD_TYPE) && (TYPE_RAISES_EXCEPTIONS (new_type) != TYPE_RAISES_EXCEPTIONS (type))) new_type = build_exception_variant (new_type, -- cgit v1.2.1 From f3943982534f64948d4c4de6b2005ec60451c076 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 12 Nov 2009 18:25:51 +0000 Subject: * typeck.c (cv_qualified_p): New fn. (decay_conversion): Use it. * cp-tree.h: Declare it. * tree.c (rvalue): Use it and cv_unqualified. * init.c (build_aggr_init): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154125 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5aea55e792f..9dae1843616 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -555,8 +555,8 @@ rvalue (tree expr) Non-class rvalues always have cv-unqualified types. */ type = TREE_TYPE (expr); - if (!CLASS_TYPE_P (type) && cp_type_quals (type)) - type = cp_build_qualified_type (type, TYPE_UNQUALIFIED); + if (!CLASS_TYPE_P (type) && cv_qualified_p (type)) + type = cv_unqualified (type); /* We need to do this for rvalue refs as well to get the right answer from decltype; see c++/36628. */ -- cgit v1.2.1 From 2e6a4932c6fc77dc57413586a49ef3584cde4967 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 13 Nov 2009 14:40:13 +0000 Subject: PR c++/11987 * parser.c (cp_parser_direct_declarator): Give helpful error about trying to define member of a dependent typedef. * pt.c (resolve_typename_type): Don't resolve a typedef typename. * tree.c (typedef_variant_p): New. * cp-tree.h: Declare it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154149 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9dae1843616..f9e1cd707a9 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1067,6 +1067,14 @@ strip_typedefs (tree t) return cp_build_qualified_type (result, cp_type_quals (t)); } +/* Returns true iff TYPE is a type variant created for a typedef. */ + +bool +typedef_variant_p (tree type) +{ + return is_typedef_decl (TYPE_NAME (type)); +} + /* Makes a copy of BINFO and TYPE, which is to be inherited into a graph dominated by T. If BINFO is NULL, TYPE is a dependent base, -- cgit v1.2.1 From b08c380313684bcfc1c94802bc1a266235a1066d Mon Sep 17 00:00:00 2001 From: dodji Date: Mon, 23 Nov 2009 13:29:50 +0000 Subject: Fix PR c++/14777 gcc/cp/ChangeLog: PR c++/14777 * cp-tree.def : Declare new kind of tree node. * cp-tree.h (struct tree_template_info, struct qualified_typedef_usage_s): New. (cp_tree_node_structure_enum): add TS_CP_TEMPLATE_INFO. (union lang_tree_node): Add template_info. (TI_TEMPLATE, TI_ARGS, TI_TYPEDEFS_NEEDING_ACCESS_CHECKING): Adjust. (build_template_info): Declare. (get_types_needing_access_check): Adjust return type. (add_typedef_to_current_template_for_access_check): Declare. * cp-objcp-common.c (cp_tree_size): Handle TEMPLATE_INFO. * semantics.c (add_typedef_to_current_template_for_access_check): Split from ... (check_accessibility_of_qualified_id): ... here. * decl.c (make_typename_type): Use it. * pt.c (build_template_info): Define. (check_explicit_specialization, find_parameter_packs_r, push_template_decl_real, lookup_template_class, for_each_template_parm_r, tsubst_decl, tsubst): Use build_template_info. (get_types_needing_access_check): Adjust return type. (append_type_to_template_for_access_check_1): Record the location of the usage point of the typedef. Adjust to TEMPLATE_INFO. (append_type_to_template_for_access_check): Add new location parameter. Pass it to append_type_to_template_for_access_check_1. Adjust to TEMPLATE_INFO. (perform_typedefs_access_check): Temporarily set input_location to the usage point of the typedef we are checking access for. Adjust to new TEMPLATE_INFO tree node. * tree.c (bind_template_template_parm): Use build_template_info. * call.c (add_template_candidate_real): Likewise. * decl.c (grokfndecl): Likewise. (cp_tree_node_structure): Handle TEMPLATE_INFO. gcc/testsuite/ChangeLog: PR c++/14777 * g++.dg/template/typedef13.C: Adjust. * g++.dg/template/typedef19.C: Adjust. * g++.dg/template/typedef20.C: Adjust. * g++.dg/template/typedef22.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154443 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f9e1cd707a9..d431b3109a6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1490,8 +1490,7 @@ bind_template_template_parm (tree t, tree newargs) TEMPLATE_TYPE_PARM_INDEX (t2) = copy_node (TEMPLATE_TYPE_PARM_INDEX (t)); TEMPLATE_PARM_DECL (TEMPLATE_TYPE_PARM_INDEX (t2)) = decl; TEMPLATE_TEMPLATE_PARM_TEMPLATE_INFO (t2) - = tree_cons (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t), - newargs, NULL_TREE); + = build_template_info (TEMPLATE_TEMPLATE_PARM_TEMPLATE_DECL (t), newargs); TREE_TYPE (decl) = t2; TYPE_NAME (t2) = decl; -- cgit v1.2.1 From e815a7959e4746984d2554bdbe955e3733da6d85 Mon Sep 17 00:00:00 2001 From: jakub Date: Mon, 23 Nov 2009 16:10:19 +0000 Subject: PR middle-end/42095 * tree.c: Include cgraph.h. (cp_fix_function_decl_p): Don't return true for same_body aliases. * Make-lang.in (cp/tree.o): Depend on $(CGRAPH_H). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154449 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d431b3109a6..17fc495c9a3 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -37,6 +37,7 @@ along with GCC; see the file COPYING3. If not see #include "target.h" #include "convert.h" #include "tree-flow.h" +#include "cgraph.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); @@ -3125,7 +3126,16 @@ cp_fix_function_decl_p (tree decl) if (!gimple_has_body_p (decl) && !DECL_THUNK_P (decl) && !DECL_EXTERNAL (decl)) - return true; + { + struct cgraph_node *node = cgraph_get_node (decl); + + /* Don't fix same_body aliases. Although they don't have their own + CFG, they share it with what they alias to. */ + if (!node + || node->decl == decl + || !node->same_body) + return true; + } return false; } -- 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/tree.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 17fc495c9a3..7097f8c68b6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1076,6 +1076,22 @@ typedef_variant_p (tree type) return is_typedef_decl (TYPE_NAME (type)); } +/* Setup a TYPE_DECL node as a typedef representation. + See comments of set_underlying_type in c-common.c. */ + +void +cp_set_underlying_type (tree t) +{ + set_underlying_type (t); + /* If the typedef variant type is dependent, make it require + structural equality. + This is useful when comparing two dependent typedef variant types, + because it forces the comparison of the template parameters of their + decls for instance. */ + if (dependent_type_p (TREE_TYPE (t))) + SET_TYPE_STRUCTURAL_EQUALITY (TREE_TYPE (t)); +} + /* Makes a copy of BINFO and TYPE, which is to be inherited into a graph dominated by T. If BINFO is NULL, TYPE is a dependent base, -- 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/tree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7097f8c68b6..865abbcfdd3 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2292,7 +2292,7 @@ tree build_dummy_object (tree type) { tree decl = build1 (NOP_EXPR, build_pointer_type (type), void_zero_node); - return cp_build_indirect_ref (decl, NULL, tf_warning_or_error); + return cp_build_indirect_ref (decl, RO_NULL, tf_warning_or_error); } /* We've gotten a reference to a member of TYPE. Return *this if appropriate, @@ -2956,7 +2956,7 @@ stabilize_expr (tree exp, tree* initp) exp = cp_build_unary_op (ADDR_EXPR, exp, 1, tf_warning_or_error); init_expr = get_target_expr (exp); exp = TARGET_EXPR_SLOT (init_expr); - exp = cp_build_indirect_ref (exp, 0, tf_warning_or_error); + exp = cp_build_indirect_ref (exp, RO_NULL, tf_warning_or_error); } *initp = init_expr; -- cgit v1.2.1 From 8a03d6ff8dad449a497a6490b84da7cdd5484a80 Mon Sep 17 00:00:00 2001 From: dodji Date: Sat, 19 Dec 2009 22:40:37 +0000 Subject: Fix PR c++/42225, take 2 gcc/cp/ChangeLog: PR c++/42225 * pt.c (push_template_decl_real): Set DECL_CONTEXT of template type parms to their containing template decl. * typeck.c (comp_template_parms_position): Split this from structural_comptypes. (incompatible_template_type_parms_p): Renamed incompatible_dependent_typedefs_p into this. Change the function to handle comparison between TEMPLATE_TYPE_PARMs only. (structural_comptypes): Use comp_template_parms_position in TEMPLATE_TEMPLATE_PARM and BOUND_TEMPLATE_TEMPLATE_PARM cases. Use incompatible_template_type_parms_p in TEMPLATE_TYPE_PARM case. * mangle.c (decl_mangling_context): Template type parms don't have a mangling context. * tree.c (cp_set_underlying_type): Set type structural equality only for TEMPLATE_TYPE_PARMs. gcc/testsuite/ChangeLog: PR c++/42225 * g++.dg/template/typedef26.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155363 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 865abbcfdd3..35d53e862a0 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1083,12 +1083,11 @@ void cp_set_underlying_type (tree t) { set_underlying_type (t); - /* If the typedef variant type is dependent, make it require - structural equality. - This is useful when comparing two dependent typedef variant types, + /* If T is a template type parm, make it require structural equality. + This is useful when comparing two template type parms, because it forces the comparison of the template parameters of their - decls for instance. */ - if (dependent_type_p (TREE_TYPE (t))) + decls. */ + if (TREE_CODE (TREE_TYPE (t)) == TEMPLATE_TYPE_PARM) SET_TYPE_STRUCTURAL_EQUALITY (TREE_TYPE (t)); } -- cgit v1.2.1 From e594b8b8652c1cdfae9b07eda166838a6bb27796 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 27 Jan 2010 19:48:34 +0000 Subject: * gcc/cp/tree.c: Tweak comment in no_linkage_check. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156300 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 35d53e862a0..678c7dd8787 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1612,7 +1612,7 @@ no_linkage_check (tree t, bool relaxed_p) /* Fall through. */ case ENUMERAL_TYPE: /* Only treat anonymous types as having no linkage if they're at - namespace scope. This doesn't have a core issue number yet. */ + namespace scope. This is core issue 966. */ if (TYPE_ANONYMOUS_P (t) && TYPE_NAMESPACE_SCOPE_P (t)) return t; -- cgit v1.2.1 From c63e9a1846e9d6a27f816fe9802820af347e2697 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 12 Feb 2010 19:46:29 +0000 Subject: PR c++/43054 * tree.c (cp_tree_equal): Correct CALL_EXPR logic, handle EXPR_PACK_EXPANSION. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156737 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 678c7dd8787..89ac3ddad38 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2060,7 +2060,9 @@ cp_tree_equal (tree t1, tree t2) arg2 = next_call_expr_arg (&iter2)) if (!cp_tree_equal (arg1, arg2)) return false; - return (arg1 || arg2); + if (arg1 || arg2) + return false; + return true; } case TARGET_EXPR: @@ -2197,6 +2199,10 @@ cp_tree_equal (tree t1, tree t2) return same_type_p (TRAIT_EXPR_TYPE1 (t1), TRAIT_EXPR_TYPE1 (t2)) && same_type_p (TRAIT_EXPR_TYPE2 (t1), TRAIT_EXPR_TYPE2 (t2)); + case EXPR_PACK_EXPANSION: + return cp_tree_equal (PACK_EXPANSION_PATTERN (t1), + PACK_EXPANSION_PATTERN (t2)); + default: break; } -- cgit v1.2.1 From 9250582227e9bf1c4649cf95034bc2c092496cc9 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 12 Feb 2010 20:00:06 +0000 Subject: revert unnecessary hunk git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156738 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 89ac3ddad38..d2ab4f0f679 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2199,10 +2199,6 @@ cp_tree_equal (tree t1, tree t2) return same_type_p (TRAIT_EXPR_TYPE1 (t1), TRAIT_EXPR_TYPE1 (t2)) && same_type_p (TRAIT_EXPR_TYPE2 (t1), TRAIT_EXPR_TYPE2 (t2)); - case EXPR_PACK_EXPANSION: - return cp_tree_equal (PACK_EXPANSION_PATTERN (t1), - PACK_EXPANSION_PATTERN (t2)); - default: break; } -- cgit v1.2.1 From b98e1bbcc047c22622b2dfcb5963b99db9b43cca Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 16 Feb 2010 06:05:09 +0000 Subject: PR c++/43036 * tree.c (build_cplus_array_type): Set TYPE_MAIN_VARIANT to strip cv-quals from element here. (cp_build_qualified_type_real): Not here. Preserve typedef name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156792 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 84 +++++++++++++++++++++++------------------------------------ 1 file changed, 33 insertions(+), 51 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d2ab4f0f679..31b54f6ce9c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -41,7 +41,6 @@ along with GCC; see the file COPYING3. If not see static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); -static tree build_cplus_array_type_1 (tree, tree); static int list_hash_eq (const void *, const void *); static hashval_t list_hash_pieces (tree, tree, tree); static hashval_t list_hash (const void *); @@ -601,14 +600,14 @@ cplus_array_compare (const void * k1, const void * k2) return (TREE_TYPE (t1) == t2->type && TYPE_DOMAIN (t1) == t2->domain); } -/* Hash table containing all of the C++ array types, including - dependent array types and array types whose element type is - cv-qualified. */ +/* Hash table containing dependent array types, which are unsuitable for + the language-independent type hash table. */ static GTY ((param_is (union tree_node))) htab_t cplus_array_htab; +/* Like build_array_type, but handle special C++ semantics. */ -static tree -build_cplus_array_type_1 (tree elt_type, tree index_type) +tree +build_cplus_array_type (tree elt_type, tree index_type) { tree t; @@ -665,6 +664,20 @@ build_cplus_array_type_1 (tree elt_type, tree index_type) else t = build_array_type (elt_type, index_type); + /* We want TYPE_MAIN_VARIANT of an array to strip cv-quals from the + element type as well, so fix it up if needed. */ + if (elt_type != TYPE_MAIN_VARIANT (elt_type)) + { + tree m = build_cplus_array_type (TYPE_MAIN_VARIANT (elt_type), + index_type); + if (TYPE_MAIN_VARIANT (t) != m) + { + TYPE_MAIN_VARIANT (t) = m; + TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); + TYPE_NEXT_VARIANT (m) = t; + } + } + /* Push these needs up so that initialization takes place more easily. */ TYPE_NEEDS_CONSTRUCTING (t) @@ -674,23 +687,6 @@ build_cplus_array_type_1 (tree elt_type, tree index_type) return t; } -tree -build_cplus_array_type (tree elt_type, tree index_type) -{ - tree t; - int type_quals = cp_type_quals (elt_type); - - if (type_quals != TYPE_UNQUALIFIED) - elt_type = cp_build_qualified_type (elt_type, TYPE_UNQUALIFIED); - - t = build_cplus_array_type_1 (elt_type, index_type); - - if (type_quals != TYPE_UNQUALIFIED) - t = cp_build_qualified_type (t, type_quals); - - return t; -} - /* Return an ARRAY_TYPE with element type ELT and length N. */ tree @@ -811,41 +807,27 @@ cp_build_qualified_type_real (tree type, if (element_type == error_mark_node) return error_mark_node; - /* See if we already have an identically qualified type. */ + /* See if we already have an identically qualified type. Tests + should be equivalent to those in check_qualified_type. */ for (t = TYPE_MAIN_VARIANT (type); t; t = TYPE_NEXT_VARIANT (t)) if (cp_type_quals (t) == type_quals && TYPE_NAME (t) == TYPE_NAME (type) - && TYPE_CONTEXT (t) == TYPE_CONTEXT (type)) + && TYPE_CONTEXT (t) == TYPE_CONTEXT (type) + && attribute_list_equal (TYPE_ATTRIBUTES (t), + TYPE_ATTRIBUTES (type))) break; if (!t) - { - t = build_cplus_array_type_1 (element_type, TYPE_DOMAIN (type)); + { + t = build_cplus_array_type (element_type, TYPE_DOMAIN (type)); - if (TYPE_MAIN_VARIANT (t) != TYPE_MAIN_VARIANT (type)) - { - /* Set the main variant of the newly-created ARRAY_TYPE - (with cv-qualified element type) to the main variant of - the unqualified ARRAY_TYPE we started with. */ - tree last_variant = t; - tree m = TYPE_MAIN_VARIANT (type); - - /* Find the last variant on the new ARRAY_TYPEs list of - variants, setting the main variant of each of the other - types to the main variant of our unqualified - ARRAY_TYPE. */ - while (TYPE_NEXT_VARIANT (last_variant)) - { - TYPE_MAIN_VARIANT (last_variant) = m; - last_variant = TYPE_NEXT_VARIANT (last_variant); - } - - /* Splice in the newly-created variants. */ - TYPE_NEXT_VARIANT (last_variant) = TYPE_NEXT_VARIANT (m); - TYPE_NEXT_VARIANT (m) = t; - TYPE_MAIN_VARIANT (last_variant) = m; - } - } + /* Keep the typedef name. */ + if (TYPE_NAME (t) != TYPE_NAME (type)) + { + t = build_variant_type_copy (t); + TYPE_NAME (t) = TYPE_NAME (type); + } + } /* Even if we already had this variant, we update TYPE_NEEDS_CONSTRUCTING and TYPE_HAS_NONTRIVIAL_DESTRUCTOR in case -- cgit v1.2.1 From 1b155d83801a3a893dee9445d57f244f2a61ca40 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 3 Mar 2010 19:01:46 +0000 Subject: PR c++/12909 * method.c (make_alias_for): Handle VAR_DECL, too. * decl2.c (vague_linkage_p): Rename from vague_linkage_fn_p. * tree.c (no_linkage_check): Adjust. * decl.c (maybe_commonize_var): Adjust. * mangle.c (mangle_decl): Adjust. * cp-tree.h: Adjust. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157202 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 31b54f6ce9c..9867d2efb66 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1607,7 +1607,7 @@ no_linkage_check (tree t, bool relaxed_p) return no_linkage_check (TYPE_CONTEXT (t), relaxed_p); else if (TREE_CODE (r) == FUNCTION_DECL) { - if (!relaxed_p || !vague_linkage_fn_p (r)) + if (!relaxed_p || !vague_linkage_p (r)) return t; else r = CP_DECL_CONTEXT (r); -- cgit v1.2.1 From 8288b81821db8ce394a0c9cc7a73e82241a71044 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 22 Mar 2010 20:38:57 +0000 Subject: PR c++/43333 * tree.c (pod_type_p): Use old meaning in C++98 mode. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157652 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9867d2efb66..35b0da62ea5 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2390,7 +2390,9 @@ pod_type_p (const_tree t) argument unmodified and we assign it to a const_tree. */ t = strip_array_types (CONST_CAST_TREE(t)); - if (CLASS_TYPE_P (t)) + if (!CLASS_TYPE_P (t)) + return scalarish_type_p (t); + else if (cxx_dialect > cxx98) /* [class]/10: A POD struct is a class that is both a trivial class and a standard-layout class, and has no non-static data members of type non-POD struct, non-POD union (or array of such types). @@ -2399,7 +2401,8 @@ pod_type_p (const_tree t) non-std-layout or non-trivial, the class will be too. */ return (std_layout_type_p (t) && trivial_type_p (t)); else - return scalarish_type_p (t); + /* The C++98 definition of POD is different. */ + return !CLASSTYPE_NON_LAYOUT_POD_P (t); } /* Returns true iff T is POD for the purpose of layout, as defined in the -- cgit v1.2.1 From a9f5259f080a1c114a6de06f2ec67730e4e50f13 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 7 Apr 2010 15:54:29 +0000 Subject: * pt.c (print_template_statistics): New. * cp-tree.h: Declare it. * tree.c (cxx_print_statistics): Call it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158072 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 35b0da62ea5..27ced53a2b4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1664,6 +1664,7 @@ cxx_print_statistics (void) { print_search_statistics (); print_class_statistics (); + print_template_statistics (); #ifdef GATHER_STATISTICS fprintf (stderr, "maximum template instantiation depth reached: %d\n", depth_reached); -- cgit v1.2.1 From f501341978079e3f868d8404d409d6ca6f5929de Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 20:08:47 +0000 Subject: PR c++/43790 * tree.c (cv_unqualified): Handle error_mark_node. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158801 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 27ced53a2b4..0abc12ccd57 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -934,7 +934,12 @@ cp_build_qualified_type_real (tree type, tree cv_unqualified (tree type) { - int quals = TYPE_QUALS (type); + int quals; + + if (type == error_mark_node) + return type; + + quals = TYPE_QUALS (type); quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE); return cp_build_qualified_type (type, quals); } -- 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/tree.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 0abc12ccd57..f8b2c403af4 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2293,11 +2293,11 @@ maybe_dummy_object (tree type, tree* binfop) { tree decl, context; tree binfo; + tree current = current_nonlambda_class_type (); - if (current_class_type - && (binfo = lookup_base (current_class_type, type, - ba_unique | ba_quiet, NULL))) - context = current_class_type; + if (current + && (binfo = lookup_base (current, type, ba_any, NULL))) + context = current; else { /* Reference from a nested class member function. */ @@ -2315,6 +2315,13 @@ maybe_dummy_object (tree type, tree* binfop) && same_type_p (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)), current_class_type)) decl = current_class_ref; + else if (current != current_class_type + && context == nonlambda_method_basetype ()) + /* In a lambda, need to go through 'this' capture. */ + decl = (cp_build_indirect_ref + ((lambda_expr_this_capture + (CLASSTYPE_LAMBDA_EXPR (current_class_type))), + RO_NULL, tf_warning_or_error)); else decl = build_dummy_object (context); -- cgit v1.2.1 From 1f07118efd627bef5aed88db1f9d840ce6ab743f Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:35:17 +0000 Subject: * tree.c (get_fns): Split out from get_first_fn. * cp-tree.h: Declare it. * search.c (shared_member_p): Use it. * semantics.c (finish_qualified_id_expr): Simplify. (finish_id_expression): Simplify. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158810 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f8b2c403af4..4d25cac186c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1352,7 +1352,7 @@ really_overloaded_fn (tree x) } tree -get_first_fn (tree from) +get_fns (tree from) { gcc_assert (is_overloaded_fn (from)); /* A baselink is also considered an overloaded function. */ @@ -1363,7 +1363,13 @@ get_first_fn (tree from) from = BASELINK_FUNCTIONS (from); if (TREE_CODE (from) == TEMPLATE_ID_EXPR) from = TREE_OPERAND (from, 0); - return OVL_CURRENT (from); + return from; +} + +tree +get_first_fn (tree from) +{ + return OVL_CURRENT (get_fns (from)); } /* Return a new OVL node, concatenating it with the old one. */ -- cgit v1.2.1 From fbb73d9bb6980aacb2366cbde38d255de0fde0fe Mon Sep 17 00:00:00 2001 From: dodji Date: Thu, 6 May 2010 06:52:30 +0000 Subject: C++ support for -Wunused-but-set-variable gcc/cp/ChangeLog: PR 18624 * cp-tree.h (mark_exp_read, mark_rvalue_use, mark_lvalue_use, mark_type_use): Declare ... * expr.c (mark_exp_read, mark_rvalue_use, mark_lvalue_use, mark_type_use): ... new fns. * typeck.c (cxx_sizeof_expr, cxx_alignof_expr): Call mark_type_use. (perform_integral_promotions): Call mark_rvalue_use. (cp_build_unary_op): Call mark_lvalue_use. (decay_conversion): Update comment. Call mark_lvalue. * decl.c (unused_but_set_errorcount): New variable. (poplevel): Issue -Wunused-but-set-variable diagnostics. (duplicate_decls): Merge DECL_READ_P flags. (start_cleanup_fn): Set DECL_READ_P flag. (finish_function): Issue -Wunused-but-set-parameter diagnostics. * tree.c (rvalue): Call mark_rvalue_use. * pt.c (convert_nontype_argument): Likewise. * semantics.c (finish_typeof, finish_decltype_type): Call mark_type_use. (finish_asm_stmt): Call mark_lvalue_use. (finish_expr_stmt): Call mark_exp_read. * call.c (convert_like_real) : Call mark_rvalue_use. (build_x_va_arg): Call mark_lvalue_use. (build_over_call): Call mark_type_use. * init.c (build_new, build_delete): Call mark_value_use. * rtti.c (build_typeid): Call mark_lvalue_use or mark_type_use. (build_dynamic_cast_1): call mark_lvalue_use or mark_rvalue_use. gcc/testsuite/ChangeLog: PR 18624 * g++.dg/warn/Wunused-7.C: Add dg-warning. * g++.dg/template/sfinae16.C: Likewise. * gcc.dg/Wunused-var-1.c: Moved to... * c-c++-common/Wunused-var-1.c: ...here. New test. * gcc.dg/Wunused-var-2.c: Moved to... * c-c++-common/Wunused-var-2.c: ...here. New test. * gcc.dg/Wunused-var-3.c: Moved to... * c-c++-common/Wunused-var-3.c: ...here. New test. * gcc.dg/Wunused-var-4.c: Moved to... * gcc.dg/Wunused-var-1.c: ... here. * gcc.dg/Wunused-var-5.c: Moved to... * c-c++-common/Wunused-var-4.c: ...here. New test. * gcc.dg/Wunused-var-7.c: Moved to... * c-c++-common/Wunused-var-5.c: ...here. New test. * gcc.dg/Wunused-var-6.c: Moved to... * gcc.dg/Wunused-var-2.c: ... here. * c-c++-common/Wunused-var-1.c: New test. * c-c++-common/Wunused-var-2.c: New test. * c-c++-common/Wunused-var-3.c: New test. * c-c++-common/Wunused-var-4.c: New test. * c-c++-common/Wunused-var-5.c: New test. * g++.dg/warn/Wunused-var-1.C: New test. * g++.dg/warn/Wunused-var-2.C: New test. * g++.dg/warn/Wunused-var-3.C: New test. * g++.dg/warn/Wunused-var-4.C: New test. * g++.dg/warn/Wunused-var-5.C: New test. * g++.dg/warn/Wunused-var-6.C: New test. * g++.dg/warn/Wunused-var-7.C: New test. * g++.dg/warn/Wunused-var-8.C: New test. * g++.dg/warn/Wunused-parm-1.C: New test. * g++.dg/warn/Wunused-parm-2.C: New test. * g++.dg/warn/Wunused-parm-3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159096 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 4d25cac186c..67bbd600af7 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -551,6 +551,8 @@ rvalue (tree expr) if (error_operand_p (expr)) return expr; + expr = mark_rvalue_use (expr); + /* [basic.lval] Non-class rvalues always have cv-unqualified types. */ -- cgit v1.2.1 From 8ce390427438cd93ede36ccf2bc1db8288d22cce Mon Sep 17 00:00:00 2001 From: froydnj Date: Tue, 18 May 2010 23:45:21 +0000 Subject: gcc/ * tree.h (build_call_list): Remove. * tree.c (build_call_list): Remove. gcc/ada/ * gcc-interface/trans.c (call_to_gnu): Use build_call_vec instead of build_call_list. * gcc-interface/utils.c (build_function_stub): Likewise. gcc/cp/ * tree.c (build_min_non_dep_call_vec): Update comment. gcc/java/ * expr.c (expand_java_multianewarray): Use build_call_vec instead of build_call_list. (pop_arguments): Return a VEC instead of a tree. Take a method type rather than a list of argument types. (rewrite_rule): Change signature. of rewrite_arglist member. (rewrite_arglist_getcaller): Update signature. (rewrite_arglist_getclass): Likewise. (maybe_rewrite_invocation): Update for rewrite_arglist change. (build_known_method_ref): Take a VEC instead of a tree. (invoke_build_dtable): Likewise. (expand_invoke): Update calls to pop_arguments. Use build_call_vec instead of build_call_list. (build_jni_stub): Use build_call_vec instead of build_call_list. * java-tree.h (maybe_rewrite_invocation): Update declaration. (build_known_method_ref): Likewise. (invoke_build_dtable): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159548 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 67bbd600af7..bfe65b8418f 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1905,9 +1905,9 @@ build_min_non_dep (enum tree_code code, tree non_dep, ...) return t; } -/* Similar to `build_call_list', but for template definitions of non-dependent - expressions. NON_DEP is the non-dependent expression that has been - built. */ +/* Similar to `build_nt_call_vec', but for template definitions of + non-dependent expressions. NON_DEP is the non-dependent expression + that has been built. */ tree build_min_non_dep_call_vec (tree non_dep, tree fn, VEC(tree,gc) *argvec) -- cgit v1.2.1 From 2ec4852152c3aae79ca3fa23033a15c2944af530 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 19 May 2010 21:01:50 +0000 Subject: PR c++/44193 * typeck.c (type_memfn_quals): New fn. (apply_memfn_quals): New fn. (cp_type_quals): Return TYPE_UNQUALIFIED for FUNCTION_TYPE. (cp_type_readonly): Use cp_type_quals. * cp-tree.h: Add declarations. * tree.c (cp_build_qualified_type_real): Don't set, but do preserve, quals on FUNCTION_TYPE. (strip_typedefs): Use apply_memfn_quals and type_memfn_quals. * decl.c (build_ptrmem_type): Likewise. (grokdeclarator): Likewise. (static_fn_type): Likewise. * decl2.c (change_return_type): Likewise. (cp_reconstruct_complex_type): Likewise. * pt.c (tsubst_function_type): Likewise. (unify): Likewise. (tsubst): Likewise. Drop special FUNCTION_TYPE substitution code. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159596 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index bfe65b8418f..04bfae0b1ee 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -868,12 +868,17 @@ cp_build_qualified_type_real (tree type, [dcl.ref], [dcl.fct] */ if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE) && (TREE_CODE (type) == REFERENCE_TYPE + || TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)) { bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); } + /* But preserve any function-cv-quals on a FUNCTION_TYPE. */ + if (TREE_CODE (type) == FUNCTION_TYPE) + type_quals |= type_memfn_quals (type); + /* A restrict-qualified type must be a pointer (or reference) to object or incomplete type. */ if ((type_quals & TYPE_QUAL_RESTRICT) @@ -1038,8 +1043,11 @@ strip_typedefs (tree t) TREE_CHAIN (arg_types)); } else + { result = build_function_type (type, arg_types); + result = apply_memfn_quals (result, type_memfn_quals (t)); + } if (TYPE_RAISES_EXCEPTIONS (t)) result = build_exception_variant (result, -- cgit v1.2.1 From 5211f81075c70f192e346a7e33ec9d5412c2f9a0 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 19 May 2010 21:02:03 +0000 Subject: * decl.c (grokdeclarator): Don't check quals on fn type. * typeck.c (cp_apply_type_quals_to_decl): Likewise. * tree.c (cp_build_qualified_type_real): Simplify qualifier checking. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159597 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 04bfae0b1ee..e34a69cf6ba 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -865,13 +865,15 @@ cp_build_qualified_type_real (tree type, } /* A reference or method type shall not be cv-qualified. - [dcl.ref], [dcl.fct] */ + [dcl.ref], [dcl.fct]. This used to be an error, but as of DR 295 + (in CD1) we always ignore extra cv-quals on functions. */ if (type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE) && (TREE_CODE (type) == REFERENCE_TYPE || TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)) { - bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); + if (TREE_CODE (type) == REFERENCE_TYPE) + bad_quals |= type_quals & (TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); type_quals &= ~(TYPE_QUAL_CONST | TYPE_QUAL_VOLATILE); } @@ -890,24 +892,16 @@ cp_build_qualified_type_real (tree type, type_quals &= ~TYPE_QUAL_RESTRICT; } - if (bad_quals == TYPE_UNQUALIFIED) + if (bad_quals == TYPE_UNQUALIFIED + || (complain & tf_ignore_bad_quals)) /*OK*/; - else if (!(complain & (tf_error | tf_ignore_bad_quals))) + else if (!(complain & tf_error)) return error_mark_node; else { - if (complain & tf_ignore_bad_quals) - /* We're not going to warn about constifying things that can't - be constified. */ - bad_quals &= ~TYPE_QUAL_CONST; - if (bad_quals) - { - tree bad_type = build_qualified_type (ptr_type_node, bad_quals); - - if (!(complain & tf_ignore_bad_quals)) - error ("%qV qualifiers cannot be applied to %qT", - bad_type, type); - } + tree bad_type = build_qualified_type (ptr_type_node, bad_quals); + error ("%qV qualifiers cannot be applied to %qT", + bad_type, type); } /* Retrieve (or create) the appropriately qualified variant. */ -- 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/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index e34a69cf6ba..d3bba4c1e51 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -940,7 +940,7 @@ cv_unqualified (tree type) if (type == error_mark_node) return type; - quals = TYPE_QUALS (type); + quals = cp_type_quals (type); quals &= ~(TYPE_QUAL_CONST|TYPE_QUAL_VOLATILE); return cp_build_qualified_type (type, quals); } -- cgit v1.2.1 From a7a4626828090600459358ca745c4482cf9551a1 Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 21 May 2010 13:53:22 +0000 Subject: gcc/ChangeLog: * tree.h: Include real.h and fixed-value.h as basic datatypes. * dfp.c, convert.c, reload1.c, reginfo.c, tree-flow.h, tree-ssa-threadedge.c, tree-ssanames.c, tree-loop-linear.c, tree-into-ssa.c, tree-vect-generic.c, tree-ssa-structalias.c, tree-ssa-loop-im.c, tree-dump.c, tree-complex.c, tree-ssa-uninit.c, genrecog.c, tree-ssa-threadupdate.c, tree-ssa-loop-niter.c, tree-pretty-print.c, tree-loop-distribution.c, tree-ssa-loop-unswitch.c, c-lex.c, optabs.c, postreload-gcse.c, tree-ssa-loop-manip.c, postreload.c, tree-ssa-loop-ch.c, tree-tailcall.c, tree.c, reload.c, tree-scalar-evolution.c, rtlanal.c, tree-phinodes.c, builtins.c, final.c, genoutput.c, fold-const.c, tree-ssa-dse.c, genautomata.c, tree-ssa-uncprop.c, toplev.c, tree-chrec.c, genemit.c, c-cppbuiltin.c, tree-ssa-sccvn.c, tree-ssa-ccp.c, tree-ssa-loop-ivopts.c, mode-switching.c, tree-call-cdce.c, cse.c, genpeep.c, tree-ssa-math-opts.c, tree-ssa-dom.c, tree-nrv.c, tree-ssa-propagate.c, tree-ssa-alias.c, tree-ssa-sink.c, jump.c, ifcvt.c, dwarf2out.c, expr.c, genattrtab.c, genconditions.c, tree-ssa-loop-ivcanon.c, tree-ssa-loop.c, tree-parloops.c, recog.c, tree-ssa-address.c, lcm.c, tree-eh.c, gimple-pretty-print.c, c-pretty-print.c, print-rtl.c, gcse.c, tree-if-conv.c, tree-data-ref.c, tree-affine.c, gimplify.c, tree-ssa-phiopt.c, implicit-zee.c, expmed.c, tree-dfa.c, emit-rtl.c, store-motion.c, cselib.c, tree-cfgcleanup.c, simplify-rtx.c, tree-ssa-pre.c, genpreds.c, tree-mudflap.c, print-tree.c, tree-ssa-copy.c, tree-ssa-forwprop.c, tree-ssa-dce.c, varasm.c, tree-nested.c, tree-ssa.c, tree-ssa-loop-prefetch.c, rtl.c, tree-inline.c, integrate.c, tree-optimize.c, tree-ssa-phiprop.c, fixed-value.c, combine.c, tree-profile.c, c-common.c, sched-vis.c, tree-cfg.c, passes.c, tree-ssa-reassoc.c, config/alpha/alpha.c, config/frv/frv.c, config/s390/s390.c, config/m32c/m32c.c, config/spu/spu.c, config/sparc/sparc.c, config/mep/mep.c, config/m32r/m32r.c, config/rx/rx.c, config/i386/i386.c, config/sh/sh.c, config/pdp11/pdp11.c, config/avr/avr.c, config/crx/crx.c, config/xtensa/xtensa.c, config/stormy16/stormy16.c, config/fr30/fr30.c, config/lm32/lm32.c, config/moxie/moxie.c, config/m68hc11/m68hc11.c, config/cris/cris.c, config/iq2000/iq2000.c, config/mn10300/mn10300.c, config/ia64/ia64.c, config/m68k/m68k.c, config/rs6000/rs6000.c, config/picochip/picochip.c, config/darwin.c, config/arc/arc.c, config/mcore/mcore.c, config/score/score3.c, config/score/score7.c, config/score/score.c, config/arm/arm.c, config/pa/pa.c, config/mips/mips.c, config/vax/vax.c, config/h8300/h8300.c, config/v850/v850.c, config/mmix/mmix.c, config/bfin/bfin.c: Clean up redundant includes. * Makefile.in: Update accordingly. java/ChangeLog: * typeck.c, decl.c, jcf-parse.c, except.c, expr.c: cp/Changelog: * error.c, tree.c, typeck2.c, cxx-pretty-print.c, mangle.c: Clean up redundant includes. fortran/ChangeLog: * trans-const.c, trans-types.c, trans-intrinsic.c: Clean up redundant includes. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159663 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d3bba4c1e51..40a0c52d780 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -27,7 +27,6 @@ along with GCC; see the file COPYING3. If not see #include "tree.h" #include "cp-tree.h" #include "flags.h" -#include "real.h" #include "rtl.h" #include "toplev.h" #include "insn-config.h" -- 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/tree.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 40a0c52d780..d5ccd65a790 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -27,16 +27,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 "toplev.h" -#include "insn-config.h" -#include "integrate.h" #include "tree-inline.h" #include "debug.h" -#include "target.h" #include "convert.h" #include "tree-flow.h" #include "cgraph.h" +#include "splay-tree.h" static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); -- cgit v1.2.1 From 15a007df5edd3e7f2c80d11b4d01d1ff66c63f3a Mon Sep 17 00:00:00 2001 From: dodji Date: Thu, 27 May 2010 19:29:53 +0000 Subject: Fix PR c++/44188 gcc/ChangeLog: PR c++/44188 * c-common.c (is_typedef_decl): Move this definition ... * tree.c (is_typedef_decl): ... here. (typdef_variant_p): Move definition here from gcc/cp/tree.c. * c-common.h (is_typedef_decl): Move this declaration ... * tree.h (is_typedef_decl): ... here. (typedef_variant_p): Move declaration here from gcc/cp/cp-tree.h * dwarf2out.c (is_naming_typedef_decl): New function. (gen_tagged_type_die): Split out of ... (gen_type_die_with_usage): ... this function. When an anonymous tagged type is named by a typedef, make sure a DW_TAG_typedef DIE is emitted for the typedef. (gen_typedef_die): Emit DW_TAG_typedef also for typedefs naming anonymous tagged types. gcc/cp/ChangeLog: PR c++/44188 * cp-tree.h (typedef_variant_p): Move this declaration to gcc/tree.h. * tree.c (typedef_variant_p): Move this definition to gcc/tree.c. * decl.c (grokdeclarator): Do not rename debug info of an anonymous tagged type named by a typedef. gcc/testsuite/ChangeLog: PR c++/44188 * g++.dg/debug/dwarf2/typedef3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159943 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d5ccd65a790..5421980a052 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1055,14 +1055,6 @@ strip_typedefs (tree t) return cp_build_qualified_type (result, cp_type_quals (t)); } -/* Returns true iff TYPE is a type variant created for a typedef. */ - -bool -typedef_variant_p (tree type) -{ - return is_typedef_decl (TYPE_NAME (type)); -} - /* Setup a TYPE_DECL node as a typedef representation. See comments of set_underlying_type in c-common.c. */ -- cgit v1.2.1 From bcf72c8bad93b0284cfcbea57a57b56df8587935 Mon Sep 17 00:00:00 2001 From: dodji Date: Fri, 28 May 2010 00:03:19 +0000 Subject: Revert "Fix PR c++/44188" gcc/ChangeLog: revert fix for PR c++/44188 * c-common.c (is_typedef_decl): Revert the moving of this definition ... * tree.c (is_typedef_decl): ... here. (typdef_variant_p): Revert the moving of this definition here from gcc/cp/tree.c. * c-common.h (is_typedef_decl): Revert the moving of this declaration ... * tree.h (is_typedef_decl): ... here. (typedef_variant_p): Revert the moving of this declaration here from gcc/cp/cp-tree.h * dwarf2out.c (is_naming_typedef_decl): Revert this new function. (gen_tagged_type_die): Revert the splitting out of ... (gen_type_die_with_usage): ... this function. Revert the anonymous tagged type handling. (gen_typedef_die): Revert emitting DW_TAG_typedef for typedefs naming anonymous tagged types. gcc/cp/ChangeLog: Revert fix of PR c++/44188 * cp-tree.h (typedef_variant_p): Revert moving this declaration to gcc/tree.h. * tree.c (typedef_variant_p): Revert moving this definition to gcc/tree.c. * decl.c (grokdeclarator): Revert naming typedef handling. gcc/testsuite/ChangeLog: Revert fix for PR c++/44188 * g++.dg/debug/dwarf2/typedef3.C: Revert new test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159955 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 5421980a052..d5ccd65a790 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1055,6 +1055,14 @@ strip_typedefs (tree t) return cp_build_qualified_type (result, cp_type_quals (t)); } +/* Returns true iff TYPE is a type variant created for a typedef. */ + +bool +typedef_variant_p (tree type) +{ + return is_typedef_decl (TYPE_NAME (type)); +} + /* Setup a TYPE_DECL node as a typedef representation. See comments of set_underlying_type in c-common.c. */ -- cgit v1.2.1 From 6ad8abad783af88a9591b967932a810347637b4e Mon Sep 17 00:00:00 2001 From: steven Date: Fri, 28 May 2010 23:13:18 +0000 Subject: gcc/ChangeLog: * c-common.h: Add FIXME for awkward split of c_register_addr_space. * c-common.c (c_register_addr_space): Remove here. * c-decl.c (c_register_addr_space): Re-add here. cp/ChangeLog: * tree.c (c_register_addr_space): Add stub. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160006 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d5ccd65a790..9a5ee0fb2d8 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -3199,6 +3199,16 @@ cp_free_lang_data (tree t) } } +/* Stub for c-common. Please keep in sync with c-decl.c. + FIXME: If address space support is target specific, then this + should be a C target hook. But currently this is not possible, + because this function is called via REGISTER_TARGET_PRAGMAS. */ +void +c_register_addr_space (const char *word ATTRIBUTE_UNUSED, + addr_space_t as ATTRIBUTE_UNUSED) +{ +} + #if defined ENABLE_TREE_CHECKING && (GCC_VERSION >= 2007) /* Complain that some language-specific thing hanging off a tree -- cgit v1.2.1 From c0f832033ab6a61743a521bb196ae9b060fa7e56 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 4 Jun 2010 21:21:02 +0000 Subject: * call.c (build_conditional_expr): Never fold in unevaluated context. * tree.c (build_aggr_init_expr): Propagate TREE_NOTHROW. * semantics.c (simplify_aggr_init_expr): Likewise. * typeck.c (merge_types): Call merge_exception_specifiers. * decl.c (duplicate_decls): Check DECL_SOURCE_LOCATION rather than DECL_ANTICIPATED for preferring new type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160296 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 9a5ee0fb2d8..c4b9dd5b5fb 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -418,6 +418,7 @@ build_aggr_init_expr (tree type, tree init) AGGR_INIT_EXPR_ARGP (init)); TREE_SIDE_EFFECTS (rval) = 1; AGGR_INIT_VIA_CTOR_P (rval) = is_ctor; + TREE_NOTHROW (rval) = TREE_NOTHROW (init); } else rval = init; -- cgit v1.2.1 From 3644efa555cc85fc27dada414f6de71133046242 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 4 Jun 2010 21:21:23 +0000 Subject: Implement noexcept-specification (15.4) * parser.c (cp_parser_exception_specification_opt): Parse it. Give -Wdeprecated warning about throw() specs. * pt.c (tsubst_exception_specification): Handle it. * error.c (dump_exception_spec): Handle it. * cxx-pretty-print.c (pp_cxx_exception_specification): Likewise. * typeck.c (comp_except_specs): Handle compatibility rules. Change exact parm to take an enum. * typeck2.c (merge_exception_specifiers): Handle noexcept. * except.c (nothrow_spec_p, type_noexcept_p): New fns. (type_throw_all_p, build_noexcept_spec): New fns. * cp-tree.h (TYPE_NOTHROW_P, TYPE_NOEXCEPT_P): Use them. (comp_except_specs): Define ce_derived, ce_normal, ce_exact enums. (cp_tree_index): Add CPTI_NOEXCEPT_TRUE_SPEC, CPTI_NOEXCEPT_FALSE_SPEC. (noexcept_true_spec, noexcept_false_spec): New macros. * name-lookup.c (pushdecl_maybe_friend): Adjust. * search.c (check_final_overrider): Adjust. * decl.c (check_redeclaration_exception_specification): Adjust. (use_eh_spec_block): Use type_throw_all_p. (cxx_init_decl_processing): Set noexcept_false_spec,noexcept_true_spec. Give operator new a noexcept-specification in C++0x mode. * tree.c (build_exception_variant, cxx_type_hash_eq): Adjust. (cp_build_type_attribute_variant): Don't test TYPE_RAISES_EXCEPTIONS. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160298 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index c4b9dd5b5fb..7d0e4765cd1 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1467,12 +1467,16 @@ cxx_printable_name_translate (tree decl, int v) tree build_exception_variant (tree type, tree raises) { - tree v = TYPE_MAIN_VARIANT (type); - int type_quals = TYPE_QUALS (type); + tree v; + int type_quals; - for (; v; v = TYPE_NEXT_VARIANT (v)) + if (comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (type), ce_exact)) + return type; + + type_quals = TYPE_QUALS (type); + for (v = TYPE_MAIN_VARIANT (type); v; v = TYPE_NEXT_VARIANT (v)) if (check_qualified_type (v, type, type_quals) - && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), 1)) + && comp_except_specs (raises, TYPE_RAISES_EXCEPTIONS (v), ce_exact)) return v; /* Need to build a new variant. */ @@ -2645,10 +2649,8 @@ cp_build_type_attribute_variant (tree type, tree attributes) tree new_type; new_type = build_type_attribute_variant (type, attributes); - if ((TREE_CODE (new_type) == FUNCTION_TYPE - || TREE_CODE (new_type) == METHOD_TYPE) - && (TYPE_RAISES_EXCEPTIONS (new_type) - != TYPE_RAISES_EXCEPTIONS (type))) + if (TREE_CODE (new_type) == FUNCTION_TYPE + || TREE_CODE (new_type) == METHOD_TYPE) new_type = build_exception_variant (new_type, TYPE_RAISES_EXCEPTIONS (type)); @@ -2669,7 +2671,7 @@ cxx_type_hash_eq (const_tree typea, const_tree typeb) gcc_assert (TREE_CODE (typea) == FUNCTION_TYPE); return comp_except_specs (TYPE_RAISES_EXCEPTIONS (typea), - TYPE_RAISES_EXCEPTIONS (typeb), 1); + TYPE_RAISES_EXCEPTIONS (typeb), ce_exact); } /* Apply FUNC to all language-specific sub-trees of TP in a pre-order -- cgit v1.2.1 From a8891ab12879a8d2f8421492c85a1b409144cea4 Mon Sep 17 00:00:00 2001 From: dodji Date: Sun, 6 Jun 2010 18:24:27 +0000 Subject: Fix PR c++/44188 gcc/ChangeLog: PR c++/44188 * c-common.c (is_typedef_decl): Move this definition ... * tree.c (is_typedef_decl): ... here. (typdef_variant_p): Move definition here from gcc/cp/tree.c. * c-common.h (is_typedef_decl): Move this declaration ... * tree.h (is_typedef_decl): ... here. (typedef_variant_p): Move declaration here from gcc/cp/cp-tree.h * dwarf2out.c (is_naming_typedef_decl): New function. (gen_tagged_type_die): Split out of ... (gen_type_die_with_usage): ... this function. When an anonymous tagged type is named by a typedef, make sure a DW_TAG_typedef DIE is emitted for the typedef. (gen_typedef_die): Emit DW_TAG_typedef also for typedefs naming anonymous tagged types. gcc/cp/ChangeLog: PR c++/44188 * cp-tree.h (typedef_variant_p): Move this declaration to gcc/tree.h. * tree.c (typedef_variant_p): Move this definition to gcc/tree.c. * decl.c (grokdeclarator): Do not rename debug info of an anonymous tagged type named by a typedef. gcc/testsuite/ChangeLog: PR c++/44188 * g++.dg/debug/dwarf2/typedef3.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160347 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 7d0e4765cd1..29712832391 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -1056,14 +1056,6 @@ strip_typedefs (tree t) return cp_build_qualified_type (result, cp_type_quals (t)); } -/* Returns true iff TYPE is a type variant created for a typedef. */ - -bool -typedef_variant_p (tree type) -{ - return is_typedef_decl (TYPE_NAME (type)); -} - /* Setup a TYPE_DECL node as a typedef representation. See comments of set_underlying_type in c-common.c. */ -- 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/tree.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 29712832391..f7ce655eb19 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -479,7 +479,7 @@ build_target_expr_with_type (tree init, tree type) if (TREE_CODE (init) == TARGET_EXPR) return init; - else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_INIT_REF (type) + else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_COPY_CTOR (type) && !VOID_TYPE_P (TREE_TYPE (init)) && TREE_CODE (init) != COND_EXPR && TREE_CODE (init) != CONSTRUCTOR @@ -2376,7 +2376,7 @@ type_has_nontrivial_copy_init (const_tree t) t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return TYPE_HAS_COMPLEX_INIT_REF (t); + return TYPE_HAS_COMPLEX_COPY_CTOR (t); else return 0; } @@ -2390,8 +2390,8 @@ trivial_type_p (const_tree t) if (CLASS_TYPE_P (t)) return (TYPE_HAS_TRIVIAL_DFLT (t) - && TYPE_HAS_TRIVIAL_INIT_REF (t) - && TYPE_HAS_TRIVIAL_ASSIGN_REF (t) + && TYPE_HAS_TRIVIAL_COPY_CTOR (t) + && TYPE_HAS_TRIVIAL_COPY_ASSIGN (t) && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else return scalarish_type_p (t); @@ -2832,7 +2832,7 @@ special_function_p (const_tree decl) if (DECL_CONSTRUCTOR_P (decl)) return sfk_constructor; if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR) - return sfk_assignment_operator; + return sfk_copy_assignment; if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) return sfk_destructor; if (DECL_COMPLETE_DESTRUCTOR_P (decl)) -- 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/tree.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index f7ce655eb19..72369244b43 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2381,22 +2381,37 @@ type_has_nontrivial_copy_init (const_tree t) return 0; } -/* Returns 1 iff type T is a trivial type, as defined in [basic.types]. */ +/* Returns 1 iff type T is a trivially copyable type, as defined in + [basic.types] and [class]. */ bool -trivial_type_p (const_tree t) +trivially_copyable_p (const_tree t) { t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return (TYPE_HAS_TRIVIAL_DFLT (t) - && TYPE_HAS_TRIVIAL_COPY_CTOR (t) + return (TYPE_HAS_TRIVIAL_COPY_CTOR (t) && TYPE_HAS_TRIVIAL_COPY_ASSIGN (t) && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else return scalarish_type_p (t); } +/* Returns 1 iff type T is a trivial type, as defined in [basic.types] and + [class]. */ + +bool +trivial_type_p (const_tree t) +{ + t = strip_array_types (CONST_CAST_TREE (t)); + + if (CLASS_TYPE_P (t)) + return (TYPE_HAS_TRIVIAL_DFLT (t) + && trivially_copyable_p (t)); + else + return scalarish_type_p (t); +} + /* Returns 1 iff type T is a POD type, as defined in [basic.types]. */ bool -- 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/tree.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 72369244b43..3367a093d36 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2847,7 +2847,12 @@ special_function_p (const_tree decl) if (DECL_CONSTRUCTOR_P (decl)) return sfk_constructor; if (DECL_OVERLOADED_OPERATOR_P (decl) == NOP_EXPR) - return sfk_copy_assignment; + { + if (copy_fn_p (decl)) + return sfk_copy_assignment; + if (move_fn_p (decl)) + return sfk_move_assignment; + } if (DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (decl)) return sfk_destructor; if (DECL_COMPLETE_DESTRUCTOR_P (decl)) -- 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/tree.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 3367a093d36..6d1ff10ea17 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -479,7 +479,7 @@ build_target_expr_with_type (tree init, tree type) if (TREE_CODE (init) == TARGET_EXPR) return init; - else if (CLASS_TYPE_P (type) && !TYPE_HAS_TRIVIAL_COPY_CTOR (type) + else if (CLASS_TYPE_P (type) && type_has_nontrivial_copy_init (type) && !VOID_TYPE_P (TREE_TYPE (init)) && TREE_CODE (init) != COND_EXPR && TREE_CODE (init) != CONSTRUCTOR @@ -497,7 +497,8 @@ build_target_expr_with_type (tree init, tree type) /* Like the above function, but without the checking. This function should only be used by code which is deliberately trying to subvert the type - system, such as call_builtin_trap. */ + system, such as call_builtin_trap. Or build_over_call, to avoid + infinite recursion. */ tree force_target_expr (tree type, tree init) @@ -2368,7 +2369,9 @@ type_has_nontrivial_default_init (const_tree t) return 0; } -/* Returns true iff copying an object of type T is non-trivial. */ +/* Returns true iff copying an object of type T (including via move + constructor) is non-trivial. That is, T has no non-trivial copy + constructors and no non-trivial move constructors. */ bool type_has_nontrivial_copy_init (const_tree t) @@ -2376,7 +2379,12 @@ type_has_nontrivial_copy_init (const_tree t) t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return TYPE_HAS_COMPLEX_COPY_CTOR (t); + { + gcc_assert (COMPLETE_TYPE_P (t)); + return ((TYPE_HAS_COPY_CTOR (t) + && TYPE_HAS_COMPLEX_COPY_CTOR (t)) + || TYPE_HAS_COMPLEX_MOVE_CTOR (t)); + } else return 0; } @@ -2390,8 +2398,12 @@ trivially_copyable_p (const_tree t) t = strip_array_types (CONST_CAST_TREE (t)); if (CLASS_TYPE_P (t)) - return (TYPE_HAS_TRIVIAL_COPY_CTOR (t) - && TYPE_HAS_TRIVIAL_COPY_ASSIGN (t) + return ((!TYPE_HAS_COPY_CTOR (t) + || !TYPE_HAS_COMPLEX_COPY_CTOR (t)) + && !TYPE_HAS_COMPLEX_MOVE_CTOR (t) + && (!TYPE_HAS_COPY_ASSIGN (t) + || !TYPE_HAS_COMPLEX_COPY_ASSIGN (t)) + && !TYPE_HAS_COMPLEX_MOVE_ASSIGN (t) && TYPE_HAS_TRIVIAL_DESTRUCTOR (t)); else return scalarish_type_p (t); -- cgit v1.2.1 From 9b40bfbf8ea234b65a27e59b608dd1f6c830c9f8 Mon Sep 17 00:00:00 2001 From: manu Date: Wed, 30 Jun 2010 07:39:21 +0000 Subject: =?UTF-8?q?2010-06-30=20=20Manuel=20L=C3=B3pez-Ib=C3=A1=C3=B1ez=20?= =?UTF-8?q?=20?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * tree.h (block_may_fallthru): Declare here. * tree-flow.h (block_may_fallthru): Do not declare here. * c-typeck.c: Do not include tree-flow.h. Include gimple.h and bitmap.h * Makefile.in (c-typeck.o): Update dependencies. c-family/ * c-gimplify.c: Do not include tree-flow.h cp/ * tree.c: Include gimple.h. Do not include tree-flow.h * decl.c: Do not include tree-flow.h * Make-lang.in: Adjust dependencies. ada/ * gcc-interface/trans.c: Do not include tree-flow.h. * gcc-interface/Make-lang.in: Adjust dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161591 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 6d1ff10ea17..d62f9d7acf6 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -31,9 +31,9 @@ along with GCC; see the file COPYING3. If not see #include "tree-inline.h" #include "debug.h" #include "convert.h" -#include "tree-flow.h" #include "cgraph.h" #include "splay-tree.h" +#include "gimple.h" /* gimple_has_body_p */ static tree bot_manip (tree *, int *, void *); static tree bot_replace (tree *, int *, void *); -- cgit v1.2.1 From 639bf191a04e597c90aabca3e05fa6fd489b185e Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 19 Jul 2010 14:50:52 +0000 Subject: PR c++/44969 * tree.c (cp_tree_equal): Compare type of *CAST_EXPR. * pt.c (iterative_hash_template_arg): Hash type of *CAST_EXPR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162307 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index d62f9d7acf6..2abd8dd1a2c 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2191,6 +2191,17 @@ cp_tree_equal (tree t1, tree t2) return same_type_p (TRAIT_EXPR_TYPE1 (t1), TRAIT_EXPR_TYPE1 (t2)) && same_type_p (TRAIT_EXPR_TYPE2 (t1), TRAIT_EXPR_TYPE2 (t2)); + case CAST_EXPR: + case STATIC_CAST_EXPR: + case REINTERPRET_CAST_EXPR: + case CONST_CAST_EXPR: + case DYNAMIC_CAST_EXPR: + case NEW_EXPR: + if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))) + return false; + /* Now compare operands as usual. */ + break; + default: break; } -- cgit v1.2.1 From 1e0510e14349695b26cf843903dc54e2482ee8a8 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 21 Jul 2010 14:38:12 +0000 Subject: * tree.c (cp_tree_equal): Fix CONSTRUCTOR handling. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162378 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/tree.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'gcc/cp/tree.c') diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c index 2abd8dd1a2c..450b9e89433 100644 --- a/gcc/cp/tree.c +++ b/gcc/cp/tree.c @@ -2023,11 +2023,21 @@ cp_tree_equal (tree t1, tree t2) /* We need to do this when determining whether or not two non-type pointer to member function template arguments are the same. */ - if (!(same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)) - /* The first operand is RTL. */ - && TREE_OPERAND (t1, 0) == TREE_OPERAND (t2, 0))) + if (!same_type_p (TREE_TYPE (t1), TREE_TYPE (t2)) + || CONSTRUCTOR_NELTS (t1) != CONSTRUCTOR_NELTS (t2)) return false; - return cp_tree_equal (TREE_OPERAND (t1, 1), TREE_OPERAND (t2, 1)); + { + tree field, value; + unsigned int i; + FOR_EACH_CONSTRUCTOR_ELT (CONSTRUCTOR_ELTS (t1), i, field, value) + { + constructor_elt *elt2 = CONSTRUCTOR_ELT (t2, i); + if (!cp_tree_equal (field, elt2->index) + || !cp_tree_equal (value, elt2->value)) + return false; + } + } + return true; case TREE_LIST: if (!cp_tree_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2))) -- cgit v1.2.1