From 39e70cbf1779519844a6a7246ba9719d80516610 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 4 Jul 2009 00:43:26 +0000 Subject: * cp-tree.h (struct lang_decl): Overhaul. (struct lang_decl_flags): Remove. (struct lang_decl_base): New. (struct lang_decl_min): New. (struct lang_decl_fn): New. (struct lang_decl_ns): New. (CAN_HAVE_FULL_LANG_DECL_P): Replace with LANG_DECL_HAS_MIN. (LANG_DECL_MIN_CHECK): New. (LANG_DECL_FN_CHECK): New. (LANG_DECL_NS_CHECK): New. (STRIP_TEMPLATE): New. (NON_THUNK_FUNCTION_CHECK): Remove. (DECL_DECLARES_FUNCTION_P): New. (lots): Adjust. * lex.c (retrofit_lang_decl, cxx_dup_lang_specific_decl): Adjust. * decl.c (push_local_name, duplicate_decls): Adjust. * decl2.c (start_objects): Don't set u2sel. * semantics.c (finish_omp_threadprivate): Adjust. * class.c (build_clone): Don't do much on TEMPLATE_DECLs. (decl_cloned_function_p): Out-of-line implementation of macros. (clone_function_decl, adjust_clone_args): Use DECL_CLONED_FUNCTION_P. * mangle.c (write_unqualified_name): Don't check function flags on non-functions. * method.c (make_alias_for): Don't set DECL_CLONED_FUNCTION. * pt.c (build_template_decl): Don't set function flags. (check_default_tmpl_args): Check that it's a function. (instantiate_template): Use DECL_ABSTRACT_ORIGIN to find the cloned template. * pt.c (tsubst_decl) [FUNCTION_DECL]: Don't tsubst DECL_CLONED_FUNCTION. * cp-tree.h (struct lang_type_class): Move sorted_fields here. * class.c (finish_struct_1): Adjust. * ptree.c (cxx_print_decl, cxx_print_type): Adjust. * search.c (lookup_field_1): Adjust. * cp-tree.h (CLASSTYPE_INLINE_FRIENDS): Remove. * decl.c (finish_method): Don't add to it. * class.c (fixup_pending_inline): Remove. (fixup_inline_methods): Remove. (finish_struct_1): Don't call it. * error.c (dump_function_name): Handle null name. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149217 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9a43863c6bb..59a5312bca8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3861,7 +3861,7 @@ finish_omp_threadprivate (tree vars) /* Make sure that DECL_DISCRIMINATOR_P continues to be true after the allocation of the lang_decl structure. */ if (DECL_DISCRIMINATOR_P (v)) - DECL_LANG_SPECIFIC (v)->decl_flags.u2sel = 1; + DECL_LANG_SPECIFIC (v)->u.base.u2sel = 1; } if (! DECL_THREAD_LOCAL_P (v)) -- cgit v1.2.1 From ccb59bb6a4de1511f5c702ff77b97193ac025583 Mon Sep 17 00:00:00 2001 From: manu Date: Mon, 6 Jul 2009 09:09:47 +0000 Subject: =?UTF-8?q?2009-07-06=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 cp/ * decl.c: Replace %H by an explicit location. Update all calls. * except.c: Likewise. * semantics.c: Likewise. * parser.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149277 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 59a5312bca8..1b96ac265a2 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2563,20 +2563,21 @@ qualified_name_lookup_error (tree scope, tree name, else if (TYPE_P (scope)) { if (!COMPLETE_TYPE_P (scope)) - error ("%Hincomplete type %qT used in nested name specifier", - &location, scope); + error_at (location, "incomplete type %qT used in nested name specifier", + scope); else if (TREE_CODE (decl) == TREE_LIST) { - error ("%Hreference to %<%T::%D%> is ambiguous", &location, scope, name); + error_at (location, "reference to %<%T::%D%> is ambiguous", + scope, name); print_candidates (decl); } else - error ("%H%qD is not a member of %qT", &location, name, scope); + error_at (location, "%qD is not a member of %qT", name, scope); } else if (scope != global_namespace) - error ("%H%qD is not a member of %qD", &location, name, scope); + error_at (location, "%qD is not a member of %qD", name, scope); else - error ("%H%<::%D%> has not been declared", &location, name); + error_at (location, "%<::%D%> has not been declared", name); } /* If FNS is a member function, a set of member functions, or a @@ -3984,7 +3985,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, } if (cond == error_mark_node) { - error ("%Hinvalid controlling predicate", &elocus); + error_at (elocus, "invalid controlling predicate"); return true; } diff = build_x_binary_op (MINUS_EXPR, TREE_OPERAND (cond, 1), @@ -3994,8 +3995,8 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, return true; if (TREE_CODE (TREE_TYPE (diff)) != INTEGER_TYPE) { - error ("%Hdifference between %qE and %qD does not have integer type", - &elocus, TREE_OPERAND (cond, 1), iter); + error_at (elocus, "difference between %qE and %qD does not have integer type", + TREE_OPERAND (cond, 1), iter); return true; } @@ -4089,7 +4090,7 @@ handle_omp_for_class_iterator (int i, location_t locus, tree declv, tree initv, if (incr == error_mark_node) { - error ("%Hinvalid increment expression", &elocus); + error_at (elocus, "invalid increment expression"); return true; } @@ -4216,8 +4217,8 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, if (decl == NULL) { - error ("%Hexpected iteration declaration or initialization", - &locus); + error_at (locus, + "expected iteration declaration or initialization"); return NULL; } } @@ -4227,13 +4228,13 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, if (cond == NULL) { - error ("%Hmissing controlling predicate", &elocus); + error_at (elocus, "missing controlling predicate"); return NULL; } if (incr == NULL) { - error ("%Hmissing increment expression", &elocus); + error_at (elocus, "missing increment expression"); return NULL; } @@ -4287,8 +4288,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, if (!DECL_P (decl)) { - error ("%Hexpected iteration declaration or initialization", - &elocus); + error_at (elocus, "expected iteration declaration or initialization"); return NULL; } @@ -4313,7 +4313,7 @@ finish_omp_for (location_t locus, tree declv, tree initv, tree condv, if (!INTEGRAL_TYPE_P (TREE_TYPE (decl)) && TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE) { - error ("%Hinvalid type for iteration variable %qE", &elocus, decl); + error_at (elocus, "invalid type for iteration variable %qE", decl); return NULL; } -- cgit v1.2.1 From 1cf1742e4834f67465fd29068ec87ac427940a6c Mon Sep 17 00:00:00 2001 From: manu Date: Tue, 7 Jul 2009 21:52:01 +0000 Subject: =?UTF-8?q?2009-07-07=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.c (set_expr_locus): Remove. * tree.h (EXPR_LOCUS,SET_EXPR_LOCUS,set_expr_locus): Remove. * c-typeck.c (c_finish_stmt_expr): Replace EXPR_LOCUS by EXPR_LOCATION. * gimplify.c (internal_get_tmp_var): Likewise. (gimplify_call_expr): Likewise. (gimplify_one_sizepos): Likewise. objc/ * objc-act.c (next_sjlj_build_catch_list): Replace EXPR_LOCUS by EXPR_LOCATION. cp/ * semantics.c (finalize_nrv_r): Replace EXPR_LOCUS by EXPR_LOCATION. ada/ * gcc-interface/trans.c (gnat_gimplify_expr): Replace EXPR_LOCUS by EXPR_LOCATION. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149350 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1b96ac265a2..aa52a362fb7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3334,7 +3334,7 @@ finalize_nrv_r (tree* tp, int* walk_subtrees, void* data) else init = build_empty_stmt (EXPR_LOCATION (*tp)); DECL_INITIAL (dp->var) = NULL_TREE; - SET_EXPR_LOCUS (init, EXPR_LOCUS (*tp)); + SET_EXPR_LOCATION (init, EXPR_LOCATION (*tp)); *tp = init; } /* And replace all uses of the NRV with the RESULT_DECL. */ -- cgit v1.2.1 From d69c0c735bc3e67f49f7283c3b75d8834e44116a Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 14 Jul 2009 18:15:35 +0000 Subject: PR c++/40740 * semantics.c (perform_koenig_lookup): Handle empty template args. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149636 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index aa52a362fb7..61dff51ba75 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1827,9 +1827,12 @@ perform_koenig_lookup (tree fn, VEC(tree,gc) *args) tree identifier = NULL_TREE; tree functions = NULL_TREE; tree tmpl_args = NULL_TREE; + bool template_id = false; if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) { + /* Use a separate flag to handle null args. */ + template_id = true; tmpl_args = TREE_OPERAND (fn, 1); fn = TREE_OPERAND (fn, 0); } @@ -1861,8 +1864,8 @@ perform_koenig_lookup (tree fn, VEC(tree,gc) *args) fn = unqualified_fn_lookup_error (identifier); } - if (fn && tmpl_args) - fn = build_nt (TEMPLATE_ID_EXPR, fn, tmpl_args); + if (fn && template_id) + fn = build2 (TEMPLATE_ID_EXPR, unknown_type_node, fn, tmpl_args); return fn; } -- 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/semantics.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 61dff51ba75..4473c4927b4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4878,6 +4878,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) switch (kind) { case CPTK_HAS_NOTHROW_ASSIGN: + type1 = strip_array_types (type1); return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE && (trait_expr_value (CPTK_HAS_TRIVIAL_ASSIGN, type1, type2) || (CLASS_TYPE_P (type1) @@ -4885,8 +4886,11 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) true)))); case CPTK_HAS_TRIVIAL_ASSIGN: + /* ??? The standard seems to be missing the "or array of such a class + type" wording for this trait. */ + type1 = strip_array_types (type1); return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE - && (pod_type_p (type1) + && (trivial_type_p (type1) || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_ASSIGN_REF (type1)))); @@ -4899,21 +4903,25 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_HAS_TRIVIAL_CONSTRUCTOR: type1 = strip_array_types (type1); - return (pod_type_p (type1) + return (trivial_type_p (type1) || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_DFLT (type1))); case CPTK_HAS_NOTHROW_COPY: + type1 = strip_array_types (type1); return (trait_expr_value (CPTK_HAS_TRIVIAL_COPY, type1, type2) || (CLASS_TYPE_P (type1) && classtype_has_nothrow_assign_or_copy_p (type1, false))); case CPTK_HAS_TRIVIAL_COPY: - return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE + /* ??? The standard seems to be missing the "or array of such a class + type" wording for this trait. */ + type1 = strip_array_types (type1); + return (trivial_type_p (type1) || type_code1 == REFERENCE_TYPE || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_INIT_REF (type1))); case CPTK_HAS_TRIVIAL_DESTRUCTOR: type1 = strip_array_types (type1); - return (pod_type_p (type1) || type_code1 == REFERENCE_TYPE + return (trivial_type_p (type1) || type_code1 == REFERENCE_TYPE || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1))); @@ -4947,6 +4955,12 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_POLYMORPHIC: return (CLASS_TYPE_P (type1) && TYPE_POLYMORPHIC_P (type1)); + case CPTK_IS_STD_LAYOUT: + return (std_layout_type_p (type1)); + + case CPTK_IS_TRIVIAL: + return (trivial_type_p (type1)); + case CPTK_IS_UNION: return (type_code1 == UNION_TYPE); @@ -4995,6 +5009,8 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) || kind == CPTK_IS_ENUM || kind == CPTK_IS_POD || kind == CPTK_IS_POLYMORPHIC + || kind == CPTK_IS_STD_LAYOUT + || kind == CPTK_IS_TRIVIAL || kind == CPTK_IS_UNION); if (kind == CPTK_IS_CONVERTIBLE_TO) @@ -5036,6 +5052,8 @@ finish_trait_expr (cp_trait_kind kind, tree type1, tree type2) case CPTK_IS_EMPTY: case CPTK_IS_POD: case CPTK_IS_POLYMORPHIC: + case CPTK_IS_STD_LAYOUT: + case CPTK_IS_TRIVIAL: if (!check_trait_type (type1)) { error ("incomplete type %qT not allowed", type1); -- 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/semantics.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4473c4927b4..9ac88fd7b65 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3129,10 +3129,11 @@ simplify_aggr_init_expr (tree *tp) style = arg; } - call_expr = build_call_array (TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), - fn, - aggr_init_expr_nargs (aggr_init_expr), - AGGR_INIT_EXPR_ARGP (aggr_init_expr)); + call_expr = build_call_array_loc (input_location, + TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), + fn, + aggr_init_expr_nargs (aggr_init_expr), + AGGR_INIT_EXPR_ARGP (aggr_init_expr)); if (style == ctor) { -- cgit v1.2.1 From bfec3452cfb96a7546809ee1af3fffb9eba9d658 Mon Sep 17 00:00:00 2001 From: rguenth Date: Fri, 17 Jul 2009 15:49:34 +0000 Subject: 2009-07-17 Richard Guenther PR c/40401 * tree-pass.h (pass_diagnose_omp_blocks): Declare. (pass_warn_unused_result): Likewise. (TODO_set_props): Remove. * omp-low.c (diagnose_omp_structured_block_errors): Change to run as a pass. (pass_diagnose_omp_blocks): Define. * c-decl.c (pop_file_scope): Do not finalize the CU here. (c_gimple_diagnostics_recursively): Remove. (finish_function): Do not call it. (c_write_global_declarations): Continue after errors. Finalize the CU here. * c-gimplify.c (c_genericize): Do not gimplify here. * c-common.c (c_warn_unused_result): Move ... * tree-cfg.c (do_warn_unused_result): ... here. (run_warn_unused_result): New function. (gate_warn_unused_result): New function. (pass_warn_unused_result): New pass. * c-common.h (c_warn_unused_result): Remove. * flags.h (flag_warn_unused_result): Declare. * c-opts.c (c_common_init_options): Enable flag_warn_unused_result. * opts.c (flag_warn_unused_result): Initialize to false. * toplev.c (compile_file): Add comment. * omp-low.c (create_omp_child_function): Do not register the function with the frontend. (diagnose_omp_structured_block_errors): Prepare to be called as optimization pass. (gate_diagnose_omp_blocks): New function. (pass_diagnose_omp_blocks): New pass. * cgraph.h (cgraph_optimize): Remove. (cgraph_analyze_function): Likewise. * cgraph.c (cgraph_add_new_function): Gimplify C++ thunks. * cgraphunit.c (cgraph_lower_function): Lower nested functions before their parents here. (cgraph_finalize_function): Not here. (cgraph_analyze_function): Gimplify functions here. (cgraph_finalize_compilation_unit): Continue after errors. Optimize the callgraph from here. (cgraph_optimize): Make static. * langhooks.c (write_global_declarations): Finalize the CU. * gimplify.c (gimplify_asm_expr): Do not emit ASMs with errors. (gimplify_function_tree): Assert we gimplify only once. Set PROP_gimple_any property. * tree-nested.c (gimplify_all_functions): New function. (lower_nested_functions): Gimplify all nested functions. * gimple.h (diagnose_omp_structured_block_errors): Remove. * passes.c (init_optimization_passes): Add pass_warn_unused_result and pass_diagnose_omp_blocks after gimplification. Do not set TODO_set_props on all_lowering_passes. (execute_one_pass): Do not handle TODO_set_props. * Makefile.in (cgraphunit.o): Add $(TREE_DUMP_H) dependency. (gimplify.o): Add tree-pass.h dependency. * tree-inline.c (copy_statement_list): Properly copy STATEMENT_LIST. (copy_tree_body_r): Properly handle TARGET_EXPR like SAVE_EXPR. (unsave_r): Likewise. * c-omp.c (c_finish_omp_atomic): Set DECL_CONTEXT on the temporary variable. cp/ * decl.c (finish_function): Do not emit unused result warnings from here. * cp-objcp-common.h (LANG_HOOKS_POST_GIMPLIFY_PASS): Use c_warn_unused_result_pass. * semantics.c (expand_or_defer_fn): Adjust assertion about IL status. * optimize.c (clone_body): Clone in GENERIC. (maybe_clone_body): Do not clear DECL_SAVED_TREE. * decl2.c (cp_write_global_declarations): Fix body test. Do not call cgraph_optimize. * Make-lang.in (optimize.o): Add tree-iterator.h dependency. * method.c (use_thunk): Register thunk with cgraph_finalize_function. * error.c (function_category): Guard access of DECL_LANG_SPECIFIC. java/ * java-gimplify.c (java_genericize): Do not gimplify here. But replace all local references. (java_gimplify_expr): Do not replace local references here. (java_gimplify_modify_expr): Likewise. * jcf-parse.c (java_parse_file): Do not finalize the CU or optimize the cgraph here. * decl.c (java_replace_reference): Make static. (java_replace_references): New function. (end_java_method): Clear base_decl_map. * java-tree.h (java_replace_references): Declare. (java_replace_reference): Remove. ada/ * utils.c (end_subprog_body): Revert to pre-tuples state. Remove unused parameter. (gnat_gimplify_function): Do not gimplify here. Fold into its only caller and remove. (gnat_builtin_function): Adjust for end_subprog_body signature change. (gnat_write_global_declarations): Also finalize the CU. * misc.c (gnat_parse_file): Do not finalize the CU here. * trans.c (gigi): Revert to pre-tuples state. (Subprogram_Body_to_gnu): Adjust for end_subprog_body signature change. * gigi.h (end_subprog_body): Remove unused parameter. fortran/ * f95-lang.c (gfc_be_parse_file): Do not finalize the CU here. * trans-decl.c (gfc_gimplify_function): Remove. (build_entry_thunks): Do not gimplify here. (create_main_function): Likewise. (gfc_generate_function_code): Likewise. * g++.dg/rtti/crash4.C: New testcase. * g++.dg/torture/20090706-1.C: Likewise. * gcc.dg/redecl-17.c: Likewise. * gfortran.dg/missing_optional_dummy_5.f90: Adjust pattern. * gcc.dg/declspec-9.c: Expect extra error. * gcc.dg/declspec-10.c: Likewise. * gcc.dg/declspec-11.c: Likewise. * gcc.dg/redecl-10.c: Expect extra warnings. * gcc.target/i386/pr39082-1.c: Adjust diagnostic location. * gcc.target/i386/pr39545-1.c: Likewise. * g++.dg/ext/asm3.C: Expect more errors. * g++.dg/gomp/block-1.C: Likewise. * g++.dg/gomp/block-2.C: Likewise. * g++.dg/gomp/block-3.C: Likewise. * g++.dg/gomp/block-5.C: Likewise. * g++.old-deja/g++.jason/report.C: Expect extra warnings. * g++.dg/warn/unused-result1.C: XFAIL. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@149750 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9ac88fd7b65..23db8321431 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3230,7 +3230,7 @@ expand_or_defer_fn (tree fn) return; } - gcc_assert (gimple_body (fn)); + gcc_assert (DECL_SAVED_TREE (fn)); /* If this is a constructor or destructor body, we have to clone it. */ -- cgit v1.2.1 From 7496b60933cbb86c3bb26e4f17bc3d1861492c47 Mon Sep 17 00:00:00 2001 From: rguenth Date: Thu, 27 Aug 2009 08:56:10 +0000 Subject: 2009-08-27 Richard Guenther * gengtype.c (main): Handle uint64_t. * ipa-utils.c (get_base_var): Indent properly. * tree-ssa-live.c (debug_scope_block): New function. * tree-flow.h (debug_scope_block): Declare. * tree-ssa-copy.c (replace_exp_1): Add vertical space. * basic-block.h (enum profile_status): Rename to enum profile_status_d. (x_profile_status): Adjust type. cp/ * class.c (build_vtbl_ref_1): Remove excess vertical space. * Make-lang.in (CXX_TREE_H): Remove c-common.def dependency tracked by $(TREE_H). * semantics.c (expand_or_defer_fn): Zero DECL_SAVED_TREE. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151139 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 23db8321431..1c16b72e8d5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3239,6 +3239,7 @@ expand_or_defer_fn (tree fn) /* We don't want to process FN again, so pretend we've written it out, even though we haven't. */ TREE_ASM_WRITTEN (fn) = 1; + DECL_SAVED_TREE (fn) = NULL_TREE; return; } -- cgit v1.2.1 From 7c8750c15d57df1cda76bc66e0a7a59bd4544f2e Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 2 Sep 2009 15:48:52 +0000 Subject: * semantics.c (describable_type): Don't pretend to be in a template. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151335 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1c16b72e8d5..1e5255e8ce2 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4543,17 +4543,13 @@ describable_type (tree expr) { tree type = NULL_TREE; - /* processing_template_decl isn't set when we're called from the mangling - code, so bump it now. */ - ++processing_template_decl; if (! type_dependent_expression_p (expr) && ! type_unknown_p (expr)) { - type = TREE_TYPE (expr); + type = unlowered_expr_type (expr); if (real_lvalue_p (expr)) type = build_reference_type (type); } - --processing_template_decl; if (type) return type; -- 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/semantics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1e5255e8ce2..477140c4472 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3186,7 +3186,9 @@ emit_associated_thunks (tree fn) is so that you can know statically the entire set of thunks that will ever be needed for a given virtual function, thereby enabling you to output all the thunks with the function itself. */ - if (DECL_VIRTUAL_P (fn)) + if (DECL_VIRTUAL_P (fn) + /* Do not emit thunks for extern template instantiations. */ + && ! DECL_REALLY_EXTERN (fn)) { tree thunk; -- cgit v1.2.1 From 78f55ca8366d5fc6a1547b4ab5998397e7618216 Mon Sep 17 00:00:00 2001 From: rth Date: Mon, 14 Sep 2009 20:17:24 +0000 Subject: * builtins.c (expand_builtin_synchronize): Use gimple_build_asm_vec. * cfgbuild.c (make_edges): Handle asm goto. * cfglayout.c (fixup_reorder_chain): Likewise. * cfgrtl.c (patch_jump_insn): Likewise. * gimple-pretty-print.c (dump_gimple_asm): Likewise. * gimple.c (gimple_build_asm_1): Add and use nlabels parameter. (gimple_build_asm_vec): Add and use labels parameter. (gimple_build_asm): Remove. (walk_gimple_asm): Walk labels too. * gimple.def (GIMPLE_ASM): Update docs. * gimple.h: Update decls. (struct gimple_statement_asm): Change nc to use unsigned char; add nl member. (gimple_asm_nlabels): New. (gimple_asm_label_op, gimple_asm_set_label_op): New. * gimplify.c (gimplify_asm_expr): Copy labels from ASM_EXPR into gimple_build_asm_vec. * jump.c (mark_jump_label_asm): New. (mark_jump_label): Use it. (redirect_jump_1): Handle asm goto. (invert_jump_1): Soft fail if X is null. * recog.c (extract_asm_operands): New. (asm_noperands): Use it; handle asm labels. (decode_asm_operands): Use extract_asm_operands. (asm_operand_ok): Properly handle empty string. * reg-stack.c (get_asm_operands_in_out): Rename from get_asm_operand_n_inputs; use extract_asm_operands; return both inputs and outputs by reference; update all callers. * rtl.def (ASM_OPERANDS): Add label vector as operand 6. * rtl.h (ASM_OPERANDS_LABEL_VEC): New. (ASM_OPERANDS_LABEL_LENGTH, ASM_OPERANDS_LABEL): New. (ASM_OPERANDS_SOURCE_LOCATION): Renumber. (extract_asm_operands): Declare. * stmt.c (expand_asm_operands): Add and use labels parameter. (check_unique_operand_names): Likewise. (resolve_asm_operand_names, resolve_operand_name_1): Likewise. (expand_asm_stmt): Handle asm labels. * tree-cfg.c (make_gimple_asm_edges): New. (make_edges): Use it. (cleanup_dead_labels): Handle asm labels. (is_ctrl_altering_stmt): Likewise. (gimple_redirect_edge_and_branch): Likewise. * tree.def (ASM_EXPR): Add 5th operand. * tree.h (ASM_LABELS): New. (resolve_asm_operand_names): Update decl. * c-parser.c (c_parser_asm_statement): Parse asm goto. (c_parser_asm_goto_operands): New. * c-tree.h (build_asm_expr): Update decl. * c-typeck.c (build_asm_expr): Add and use labels parameter. * doc/extend.texi: Document asm goto. gcc/ada/ * gcc-interface/trans.c (Pragma_to_gnu): Use build5 for ASM_EXPR. gcc/cp/ * cp-tree.h (finish_asm_stmt): Update decl. * parser.c (cp_parser_asm_definition): Parse asm goto. (cp_parser_asm_label_list): New. * pt.c (tsubst_copy_asm_operands): Don't recurse on labels. (tsubst_expr): Handle asm labels. * semantics.c (finish_asm_stmt): Add and use labels parameter. gcc/testsuite/ * c-c++-common/asmgoto-1.c, c-c++-common/asmgoto-2.c, c-c++-common/asmgoto-3.c, gcc.c-torture/compile/asmgoto-1.c, gcc.dg/tree-ssa/asmgoto-1.c: New files. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@151701 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 477140c4472..6b741b3ebe5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1200,12 +1200,13 @@ finish_compound_stmt (tree stmt) } /* Finish an asm-statement, whose components are a STRING, some - OUTPUT_OPERANDS, some INPUT_OPERANDS, and some CLOBBERS. Also note - whether the asm-statement should be considered volatile. */ + OUTPUT_OPERANDS, some INPUT_OPERANDS, some CLOBBERS and some + LABELS. Also note whether the asm-statement should be + considered volatile. */ tree finish_asm_stmt (int volatile_p, tree string, tree output_operands, - tree input_operands, tree clobbers) + tree input_operands, tree clobbers, tree labels) { tree r; tree t; @@ -1223,7 +1224,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, oconstraints = (const char **) alloca (noutputs * sizeof (char *)); string = resolve_asm_operand_names (string, output_operands, - input_operands); + input_operands, labels); for (i = 0, t = output_operands; t; t = TREE_CHAIN (t), ++i) { @@ -1309,7 +1310,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, r = build_stmt (input_location, ASM_EXPR, string, output_operands, input_operands, - clobbers); + clobbers, labels); ASM_VOLATILE_P (r) = volatile_p || noutputs == 0; r = maybe_cleanup_point_expr_void (r); return add_stmt (r); -- 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/semantics.c | 522 ++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 516 insertions(+), 6 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6b741b3ebe5..6dec9f8a339 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -55,6 +55,7 @@ along with GCC; see the file COPYING3. If not see static tree maybe_convert_cond (tree); static tree finalize_nrv_r (tree *, int *, void *); +static tree capture_decltype (tree); /* Deferred Access Checking Overview @@ -1445,6 +1446,21 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) return error_mark_node; } + + /* If decl is a field, object has a lambda type, and decl is not a member + of that type, then we have a reference to a member of 'this' from a + lambda inside a non-static member function, and we must get to decl + through the 'this' capture. If decl is not a member of that object, + either, then its access will still fail later. */ + if (LAMBDA_TYPE_P (TREE_TYPE (object)) + && !same_type_ignoring_top_level_qualifiers_p (DECL_CONTEXT (decl), + TREE_TYPE (object))) + object = cp_build_indirect_ref (lambda_expr_this_capture + (CLASSTYPE_LAMBDA_EXPR + (TREE_TYPE (object))), + /*errorstring=*/"", + /*complain=*/tf_warning_or_error); + if (current_class_ptr) TREE_USED (current_class_ptr) = 1; if (processing_template_decl && !qualifying_scope) @@ -2049,7 +2065,14 @@ finish_this_expr (void) if (current_class_ptr) { - result = current_class_ptr; + tree type = TREE_TYPE (current_class_ref); + + /* In a lambda expression, 'this' refers to the captured 'this'. */ + if (LAMBDA_TYPE_P (type)) + result = lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (type)); + else + result = current_class_ptr; + } else if (current_function_decl && DECL_STATIC_FUNCTION_P (current_function_decl)) @@ -2613,6 +2636,18 @@ baselink_for_fns (tree fns) return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE); } +/* Returns true iff DECL is an automatic variable from a function outside + the current one. */ + +static bool +outer_automatic_var_p (tree decl) +{ + return ((TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL) + && DECL_FUNCTION_SCOPE_P (decl) + && !TREE_STATIC (decl) + && DECL_CONTEXT (decl) != current_function_decl); +} + /* ID_EXPRESSION is a representation of parsed, but unprocessed, id-expression. (See cp_parser_id_expression for details.) SCOPE, if non-NULL, is the type or namespace used to explicitly qualify @@ -2714,12 +2749,61 @@ finish_id_expression (tree id_expression, if (!scope && decl != error_mark_node) maybe_note_name_used_in_class (id_expression, decl); - /* Disallow uses of local variables from containing functions. */ - if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL) + /* Disallow uses of local variables from containing functions, except + within lambda-expressions. */ + if (outer_automatic_var_p (decl) + /* It's not a use (3.2) if we're in an unevaluated context. */ + && !cp_unevaluated_operand) { - tree context = decl_function_context (decl); - if (context != NULL_TREE && context != current_function_decl - && ! TREE_STATIC (decl)) + tree context = DECL_CONTEXT (decl); + tree containing_function = current_function_decl; + tree lambda_stack = NULL_TREE; + tree lambda_expr = NULL_TREE; + + /* Core issue 696: "[At the July 2009 meeting] the CWG expressed + support for an approach in which a reference to a local + [constant] automatic variable in a nested class or lambda body + would enter the expression as an rvalue, which would reduce + the complexity of the problem" + + FIXME update for final resolution of core issue 696. */ + if (DECL_INTEGRAL_CONSTANT_VAR_P (decl)) + return integral_constant_value (decl); + + /* If we are in a lambda function, we can move out until we hit + 1. the context, + 2. a non-lambda function, or + 3. a non-default capturing lambda function. */ + while (context != containing_function + && LAMBDA_FUNCTION_P (containing_function)) + { + lambda_expr = CLASSTYPE_LAMBDA_EXPR + (DECL_CONTEXT (containing_function)); + + if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda_expr) + == CPLD_NONE) + break; + + lambda_stack = tree_cons (NULL_TREE, + lambda_expr, + lambda_stack); + + containing_function + = decl_function_context (containing_function); + } + + if (context == containing_function) + { + decl = add_default_capture (lambda_stack, + /*id=*/DECL_NAME (decl), + /*initializer=*/decl); + } + else if (lambda_expr) + { + error ("%qD is not captured", decl); + return error_mark_node; + } + else { error (TREE_CODE (decl) == VAR_DECL ? "use of % variable from containing function" @@ -4788,6 +4872,18 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) if (real_lvalue_p (expr)) type = build_reference_type (type); } + /* Within a lambda-expression: + + Every occurrence of decltype((x)) where x is a possibly + parenthesized id-expression that names an entity of + automatic storage duration is treated as if x were + transformed into an access to a corresponding data member + of the closure type that would have been declared if x + were a use of the denoted entity. */ + else if (outer_automatic_var_p (expr) + && current_function_decl + && LAMBDA_FUNCTION_P (current_function_decl)) + type = capture_decltype (expr); else { /* Otherwise, where T is the type of e, if e is an lvalue, @@ -4842,6 +4938,8 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) it now. */ if (CLASSTYPE_LAZY_COPY_CTOR (type)) lazily_declare_fn (sfk_copy_constructor, type); + if (CLASSTYPE_LAZY_MOVE_CTOR (type)) + lazily_declare_fn (sfk_move_constructor, type); fns = CLASSTYPE_CONSTRUCTORS (type); } else @@ -5105,4 +5203,416 @@ float_const_decimal64_p (void) return 0; } +/* Constructor for a lambda expression. */ + +tree +build_lambda_expr (void) +{ + tree lambda = make_node (LAMBDA_EXPR); + LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) = CPLD_NONE; + LAMBDA_EXPR_CAPTURE_LIST (lambda) = NULL_TREE; + LAMBDA_EXPR_THIS_CAPTURE (lambda) = NULL_TREE; + LAMBDA_EXPR_RETURN_TYPE (lambda) = NULL_TREE; + LAMBDA_EXPR_MUTABLE_P (lambda) = false; + return lambda; +} + +/* Create the closure object for a LAMBDA_EXPR. */ + +tree +build_lambda_object (tree lambda_expr) +{ + /* Build aggregate constructor call. + - cp_parser_braced_list + - cp_parser_functional_cast */ + VEC(constructor_elt,gc) *elts = NULL; + tree node, expr, type; + location_t saved_loc; + + if (processing_template_decl) + return lambda_expr; + + /* Make sure any error messages refer to the lambda-introducer. */ + saved_loc = input_location; + input_location = LAMBDA_EXPR_LOCATION (lambda_expr); + + for (node = LAMBDA_EXPR_CAPTURE_LIST (lambda_expr); + node; + node = TREE_CHAIN (node)) + { + tree field = TREE_PURPOSE (node); + tree val = TREE_VALUE (node); + + /* Mere mortals can't copy arrays with aggregate initialization, so + do some magic to make it work here. */ + if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE) + val = build_array_copy (val); + + CONSTRUCTOR_APPEND_ELT (elts, DECL_NAME (field), val); + } + + expr = build_constructor (init_list_type_node, elts); + CONSTRUCTOR_IS_DIRECT_INIT (expr) = 1; + + /* N2927: "[The closure] class type is not an aggregate." + But we briefly treat it as an aggregate to make this simpler. */ + type = TREE_TYPE (lambda_expr); + CLASSTYPE_NON_AGGREGATE (type) = 0; + expr = finish_compound_literal (type, expr); + CLASSTYPE_NON_AGGREGATE (type) = 1; + + input_location = saved_loc; + return expr; +} + +/* Return an initialized RECORD_TYPE for LAMBDA. + LAMBDA must have its explicit captures already. */ + +tree +begin_lambda_type (tree lambda) +{ + tree type; + + { + /* Unique name. This is just like an unnamed class, but we cannot use + make_anon_name because of certain checks against TYPE_ANONYMOUS_P. */ + tree name; + name = make_lambda_name (); + + /* Create the new RECORD_TYPE for this lambda. */ + type = xref_tag (/*tag_code=*/record_type, + name, + /*scope=*/ts_within_enclosing_non_class, + /*template_header_p=*/false); + } + + /* Designate it as a struct so that we can use aggregate initialization. */ + CLASSTYPE_DECLARED_CLASS (type) = false; + + /* Clear base types. */ + xref_basetypes (type, /*bases=*/NULL_TREE); + + /* Start the class. */ + type = begin_class_definition (type, /*attributes=*/NULL_TREE); + + /* Cross-reference the expression and the type. */ + TREE_TYPE (lambda) = type; + CLASSTYPE_LAMBDA_EXPR (type) = lambda; + + return type; +} + +/* Returns the type to use for the return type of the operator() of a + closure class. */ + +tree +lambda_return_type (tree expr) +{ + tree type; + if (type_dependent_expression_p (expr)) + { + type = cxx_make_type (DECLTYPE_TYPE); + DECLTYPE_TYPE_EXPR (type) = expr; + DECLTYPE_FOR_LAMBDA_RETURN (type) = true; + SET_TYPE_STRUCTURAL_EQUALITY (type); + } + else + type = type_decays_to (unlowered_expr_type (expr)); + return type; +} + +/* Given a LAMBDA_EXPR or closure type LAMBDA, return the op() of the + closure type. */ + +tree +lambda_function (tree lambda) +{ + tree type; + if (TREE_CODE (lambda) == LAMBDA_EXPR) + type = TREE_TYPE (lambda); + else + type = lambda; + gcc_assert (LAMBDA_TYPE_P (type)); + /* Don't let debug_tree cause instantiation. */ + if (CLASSTYPE_TEMPLATE_INSTANTIATION (type) && !COMPLETE_TYPE_P (type)) + return NULL_TREE; + lambda = lookup_member (type, ansi_opname (CALL_EXPR), + /*protect=*/0, /*want_type=*/false); + if (lambda) + lambda = BASELINK_FUNCTIONS (lambda); + return lambda; +} + +/* Returns the type to use for the FIELD_DECL corresponding to the + capture of EXPR. + The caller should add REFERENCE_TYPE for capture by reference. */ + +tree +lambda_capture_field_type (tree expr) +{ + tree type; + if (type_dependent_expression_p (expr)) + { + type = cxx_make_type (DECLTYPE_TYPE); + DECLTYPE_TYPE_EXPR (type) = expr; + DECLTYPE_FOR_LAMBDA_CAPTURE (type) = true; + SET_TYPE_STRUCTURAL_EQUALITY (type); + } + else + type = non_reference (unlowered_expr_type (expr)); + return type; +} + +/* Recompute the return type for LAMBDA with body of the form: + { return EXPR ; } */ + +void +apply_lambda_return_type (tree lambda, tree return_type) +{ + tree fco = lambda_function (lambda); + tree result; + + LAMBDA_EXPR_RETURN_TYPE (lambda) = return_type; + + /* If we got a DECLTYPE_TYPE, don't stick it in the function yet, + it would interfere with instantiating the closure type. */ + if (dependent_type_p (return_type)) + return; + if (return_type == error_mark_node) + return; + + /* TREE_TYPE (FUNCTION_DECL) == METHOD_TYPE + TREE_TYPE (METHOD_TYPE) == return-type */ + TREE_TYPE (TREE_TYPE (fco)) = return_type; + + result = DECL_RESULT (fco); + if (result == NULL_TREE) + return; + + /* We already have a DECL_RESULT from start_preparsed_function. + Now we need to redo the work it and allocate_struct_function + did to reflect the new type. */ + result = build_decl (input_location, RESULT_DECL, NULL_TREE, + TYPE_MAIN_VARIANT (return_type)); + DECL_ARTIFICIAL (result) = 1; + DECL_IGNORED_P (result) = 1; + cp_apply_type_quals_to_decl (cp_type_quals (return_type), + result); + + DECL_RESULT (fco) = result; + + if (!processing_template_decl && aggregate_value_p (result, fco)) + { +#ifdef PCC_STATIC_STRUCT_RETURN + cfun->returns_pcc_struct = 1; +#endif + cfun->returns_struct = 1; + } + +} + +/* DECL is a local variable or parameter from the surrounding scope of a + lambda-expression. Returns the decltype for a use of the capture field + for DECL even if it hasn't been captured yet. */ + +static tree +capture_decltype (tree decl) +{ + tree lam = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (current_function_decl)); + /* FIXME do lookup instead of list walk? */ + tree cap = value_member (decl, LAMBDA_EXPR_CAPTURE_LIST (lam)); + tree type; + + if (cap) + type = TREE_TYPE (TREE_PURPOSE (cap)); + else + switch (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lam)) + { + case CPLD_NONE: + error ("%qD is not captured", decl); + return error_mark_node; + + case CPLD_COPY: + type = TREE_TYPE (decl); + if (TREE_CODE (type) == REFERENCE_TYPE + && TREE_CODE (TREE_TYPE (type)) != FUNCTION_TYPE) + type = TREE_TYPE (type); + break; + + case CPLD_REFERENCE: + type = TREE_TYPE (decl); + if (TREE_CODE (type) != REFERENCE_TYPE) + type = build_reference_type (TREE_TYPE (decl)); + break; + + default: + gcc_unreachable (); + } + + if (TREE_CODE (type) != REFERENCE_TYPE) + { + if (!LAMBDA_EXPR_MUTABLE_P (lam)) + type = cp_build_qualified_type (type, (TYPE_QUALS (type) + |TYPE_QUAL_CONST)); + type = build_reference_type (type); + } + return type; +} + +/* From an ID and INITIALIZER, create a capture (by reference if + BY_REFERENCE_P is true), add it to the capture-list for LAMBDA, + and return it. */ + +tree +add_capture (tree lambda, tree id, tree initializer, bool by_reference_p) +{ + tree type; + tree member; + + type = lambda_capture_field_type (initializer); + if (by_reference_p) + { + type = build_reference_type (type); + if (!real_lvalue_p (initializer)) + error ("cannot capture %qE by reference", initializer); + } + + /* Make member variable. */ + member = build_lang_decl (FIELD_DECL, id, type); + + /* Add it to the appropriate closure class. */ + finish_member_declaration (member); + + LAMBDA_EXPR_CAPTURE_LIST (lambda) + = tree_cons (member, initializer, LAMBDA_EXPR_CAPTURE_LIST (lambda)); + + if (id == get_identifier ("__this")) + { + if (LAMBDA_EXPR_CAPTURES_THIS_P (lambda)) + error ("already captured % in lambda expression"); + LAMBDA_EXPR_THIS_CAPTURE (lambda) = member; + } + + return member; +} + +/* Similar to add_capture, except this works on a stack of nested lambdas. + BY_REFERENCE_P in this case is derived from the default capture mode. + Returns the capture for the lambda at the bottom of the stack. */ + +tree +add_default_capture (tree lambda_stack, tree id, tree initializer) +{ + bool this_capture_p = (id == get_identifier ("__this")); + + tree member = NULL_TREE; + + tree saved_class_type = current_class_type; + + tree node; + + for (node = lambda_stack; + node; + node = TREE_CHAIN (node)) + { + tree lambda = TREE_VALUE (node); + + current_class_type = TREE_TYPE (lambda); + member = add_capture (lambda, + id, + initializer, + /*by_reference_p=*/ + (!this_capture_p + && (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) + == CPLD_REFERENCE))); + + { + /* Have to get the old value of current_class_ref. */ + tree object = cp_build_indirect_ref (DECL_ARGUMENTS + (lambda_function (lambda)), + /*errorstring=*/"", + /*complain=*/tf_warning_or_error); + initializer = finish_non_static_data_member + (member, object, /*qualifying_scope=*/NULL_TREE); + } + } + + current_class_type = saved_class_type; + + return member; + +} + +/* Return the capture pertaining to a use of 'this' in LAMBDA, in the form of an + INDIRECT_REF, possibly adding it through default capturing. */ + +tree +lambda_expr_this_capture (tree lambda) +{ + tree result; + + tree this_capture = LAMBDA_EXPR_THIS_CAPTURE (lambda); + + /* Try to default capture 'this' if we can. */ + if (!this_capture + && LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) != CPLD_NONE) + { + tree containing_function = TYPE_CONTEXT (TREE_TYPE (lambda)); + tree lambda_stack = tree_cons (NULL_TREE, lambda, NULL_TREE); + + /* If we are in a lambda function, we can move out until we hit: + 1. a non-lambda function, + 2. a lambda function capturing 'this', or + 3. a non-default capturing lambda function. */ + while (LAMBDA_FUNCTION_P (containing_function)) + { + tree lambda + = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (containing_function)); + + if (LAMBDA_EXPR_THIS_CAPTURE (lambda) + || LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_NONE) + break; + + lambda_stack = tree_cons (NULL_TREE, + lambda, + lambda_stack); + + containing_function = decl_function_context (containing_function); + } + + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (containing_function)) + { + this_capture = add_default_capture (lambda_stack, + /*id=*/get_identifier ("__this"), + /* First parameter is 'this'. */ + /*initializer=*/DECL_ARGUMENTS + (containing_function)); + } + + } + + if (!this_capture) + { + error ("% was not captured for this lambda function"); + result = error_mark_node; + } + else + { + /* To make sure that current_class_ref is for the lambda. */ + gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)) == TREE_TYPE (lambda)); + + result = finish_non_static_data_member (this_capture, + current_class_ref, + /*qualifying_scope=*/NULL_TREE); + + /* If 'this' is captured, each use of 'this' is transformed into an + access to the corresponding unnamed data member of the closure + type cast (_expr.cast_ 5.4) to the type of 'this'. [ The cast + ensures that the transformed expression is an rvalue. ] */ + result = rvalue (result); + } + + return result; +} + #include "gt-cp-semantics.h" -- cgit v1.2.1 From fffbaa80271f7cae65f17950028edbc1b1f39217 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 30 Sep 2009 17:54:37 +0000 Subject: * semantics.c (lambda_expr_this_capture): Fix default capture of explicit capture of 'this'. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152339 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 35 +++++++++++++++++++++++------------ 1 file changed, 23 insertions(+), 12 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6dec9f8a339..725bcc2966a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5540,7 +5540,6 @@ add_default_capture (tree lambda_stack, tree id, tree initializer) current_class_type = saved_class_type; return member; - } /* Return the capture pertaining to a use of 'this' in LAMBDA, in the form of an @@ -5559,6 +5558,7 @@ lambda_expr_this_capture (tree lambda) { tree containing_function = TYPE_CONTEXT (TREE_TYPE (lambda)); tree lambda_stack = tree_cons (NULL_TREE, lambda, NULL_TREE); + tree init = NULL_TREE; /* If we are in a lambda function, we can move out until we hit: 1. a non-lambda function, @@ -5569,9 +5569,20 @@ lambda_expr_this_capture (tree lambda) tree lambda = CLASSTYPE_LAMBDA_EXPR (DECL_CONTEXT (containing_function)); - if (LAMBDA_EXPR_THIS_CAPTURE (lambda) - || LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_NONE) - break; + if (LAMBDA_EXPR_THIS_CAPTURE (lambda)) + { + /* An outer lambda has already captured 'this'. */ + tree cap = LAMBDA_EXPR_THIS_CAPTURE (lambda); + tree lthis + = cp_build_indirect_ref (DECL_ARGUMENTS (containing_function), + "", tf_warning_or_error); + init = finish_non_static_data_member (cap, lthis, NULL_TREE); + break; + } + + if (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_NONE) + /* An outer lambda won't let us capture 'this'. */ + break; lambda_stack = tree_cons (NULL_TREE, lambda, @@ -5580,15 +5591,15 @@ lambda_expr_this_capture (tree lambda) containing_function = decl_function_context (containing_function); } - if (DECL_NONSTATIC_MEMBER_FUNCTION_P (containing_function)) - { - this_capture = add_default_capture (lambda_stack, - /*id=*/get_identifier ("__this"), - /* First parameter is 'this'. */ - /*initializer=*/DECL_ARGUMENTS - (containing_function)); - } + if (!init && DECL_NONSTATIC_MEMBER_FUNCTION_P (containing_function) + && !LAMBDA_FUNCTION_P (containing_function)) + /* First parameter is 'this'. */ + init = DECL_ARGUMENTS (containing_function); + if (init) + this_capture = add_default_capture (lambda_stack, + /*id=*/get_identifier ("__this"), + init); } if (!this_capture) -- 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/semantics.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 725bcc2966a..8199af0e693 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5203,6 +5203,87 @@ float_const_decimal64_p (void) return 0; } +/* Return true if T is a literal type. */ + +bool +literal_type_p (tree t) +{ + if (SCALAR_TYPE_P (t)) + return true; + if (CLASS_TYPE_P (t)) + return CLASSTYPE_LITERAL_P (t); + if (TREE_CODE (t) == ARRAY_TYPE) + return literal_type_p (strip_array_types (t)); + return false; +} + + +/* If DECL is a variable declared `constexpr', require its type + be literal. Return the DECL if OK, otherwise NULL. */ + +tree +ensure_literal_type_for_constexpr_object (tree decl) +{ + tree type = TREE_TYPE (decl); + if (TREE_CODE (decl) == VAR_DECL && DECL_DECLARED_CONSTEXPR_P (decl) + && !processing_template_decl && !literal_type_p (type)) + { + error ("the type %qT of constexpr variable %qD is not literal", + type, decl); + return NULL; + } + return decl; +} + +/* Return non-null if FUN certainly designates a valid constexpr function + declaration. Otherwise return NULL. Issue appropriate diagnostics + if necessary. Note that we only check the declaration, not the body + of the function. */ + +tree +validate_constexpr_fundecl (tree fun) +{ + tree rettype = NULL; + tree parm = NULL; + + /* Don't bother if FUN is not marked constexpr. */ + if (!DECL_DECLARED_CONSTEXPR_P (fun)) + return NULL; + + /* For a function template, we have absolutely no guarantee that all + instantiations will be constexpr. */ + if (TREE_CODE (fun) == TEMPLATE_DECL) + return NULL; + + parm = FUNCTION_FIRST_USER_PARM (fun); + for (; parm != NULL; parm = TREE_CHAIN (parm)) + { + tree type = TREE_TYPE (parm); + if (dependent_type_p (type)) + return NULL; + if (!literal_type_p (type)) + { + error ("parameter %q#D is not of literal type", parm); + return NULL; + } + } + + if (DECL_CONSTRUCTOR_P (fun)) + return fun; + + rettype = TREE_TYPE (TREE_TYPE (fun)); + if (dependent_type_p (rettype)) + return NULL; + if (!literal_type_p (rettype)) + { + error ("return type %qT of function %qD is not a literal type", + TREE_TYPE (TREE_TYPE (fun)), fun); + return NULL; + } + return fun; +} + + /* Constructor for a lambda expression. */ tree -- cgit v1.2.1 From 7da3c25a95641edd488f078f418e1aa664432f87 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 6 Oct 2009 22:14:01 +0000 Subject: Fix lookup of initialized captures in unevaluated context. * cp-tree.h (DECL_NORMAL_CAPTURE_P): New. * name-lookup.c (qualify_lookup): Check it. * parser.c (cp_parser_lambda_introducer): Pass explicit_init_p to add_capture. * semantics.c (add_capture): Set DECL_NORMAL_CAPTURE_P on captures without explicit init. (add_default_capture): Pass explicit_init_p. Fix capture by copy of types with explicit copy constructor. * cp-tree.h (TARGET_EXPR_DIRECT_INIT_P): New. (DIRECT_INIT_EXPR_P): New. * typeck.c (convert_for_initialization): Just return if DIRECT_INIT_EXPR_P. * parser.c (cp_parser_lambda_introducer): Use TARGET_EXPR_DIRECT_INIT_P for normal captures. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152500 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8199af0e693..391228b02a6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5328,6 +5328,20 @@ build_lambda_object (tree lambda_expr) do some magic to make it work here. */ if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE) val = build_array_copy (val); + else if (DECL_NORMAL_CAPTURE_P (field) + && TREE_CODE (TREE_TYPE (field)) != REFERENCE_TYPE) + { + /* "the entities that are captured by copy are used to + direct-initialize each corresponding non-static data + member of the resulting closure object." + + There's normally no way to express direct-initialization + from an element of a CONSTRUCTOR, so we build up a special + TARGET_EXPR to bypass the usual copy-initialization. */ + val = force_rvalue (val); + if (TREE_CODE (val) == TARGET_EXPR) + TARGET_EXPR_DIRECT_INIT_P (val) = true; + } CONSTRUCTOR_APPEND_ELT (elts, DECL_NAME (field), val); } @@ -5545,7 +5559,8 @@ capture_decltype (tree decl) and return it. */ tree -add_capture (tree lambda, tree id, tree initializer, bool by_reference_p) +add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, + bool explicit_init_p) { tree type; tree member; @@ -5560,6 +5575,13 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p) /* Make member variable. */ member = build_lang_decl (FIELD_DECL, id, type); + if (!explicit_init_p) + /* Normal captures are invisible to name lookup but uses are replaced + with references to the capture field; we implement this by only + really making them invisible in unevaluated context; see + qualify_lookup. For now, let's make explicitly initialized captures + always visible. */ + DECL_NORMAL_CAPTURE_P (member) = true; /* Add it to the appropriate closure class. */ finish_member_declaration (member); @@ -5605,7 +5627,8 @@ add_default_capture (tree lambda_stack, tree id, tree initializer) /*by_reference_p=*/ (!this_capture_p && (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) - == CPLD_REFERENCE))); + == CPLD_REFERENCE)), + /*explicit_init_p=*/false); { /* Have to get the old value of current_class_ref. */ -- cgit v1.2.1 From eebd67e77cb2aac330d3449d78d40a3770238a97 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 8 Oct 2009 16:09:22 +0000 Subject: PR c++/37177 * pt.c (resolve_nondeduced_context): New. * cvt.c (convert_to_void): Call it. * semantics.c (finish_decltype_type): Likewise. * typeck.c (decay_conversion): Here too. * pt.c (tsubst_decl): Don't clobber input_location. Don't register a bad specialization. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@152564 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 391228b02a6..6cf22204a5e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4741,6 +4741,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) /* The type denoted by decltype(e) is defined as follows: */ + expr = resolve_nondeduced_context (expr); if (id_expression_or_member_access_p) { /* If e is an id-expression or a class member access (5.2.5 @@ -4766,9 +4767,13 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) /* See through BASELINK nodes to the underlying functions. */ expr = BASELINK_FUNCTIONS (expr); + if (TREE_CODE (expr) == TEMPLATE_ID_EXPR) + expr = TREE_OPERAND (expr, 0); + if (TREE_CODE (expr) == OVERLOAD) { - if (OVL_CHAIN (expr)) + if (OVL_CHAIN (expr) + || TREE_CODE (OVL_FUNCTION (expr)) == TEMPLATE_DECL) { error ("%qE refers to a set of overloaded functions", orig_expr); return error_mark_node; -- cgit v1.2.1 From ab9eab4aa8b55cb559a1b400943749098556d9a1 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 23 Oct 2009 18:08:18 +0000 Subject: * semantics.c (outer_lambda_capture_p): New fn. (thisify_lambda_field): Factor out... (add_default_capture): ...from here. (finish_id_expression): Use them. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153510 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 59 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 43 insertions(+), 16 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6cf22204a5e..3e39f3765e1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -56,6 +56,7 @@ along with GCC; see the file COPYING3. If not see static tree maybe_convert_cond (tree); static tree finalize_nrv_r (tree *, int *, void *); static tree capture_decltype (tree); +static tree thisify_lambda_field (tree); /* Deferred Access Checking Overview @@ -1447,14 +1448,13 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) return error_mark_node; } - /* If decl is a field, object has a lambda type, and decl is not a member - of that type, then we have a reference to a member of 'this' from a + /* If decl is a non-capture field and object has a lambda type, + then we have a reference to a member of 'this' from a lambda inside a non-static member function, and we must get to decl through the 'this' capture. If decl is not a member of that object, either, then its access will still fail later. */ if (LAMBDA_TYPE_P (TREE_TYPE (object)) - && !same_type_ignoring_top_level_qualifiers_p (DECL_CONTEXT (decl), - TREE_TYPE (object))) + && !LAMBDA_TYPE_P (DECL_CONTEXT (decl))) object = cp_build_indirect_ref (lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (TREE_TYPE (object))), @@ -2648,6 +2648,18 @@ outer_automatic_var_p (tree decl) && DECL_CONTEXT (decl) != current_function_decl); } +/* Returns true iff DECL is a capture field from a lambda that is not our + immediate context. */ + +static bool +outer_lambda_capture_p (tree decl) +{ + return (TREE_CODE (decl) == FIELD_DECL + && LAMBDA_TYPE_P (DECL_CONTEXT (decl)) + && (!current_class_type + || !DERIVED_FROM_P (DECL_CONTEXT (decl), current_class_type))); +} + /* ID_EXPRESSION is a representation of parsed, but unprocessed, id-expression. (See cp_parser_id_expression for details.) SCOPE, if non-NULL, is the type or namespace used to explicitly qualify @@ -2751,7 +2763,8 @@ finish_id_expression (tree id_expression, /* Disallow uses of local variables from containing functions, except within lambda-expressions. */ - if (outer_automatic_var_p (decl) + if ((outer_automatic_var_p (decl) + || outer_lambda_capture_p (decl)) /* It's not a use (3.2) if we're in an unevaluated context. */ && !cp_unevaluated_operand) { @@ -2759,6 +2772,7 @@ finish_id_expression (tree id_expression, tree containing_function = current_function_decl; tree lambda_stack = NULL_TREE; tree lambda_expr = NULL_TREE; + tree initializer = decl; /* Core issue 696: "[At the July 2009 meeting] the CWG expressed support for an approach in which a reference to a local @@ -2770,6 +2784,13 @@ finish_id_expression (tree id_expression, if (DECL_INTEGRAL_CONSTANT_VAR_P (decl)) return integral_constant_value (decl); + if (TYPE_P (context)) + { + /* Implicit capture of an explicit capture. */ + context = lambda_function (context); + initializer = thisify_lambda_field (decl); + } + /* If we are in a lambda function, we can move out until we hit 1. the context, 2. a non-lambda function, or @@ -2796,7 +2817,7 @@ finish_id_expression (tree id_expression, { decl = add_default_capture (lambda_stack, /*id=*/DECL_NAME (decl), - /*initializer=*/decl); + initializer); } else if (lambda_expr) { @@ -5604,6 +5625,21 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, return member; } +/* Given a FIELD_DECL decl belonging to a closure type, return a + COMPONENT_REF of it relative to the 'this' parameter of the op() for + that type. */ + +static tree +thisify_lambda_field (tree decl) +{ + tree context = lambda_function (DECL_CONTEXT (decl)); + tree object = cp_build_indirect_ref (DECL_ARGUMENTS (context), + /*errorstring*/"", + tf_warning_or_error); + return finish_non_static_data_member (decl, object, + /*qualifying_scope*/NULL_TREE); +} + /* Similar to add_capture, except this works on a stack of nested lambdas. BY_REFERENCE_P in this case is derived from the default capture mode. Returns the capture for the lambda at the bottom of the stack. */ @@ -5634,16 +5670,7 @@ add_default_capture (tree lambda_stack, tree id, tree initializer) && (LAMBDA_EXPR_DEFAULT_CAPTURE_MODE (lambda) == CPLD_REFERENCE)), /*explicit_init_p=*/false); - - { - /* Have to get the old value of current_class_ref. */ - tree object = cp_build_indirect_ref (DECL_ARGUMENTS - (lambda_function (lambda)), - /*errorstring=*/"", - /*complain=*/tf_warning_or_error); - initializer = finish_non_static_data_member - (member, object, /*qualifying_scope=*/NULL_TREE); - } + initializer = thisify_lambda_field (member); } current_class_type = saved_class_type; -- cgit v1.2.1 From 84e244c597f0d8a818556abf09ba2fc031493a43 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 23 Oct 2009 20:09:45 +0000 Subject: * semantics.c (lambda_expr_this_capture): Use thisify_lambda_field. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153512 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3e39f3765e1..417c15f428e 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5709,10 +5709,7 @@ lambda_expr_this_capture (tree lambda) { /* An outer lambda has already captured 'this'. */ tree cap = LAMBDA_EXPR_THIS_CAPTURE (lambda); - tree lthis - = cp_build_indirect_ref (DECL_ARGUMENTS (containing_function), - "", tf_warning_or_error); - init = finish_non_static_data_member (cap, lthis, NULL_TREE); + init = thisify_lambda_field (cap); break; } -- cgit v1.2.1 From 91a733f97f879e50ec17dea55200c6d630d75cd3 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Oct 2009 21:58:09 +0000 Subject: Allow no-capture lambdas to convert to function pointer. * semantics.c (maybe_add_lambda_conv_op): New. * parser.c (cp_parser_lambda_expression): Call it. (cp_parser_lambda_declarator_opt): Make op() static if no captures. * mangle.c (write_closure_type_name): Adjust. * semantics.c (finish_this_expr): Adjust. * decl.c (grok_op_properties): Allow it. * call.c (build_user_type_conversion_1): Handle static conversion op. (build_op_call): And op(). git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@153617 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 69 +++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 11 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 417c15f428e..e270a734fa0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2063,17 +2063,13 @@ finish_this_expr (void) { tree result; - if (current_class_ptr) - { - tree type = TREE_TYPE (current_class_ref); - - /* In a lambda expression, 'this' refers to the captured 'this'. */ - if (LAMBDA_TYPE_P (type)) - result = lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (type)); - else - result = current_class_ptr; - - } + /* In a lambda expression, 'this' refers to the captured 'this'. */ + if (current_function_decl + && LAMBDA_FUNCTION_P (current_function_decl)) + result = (lambda_expr_this_capture + (CLASSTYPE_LAMBDA_EXPR (current_class_type))); + else if (current_class_ptr) + result = current_class_ptr; else if (current_function_decl && DECL_STATIC_FUNCTION_P (current_function_decl)) { @@ -5759,4 +5755,55 @@ lambda_expr_this_capture (tree lambda) return result; } +/* If the closure TYPE has a static op(), also add a conversion to function + pointer. */ + +void +maybe_add_lambda_conv_op (tree type) +{ + bool nested = (current_function_decl != NULL_TREE); + tree callop = lambda_function (type); + tree rettype, name, fntype, fn, body, compound_stmt; + + if (!DECL_STATIC_FUNCTION_P (callop)) + return; + + rettype = build_pointer_type (TREE_TYPE (callop)); + name = mangle_conv_op_name_for_type (rettype); + fntype = build_function_type (rettype, void_list_node); + fn = build_lang_decl (FUNCTION_DECL, name, fntype); + DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); + + if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn + && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) + DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; + + SET_OVERLOADED_OPERATOR_CODE (fn, TYPE_EXPR); + grokclassfn (type, fn, NO_SPECIAL); + set_linkage_according_to_type (type, fn); + rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof); + DECL_IN_AGGR_P (fn) = 1; + DECL_ARTIFICIAL (fn) = 1; + DECL_NOT_REALLY_EXTERN (fn) = 1; + DECL_DECLARED_INLINE_P (fn) = 1; + DECL_STATIC_FUNCTION_P (fn) = 1; + + add_method (type, fn, NULL_TREE); + + if (nested) + push_function_context (); + start_preparsed_function (fn, NULL_TREE, + SF_PRE_PARSED | SF_INCLASS_INLINE); + body = begin_function_body (); + compound_stmt = begin_compound_stmt (0); + + finish_return_stmt (decay_conversion (callop)); + + finish_compound_stmt (compound_stmt); + finish_function_body (body); + + expand_or_defer_fn (finish_function (2)); + if (nested) + pop_function_context (); +} #include "gt-cp-semantics.h" -- cgit v1.2.1 From a55b2063be9c90c654d99160a144cb174541af83 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 13 Nov 2009 14:40:22 +0000 Subject: PR c++/21008, DR 515 * semantics.c (finish_non_static_data_member): Don't check derivation in a template. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154150 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e270a734fa0..c1df24bfffa 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1485,6 +1485,14 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) return build_min (COMPONENT_REF, type, object, decl, NULL_TREE); } + /* If PROCESSING_TEMPLATE_DECL is nonzero here, then + QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF + for now. */ + else if (processing_template_decl) + return build_qualified_name (TREE_TYPE (decl), + qualifying_scope, + DECL_NAME (decl), + /*template_p=*/false); else { tree access_type = TREE_TYPE (object); @@ -1504,15 +1512,6 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) } } - /* If PROCESSING_TEMPLATE_DECL is nonzero here, then - QUALIFYING_SCOPE is also non-null. Wrap this in a SCOPE_REF - for now. */ - if (processing_template_decl) - return build_qualified_name (TREE_TYPE (decl), - qualifying_scope, - DECL_NAME (decl), - /*template_p=*/false); - perform_or_defer_access_check (TYPE_BINFO (access_type), decl, decl); -- cgit v1.2.1 From ed772161067b3dbee0dbc2ccf93e20e574db2067 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 18 Nov 2009 09:53:52 +0000 Subject: PR c++/3187 * cgraph.h (struct cgraph_node): Add same_body and same_body_alias fields. (cgraph_same_body_alias, cgraph_remove_same_body_alias): New prototypes. * cgraphunit.c (cgraph_expand_function, cgraph_emit_thunks, cgraph_materialize_all_clones): Handle same_body aliases. * cgraph.c (cgraph_allocate_node): New function. (cgraph_create_node): Use it. (cgraph_node_for_decl, cgraph_node, cgraph_get_node, cgraph_node_for_asm, cgraph_remove_node): Handle same_body aliases. (cgraph_same_body_alias, cgraph_remove_same_body_alias): New functions. * lto-cgraph.c (lto_output_node): Stream out same_body aliases. (input_node): Stream in same_body aliases. * lto-symtab.c (lto_cgraph_replace_node): Clear node pointers for same_body aliases. (lto_symtab_merge_cgraph_nodes_1): Handle same_body aliases. * cp-tree.h (expand_or_defer_fn_1): New prototype. * decl2.c (cp_write_global_declarations): Mark as !DECL_EXTERNAL also all same_body aliases. * semantics.c (expand_or_defer_fn): Move most of the function except registering with cgraph to ... (expand_or_defer_fn_1): ... here. New function. * optimize.c: Include cgraph.h. (maybe_clone_body): If in charge parm is not used and both base and complete clones are created and are not comdat, tell cgraph they have the same body. * Make-lang.in (cp/optimize.o): Depend on $(CGRAPH_H). * g++.dg/abi/mangle26.C: Also match *C2* definition. * g++.dg/abi/mangle27.C: Likewise. * g++.dg/abi/mangle28.C: Likewise. * g++.dg/abi/mangle29.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154284 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index c1df24bfffa..7401593bcc6 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3315,8 +3315,8 @@ emit_associated_thunks (tree fn) /* Generate RTL for FN. */ -void -expand_or_defer_fn (tree fn) +bool +expand_or_defer_fn_1 (tree fn) { /* When the parser calls us after finishing the body of a template function, we don't really want to expand the body. */ @@ -3330,7 +3330,7 @@ expand_or_defer_fn (tree fn) is not a GC root. */ if (!function_depth) ggc_collect (); - return; + return false; } gcc_assert (DECL_SAVED_TREE (fn)); @@ -3343,7 +3343,7 @@ expand_or_defer_fn (tree fn) it out, even though we haven't. */ TREE_ASM_WRITTEN (fn) = 1; DECL_SAVED_TREE (fn) = NULL_TREE; - return; + return false; } /* We make a decision about linkage for these functions at the end @@ -3390,14 +3390,23 @@ expand_or_defer_fn (tree fn) /* There's no reason to do any of the work here if we're only doing semantic analysis; this code just generates RTL. */ if (flag_syntax_only) - return; + return false; - function_depth++; + return true; +} + +void +expand_or_defer_fn (tree fn) +{ + if (expand_or_defer_fn_1 (fn)) + { + function_depth++; - /* Expand or defer, at the whim of the compilation unit manager. */ - cgraph_finalize_function (fn, function_depth > 1); + /* Expand or defer, at the whim of the compilation unit manager. */ + cgraph_finalize_function (fn, function_depth > 1); - function_depth--; + function_depth--; + } } struct nrv_data -- 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/semantics.c | 57 ++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 36 insertions(+), 21 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7401593bcc6..34b5d574d07 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1531,6 +1531,37 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) } } +/* If we are currently parsing a template and we encountered a typedef + TYPEDEF_DECL that is being accessed though CONTEXT, this function + adds the typedef to a list tied to the current template. + At tempate instantiatin time, that list is walked and access check + performed for each typedef. + LOCATION is the location of the usage point of TYPEDEF_DECL. */ + +void +add_typedef_to_current_template_for_access_check (tree typedef_decl, + tree context, + location_t location) +{ + tree template_info = NULL; + tree cs = current_scope (); + + if (!is_typedef_decl (typedef_decl) + || !context + || !CLASS_TYPE_P (context) + || !cs) + return; + + if (CLASS_TYPE_P (cs) || TREE_CODE (cs) == FUNCTION_DECL) + template_info = get_template_info (cs); + + if (template_info + && TI_TEMPLATE (template_info) + && !currently_open_class (context)) + append_type_to_template_for_access_check (cs, typedef_decl, + context, location); +} + /* DECL was the declaration to which a qualified-id resolved. Issue an error message if it is not accessible. If OBJECT_TYPE is non-NULL, we have just seen `x->' or `x.' and OBJECT_TYPE is the @@ -1549,27 +1580,11 @@ check_accessibility_of_qualified_id (tree decl, add it to a list tied to the template. At template instantiation time, that list will be walked and access check performed. */ - if (is_typedef_decl (decl)) - { - /* This the scope through which type_decl is accessed. - It will be useful information later to do access check for - type_decl usage. */ - tree scope = nested_name_specifier - ? nested_name_specifier - : DECL_CONTEXT (decl); - tree templ_info = NULL; - tree cs = current_scope (); - - if (cs && (CLASS_TYPE_P (cs) || TREE_CODE (cs) == FUNCTION_DECL)) - templ_info = get_template_info (cs); - - if (templ_info - && TI_TEMPLATE (templ_info) - && scope - && CLASS_TYPE_P (scope) - && !currently_open_class (scope)) - append_type_to_template_for_access_check (current_scope (), decl, scope); - } + add_typedef_to_current_template_for_access_check (decl, + nested_name_specifier + ? nested_name_specifier + : DECL_CONTEXT (decl), + input_location); /* If we're not checking, return immediately. */ if (deferred_access_no_check) -- cgit v1.2.1 From d9655b3158262e243e4dd8ac0dd6660787b86858 Mon Sep 17 00:00:00 2001 From: dodji Date: Sat, 28 Nov 2009 22:55:52 +0000 Subject: Fix PR c++/36408 gcc/cp/ChangeLog: PR c++/36408 * cp-tree.h (empty_expr_stmt_p): Declare ... * semantics.c (empty_expr_stmt_p): ... this. * pt.c (tsubst_copy_and_build) : Use it. gcc/testsuite/ChangeLog: PR c++/36408 * g++.dg/template/stmtexpr2.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154731 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 34b5d574d07..5253df85ff9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1847,6 +1847,32 @@ stmt_expr_value_expr (tree stmt_expr) return t; } +/* Return TRUE iff EXPR_STMT is an empty list of + expression statements. */ + +bool +empty_expr_stmt_p (tree expr_stmt) +{ + tree body = NULL_TREE; + + if (expr_stmt) + { + if (TREE_CODE (expr_stmt) == EXPR_STMT) + body = EXPR_STMT_EXPR (expr_stmt); + else if (TREE_CODE (expr_stmt) == STATEMENT_LIST) + body = expr_stmt; + } + + if (body) + { + if (TREE_CODE (body) == STATEMENT_LIST) + return tsi_end_p (tsi_start (body)); + else + return empty_expr_stmt_p (body); + } + return false; +} + /* Perform Koenig lookup. FN is the postfix-expression representing the function (or functions) to call; ARGS are the arguments to the call. Returns the functions to be considered by overload -- cgit v1.2.1 From 284545178e8dd05756e5b236cf3b47834b87abf2 Mon Sep 17 00:00:00 2001 From: hubicka Date: Sun, 29 Nov 2009 10:32:08 +0000 Subject: * cgraph.c (same_body_alias_1): Break out of (same_body_alias): ... here; remove comdat check; it is handled in cp already. (cgraph_add_thunk): New. (dump_cgraph_node): Dump aliases and thunks. * cgraph.h (cgraph_thunk_info): New structure. (struct cgraph_node): Add thunk info. (cgraph_add_thunk): New. * cgraphunit.c (cgraph_emit_thunks): Remove. (cgraph_finalize_compilation_unit): Do not call cgraph_emit_thunks. (assemble_thunk): New function. (cgraph_expand_function): Handle thunks. (thunk_adjust): New. (init_lowered_empty_function): New. * optimize.c (maybe_clone_body): Emit thunks associated to alias. * Make-lang.in (method.o): Add dependency on gimple.h. * method.c: Include gimple.h (make_alias_for_thunk): Use same body alias instead of assemble_alias. (use_thunk): Drop codegen; use cgraph_add_thunk; gimplify generic thunks. * semantics.c (expand_or_defer_fn): Emit associated thunks. * cp-objcp-common.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove. * lto-cgraph.c (lto_output_node): Stream thunk info. (input_node): Likewise. * langhooks.h (lang_hooks_for_callgraph): Remove emit_associated_thunks. * langhooks-def.h (LANG_HOOKS_CALLGRAPH_EMIT_ASSOCIATED_THUNKS): Remove. (LANG_HOOKS_CALLGRAPH_INITIALIZER): Update. * i386.c (x86_output_mi_thunk): Make output prettier. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154736 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5253df85ff9..0a1a547d13d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3445,6 +3445,7 @@ expand_or_defer_fn (tree fn) /* Expand or defer, at the whim of the compilation unit manager. */ cgraph_finalize_function (fn, function_depth > 1); + emit_associated_thunks (fn); function_depth--; } -- cgit v1.2.1 From 7a86e244d0df52d6a875d0bad926fb79718174e2 Mon Sep 17 00:00:00 2001 From: dodji Date: Sun, 29 Nov 2009 19:19:06 +0000 Subject: Really fix PR c++/36408 gcc/cp/ChangeLog: PR c++/36408 * semantics.c (empty_expr_stmt_p): Handle void_zero_node and fix bad indentation. * pt.c (tsubst_copy_and_build): Fix typo. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154742 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0a1a547d13d..4a9bee71624 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1855,6 +1855,9 @@ empty_expr_stmt_p (tree expr_stmt) { tree body = NULL_TREE; + if (expr_stmt == void_zero_node) + return true; + if (expr_stmt) { if (TREE_CODE (expr_stmt) == EXPR_STMT) @@ -1863,13 +1866,13 @@ empty_expr_stmt_p (tree expr_stmt) body = expr_stmt; } - if (body) - { - if (TREE_CODE (body) == STATEMENT_LIST) - return tsi_end_p (tsi_start (body)); - else - return empty_expr_stmt_p (body); - } + if (body) + { + if (TREE_CODE (body) == STATEMENT_LIST) + return tsi_end_p (tsi_start (body)); + else + return empty_expr_stmt_p (body); + } return false; } -- cgit v1.2.1 From fd1db3e9212f280d8ad99ed3dbaab9be098107da Mon Sep 17 00:00:00 2001 From: tglek Date: Wed, 2 Dec 2009 01:00:39 +0000 Subject: * parser.c (cp_parser_class_specifier): Set class location to that of IDENTIFIER_NODE instead of '{' when possible.\n* semantics.c (begin_class_definition): Do not overide locations with less precise ones. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154890 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4a9bee71624..aa79b22a33f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2386,9 +2386,6 @@ begin_class_definition (tree t, tree attributes) pushtag (make_anon_name (), t, /*tag_scope=*/ts_current); } - /* Update the location of the decl. */ - DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location; - if (TYPE_BEING_DEFINED (t)) { t = make_class_type (TREE_CODE (t)); -- cgit v1.2.1 From 5c892d4a05f59896e924a64c2db11630ada5c263 Mon Sep 17 00:00:00 2001 From: paolo Date: Wed, 2 Dec 2009 15:49:20 +0000 Subject: 2009-12-02 Paolo Bonzini Shujing Zhao PR c++/29917 * call.c (op_error): Accept a boolean to indicate no match/ambiguous match, instead of a string. Callers adjusted. PR c++/34836 * cp-tree.h (readonly_error_kind): New type. (readonly_error): Adjust prototype with new argument. * typeck2.c (readonly_error): Accept readonly_error_kind as argument and add macro ERROR_FOR_ASSIGNMENT to emit diagnostics. * semantics.c (finish_asm_stmt): Adjust readonly_error call. * typeck.c (cp_build_unary_op, cp_build_modify_expr): Likewise. * decl.c (grokparms, grok_op_properties): Put the diagnostics in full sentences for easy translation and wrap the diagnostics into G_() when needed. (create_array_type_for_decl): Likewise. * pt.c (tsubst): Likewise. * typeck2.c (cp_build_unary_op): Wrap diagnostic into _(). * rtti.c (build_dynamic_cast_1): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154915 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index aa79b22a33f..b3821087ac7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1254,7 +1254,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, effectively const. */ || (CLASS_TYPE_P (TREE_TYPE (operand)) && C_TYPE_FIELDS_READONLY (TREE_TYPE (operand))))) - readonly_error (operand, "assignment (via 'asm' output)"); + readonly_error (operand, REK_ASSIGNMENT_ASM); constraint = TREE_STRING_POINTER (TREE_VALUE (TREE_PURPOSE (t))); oconstraints[i] = constraint; -- cgit v1.2.1 From 0baee55df687806e7cfa915d058855f66d534712 Mon Sep 17 00:00:00 2001 From: tglek Date: Wed, 2 Dec 2009 17:50:41 +0000 Subject: * parser.c (cp_parser_class_specifier): Back out my previous change. * semantics.c (begin_class_definition): Back out my previous change. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@154919 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b3821087ac7..4c3628034b3 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2386,6 +2386,9 @@ begin_class_definition (tree t, tree attributes) pushtag (make_anon_name (), t, /*tag_scope=*/ts_current); } + /* Update the location of the decl. */ + DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location; + if (TYPE_BEING_DEFINED (t)) { t = make_class_type (TREE_CODE (t)); -- cgit v1.2.1 From 7d709aecc260dc570093dbc8c67e05f6fca78249 Mon Sep 17 00:00:00 2001 From: jason Date: Fri, 4 Dec 2009 22:51:12 +0000 Subject: PR c++/42277 * semantics.c (finish_decltype_type): Don't assume that op1 of a COMPONENT_REF is always the field. * g++.dg/cpp0x/decltype20.C: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155002 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4c3628034b3..841efc8fafc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4777,7 +4777,13 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) return error_mark_node; } - if (type_dependent_expression_p (expr)) + if (type_dependent_expression_p (expr) + /* In a template, a COMPONENT_REF has an IDENTIFIER_NODE for op1 even + if it isn't dependent, so that we can check access control at + instantiation time, so defer the decltype as well (PR 42277). */ + || (id_expression_or_member_access_p + && processing_template_decl + && TREE_CODE (expr) == COMPONENT_REF)) { if (id_expression_or_member_access_p) { -- 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/semantics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 841efc8fafc..547e89934c1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1458,7 +1458,7 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) object = cp_build_indirect_ref (lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (TREE_TYPE (object))), - /*errorstring=*/"", + RO_NULL, /*complain=*/tf_warning_or_error); if (current_class_ptr) @@ -5689,7 +5689,7 @@ thisify_lambda_field (tree decl) { tree context = lambda_function (DECL_CONTEXT (decl)); tree object = cp_build_indirect_ref (DECL_ARGUMENTS (context), - /*errorstring*/"", + RO_NULL, tf_warning_or_error); return finish_non_static_data_member (decl, object, /*qualifying_scope*/NULL_TREE); -- cgit v1.2.1 From 0278c8d834b7d73374478e6ac3f2dbef85290fa3 Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 4 Jan 2010 17:53:29 +0000 Subject: PR c++/42567 * semantics.c (describable_type): Remove decltype comment and semantics. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155627 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 547e89934c1..b2f9fd31f56 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4690,10 +4690,8 @@ finish_static_assert (tree condition, tree message, location_t location, } } -/* Returns decltype((EXPR)) for cases where we can drop the decltype and - just return the type even though EXPR is a type-dependent expression. - The ABI specifies which cases this applies to, which is a subset of the - possible cases. */ +/* Returns the type of EXPR for cases where we can determine it even though + EXPR is a type-dependent expression. */ tree describable_type (tree expr) @@ -4717,8 +4715,7 @@ describable_type (tree expr) case PARM_DECL: case RESULT_DECL: case FUNCTION_DECL: - /* Named rvalue reference becomes lvalue. */ - type = build_reference_type (non_reference (TREE_TYPE (expr))); + return TREE_TYPE (expr); break; case NEW_EXPR: -- cgit v1.2.1 From d2b803b8ac1afa0d79d5d60f6d7de0cedfeeb766 Mon Sep 17 00:00:00 2001 From: jason Date: Sat, 16 Jan 2010 15:23:19 +0000 Subject: PR c++/42761 * semantics.c (finish_decltype_type): Within a template, treat unresolved CALL_EXPR as dependent. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@155966 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b2f9fd31f56..fa3ecda205d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4803,6 +4803,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) if (type && !type_uses_auto (type)) return type; + treat_as_dependent: type = cxx_make_type (DECLTYPE_TYPE); DECLTYPE_TYPE_EXPR (type) = expr; DECLTYPE_TYPE_ID_EXPR_OR_MEMBER_ACCESS_P (type) @@ -4930,6 +4931,11 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) && (TREE_CODE (TREE_TYPE (target_type)) == FUNCTION_TYPE || TREE_CODE (TREE_TYPE (target_type)) == METHOD_TYPE)) type = TREE_TYPE (TREE_TYPE (target_type)); + else if (processing_template_decl) + /* Within a template finish_call_expr doesn't resolve + CALL_EXPR_FN, so even though this decltype isn't really + dependent let's defer resolving it. */ + goto treat_as_dependent; else sorry ("unable to determine the declared type of expression %<%E%>", expr); -- cgit v1.2.1 From 3786e1ba45691e6feefd41b13759557108f44443 Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 20 Jan 2010 21:30:28 +0000 Subject: PR c++/41920 * semantics.c (build_lambda_object): Call mark_used on captured variables. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156085 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index fa3ecda205d..1545443c8cf 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5408,6 +5408,9 @@ build_lambda_object (tree lambda_expr) tree field = TREE_PURPOSE (node); tree val = TREE_VALUE (node); + if (DECL_P (val)) + mark_used (val); + /* Mere mortals can't copy arrays with aggregate initialization, so do some magic to make it work here. */ if (TREE_CODE (TREE_TYPE (field)) == ARRAY_TYPE) -- cgit v1.2.1 From 8df5a43d64487d03b55a5799f17a6c465e019062 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 21 Jan 2010 05:49:35 +0000 Subject: * tree.h (TYPE_TRANSPARENT_UNION): Replace with ... (TYPE_TRANSPARENT_AGGR): this, for union and record. * calls.c (initialize argument_information): Handle it. * c-common.c (handle_transparent_union_attribute): Use new name. * c-decl.c (finish_struct): Ditto. * c-typeck.c (type_lists_compatible_p): Ditto. (convert_for_assignment): Use new name and also handle record. * function.c (aggregate_value_p): Handle it. (pass_by_reference): Ditto. (assign_parm_data_types): Ditto. * print-tree.c (print_node): Ditto. * lto-streamer-in.c (unpack_ts_type_value_fields): Ditto. * lto-streamer-out.c (pack_ts_type_value_fields): Ditto. * tree.c (first_field): New fn. gcc/cp/ * mangle.c (write_type): Mangle transparent record as member type. * semantics.c (begin_class_definition): Recognize decimal classes and set TYPE_TRANSPARENT_AGGR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156106 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1545443c8cf..d9ba591b3f5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2368,6 +2368,18 @@ begin_class_definition (tree t, tree attributes) error ("definition of %q#T inside template parameter list", t); return error_mark_node; } + + /* According to the C++ ABI, decimal classes defined in ISO/IEC TR 24733 + are passed the same as decimal scalar types. */ + if (TREE_CODE (t) == RECORD_TYPE) + { + const char *n = type_as_string (t, TFF_CLASS_KEY_OR_ENUM); + if ((strcmp (n, "class std::decimal::decimal32") == 0) + || (strcmp (n, "class std::decimal::decimal64") == 0) + || (strcmp (n, "class std::decimal::decimal128") == 0)) + TYPE_TRANSPARENT_AGGR (t) = 1; + } + /* A non-implicit typename comes from code like: template struct A { -- cgit v1.2.1 From f71a31892af0c9190ab534d5a054822f3e4a19d0 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 28 Jan 2010 22:52:36 +0000 Subject: PR c++/42880 * semantics.c (begin_class_definition): Don't use type_as_string. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156336 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d9ba591b3f5..441081c3d96 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2371,13 +2371,20 @@ begin_class_definition (tree t, tree attributes) /* According to the C++ ABI, decimal classes defined in ISO/IEC TR 24733 are passed the same as decimal scalar types. */ - if (TREE_CODE (t) == RECORD_TYPE) + if (TREE_CODE (t) == RECORD_TYPE + && !processing_template_decl) { - const char *n = type_as_string (t, TFF_CLASS_KEY_OR_ENUM); - if ((strcmp (n, "class std::decimal::decimal32") == 0) - || (strcmp (n, "class std::decimal::decimal64") == 0) - || (strcmp (n, "class std::decimal::decimal128") == 0)) - TYPE_TRANSPARENT_AGGR (t) = 1; + tree ns = TYPE_CONTEXT (t); + if (ns && TREE_CODE (ns) == NAMESPACE_DECL + && DECL_CONTEXT (ns) == std_node + && !strcmp (IDENTIFIER_POINTER (DECL_NAME (ns)), "decimal")) + { + const char *n = TYPE_NAME_STRING (t); + if ((strcmp (n, "decimal32") == 0) + || (strcmp (n, "decimal64") == 0) + || (strcmp (n, "decimal128") == 0)) + TYPE_TRANSPARENT_AGGR (t) = 1; + } } /* A non-implicit typename comes from code like: -- cgit v1.2.1 From 93529b28fa5b6fca2c417f9ad59d6af66a426baa Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 9 Feb 2010 20:05:51 +0000 Subject: PR c++/42370 * decl2.c (change_return_type): New fn. * semantics.c (apply_lambda_return_type): Use it. * cp-tree.h: Declare it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156634 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 441081c3d96..39085be19d4 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5584,7 +5584,7 @@ apply_lambda_return_type (tree lambda, tree return_type) /* TREE_TYPE (FUNCTION_DECL) == METHOD_TYPE TREE_TYPE (METHOD_TYPE) == return-type */ - TREE_TYPE (TREE_TYPE (fco)) = return_type; + TREE_TYPE (fco) = change_return_type (return_type, TREE_TYPE (fco)); result = DECL_RESULT (fco); if (result == NULL_TREE) -- cgit v1.2.1 From 1e1f8b7f57588db63a2b9922fe5a74e11646544e Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 10 Feb 2010 21:48:25 +0000 Subject: PR c++/43016 * semantics.c (maybe_add_lambda_conv_op): Set DECL_INTERFACE_KNOWN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156671 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 39085be19d4..f8ced6fd549 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5871,6 +5871,8 @@ maybe_add_lambda_conv_op (tree type) DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; DECL_STATIC_FUNCTION_P (fn) = 1; + if (nested) + DECL_INTERFACE_KNOWN (fn) = 1; add_method (type, fn, NULL_TREE); -- cgit v1.2.1 From b29dbfa555e2a017a01be3bb626fa805725b77ae Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 10 Feb 2010 22:45:07 +0000 Subject: PR c++/41896 * semantics.c (outer_lambda_capture_p): Use current_function_decl instead of current_class_type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156673 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f8ced6fd549..796b789199b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2714,8 +2714,9 @@ outer_lambda_capture_p (tree decl) { return (TREE_CODE (decl) == FIELD_DECL && LAMBDA_TYPE_P (DECL_CONTEXT (decl)) - && (!current_class_type - || !DERIVED_FROM_P (DECL_CONTEXT (decl), current_class_type))); + /* Using current_class_type here causes problems with uses in a + nested lambda-introducer; see 41896. */ + && DECL_CONTEXT (current_function_decl) != DECL_CONTEXT (decl)); } /* ID_EXPRESSION is a representation of parsed, but unprocessed, -- cgit v1.2.1 From 86b604cfd0917da33b295d4c4d8892c7619994b7 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 11 Feb 2010 02:12:53 +0000 Subject: PR c++/41896 * semantics.c (outer_lambda_capture_p): Revert. (add_capture): Only finish_member_declaration if we're in the lambda class. (register_capture_members): New. * cp-tree.h: Declare it. * parser.c (cp_parser_lambda_expression): Call it. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156678 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 796b789199b..985e2c0f464 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2714,9 +2714,8 @@ outer_lambda_capture_p (tree decl) { return (TREE_CODE (decl) == FIELD_DECL && LAMBDA_TYPE_P (DECL_CONTEXT (decl)) - /* Using current_class_type here causes problems with uses in a - nested lambda-introducer; see 41896. */ - && DECL_CONTEXT (current_function_decl) != DECL_CONTEXT (decl)); + && (!current_class_type + || !DERIVED_FROM_P (DECL_CONTEXT (decl), current_class_type))); } /* ID_EXPRESSION is a representation of parsed, but unprocessed, @@ -5690,8 +5689,9 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, always visible. */ DECL_NORMAL_CAPTURE_P (member) = true; - /* Add it to the appropriate closure class. */ - finish_member_declaration (member); + /* Add it to the appropriate closure class if we've started it. */ + if (current_class_type && current_class_type == TREE_TYPE (lambda)) + finish_member_declaration (member); LAMBDA_EXPR_CAPTURE_LIST (lambda) = tree_cons (member, initializer, LAMBDA_EXPR_CAPTURE_LIST (lambda)); @@ -5706,6 +5706,18 @@ add_capture (tree lambda, tree id, tree initializer, bool by_reference_p, return member; } +/* Register all the capture members on the list CAPTURES, which is the + LAMBDA_EXPR_CAPTURE_LIST for the lambda after the introducer. */ + +void register_capture_members (tree captures) +{ + if (captures) + { + register_capture_members (TREE_CHAIN (captures)); + finish_member_declaration (TREE_PURPOSE (captures)); + } +} + /* Given a FIELD_DECL decl belonging to a closure type, return a COMPONENT_REF of it relative to the 'this' parameter of the op() for that type. */ -- cgit v1.2.1 From 98c209e2fcee1b50470884aa9a0d65ba072b7d02 Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 14 Feb 2010 15:17:30 +0000 Subject: PR c++/41997 * semantics.c (finish_compound_literal): Use cp_apply_type_quals_to_decl when creating a static variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156760 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 985e2c0f464..90a76d9391c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2257,6 +2257,7 @@ finish_compound_literal (tree type, tree compound_literal) tree decl = create_temporary_var (type); DECL_INITIAL (decl) = compound_literal; TREE_STATIC (decl) = 1; + cp_apply_type_quals_to_decl (cp_type_quals (type), decl); decl = pushdecl_top_level (decl); DECL_NAME (decl) = make_anon_name (); SET_DECL_ASSEMBLER_NAME (decl, DECL_NAME (decl)); -- cgit v1.2.1 From 1bd1e44fa057d27d0cd51e2fdadedda79dc86868 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 18 Feb 2010 16:27:07 +0000 Subject: PR c++/43109 * semantics.c (begin_class_definition): Don't crash on unnamed ns. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156864 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 90a76d9391c..24390d98c0c 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2378,6 +2378,7 @@ begin_class_definition (tree t, tree attributes) tree ns = TYPE_CONTEXT (t); if (ns && TREE_CODE (ns) == NAMESPACE_DECL && DECL_CONTEXT (ns) == std_node + && DECL_NAME (ns) && !strcmp (IDENTIFIER_POINTER (DECL_NAME (ns)), "decimal")) { const char *n = TYPE_NAME_STRING (t); -- cgit v1.2.1 From b0fd6624152bd01fe36eef8467fa8fc4f0fc716c Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 18 Feb 2010 19:20:21 +0000 Subject: PR c++/43070 * semantics.c (finish_goto_stmt): Don't call decay_conversion. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@156872 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 24390d98c0c..5d8b767b272 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -546,10 +546,8 @@ finish_goto_stmt (tree destination) TREE_USED (destination) = 1; else { - /* The DESTINATION is being used as an rvalue. */ if (!processing_template_decl) { - destination = decay_conversion (destination); destination = cp_convert (ptr_type_node, destination); if (error_operand_p (destination)) return NULL_TREE; -- cgit v1.2.1 From 43936711fc72dbea643334f250f055f85f398fa2 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 23 Mar 2010 22:29:53 +0000 Subject: Make lambda conversion op and op() non-static. * semantics.c (maybe_add_lambda_conv_op): Make non-static. Also add the thunk function returned by the conversion op. Mark the conversion deleted if the op() is variadic. * decl2.c (mark_used): Give helpful message about deleted conversion. * parser.c (cp_parser_lambda_declarator_opt): Don't make op() static. * semantics.c (finish_this_expr): Adjust. * mangle.c (write_closure_type_name): Adjust. * decl.c (grok_op_properties): Don't allow it. * call.c (build_user_type_conversion_1): No static conversion ops. (build_op_call): Or op(). * decl2.c (change_return_type): Fix 'this' quals. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157681 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 108 ++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 95 insertions(+), 13 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5d8b767b272..1678e5078e8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2104,13 +2104,17 @@ finish_this_expr (void) { tree result; - /* In a lambda expression, 'this' refers to the captured 'this'. */ - if (current_function_decl - && LAMBDA_FUNCTION_P (current_function_decl)) - result = (lambda_expr_this_capture - (CLASSTYPE_LAMBDA_EXPR (current_class_type))); - else if (current_class_ptr) - result = current_class_ptr; + if (current_class_ptr) + { + tree type = TREE_TYPE (current_class_ref); + + /* In a lambda expression, 'this' refers to the captured 'this'. */ + if (LAMBDA_TYPE_P (type)) + result = lambda_expr_this_capture (CLASSTYPE_LAMBDA_EXPR (type)); + else + result = current_class_ptr; + + } else if (current_function_decl && DECL_STATIC_FUNCTION_P (current_function_decl)) { @@ -5861,14 +5865,22 @@ maybe_add_lambda_conv_op (tree type) bool nested = (current_function_decl != NULL_TREE); tree callop = lambda_function (type); tree rettype, name, fntype, fn, body, compound_stmt; + tree thistype, stattype, statfn, convfn, call, arg; + VEC (tree, gc) *argvec; - if (!DECL_STATIC_FUNCTION_P (callop)) + if (LAMBDA_EXPR_CAPTURE_LIST (CLASSTYPE_LAMBDA_EXPR (type)) != NULL_TREE) return; - rettype = build_pointer_type (TREE_TYPE (callop)); + stattype = build_function_type (TREE_TYPE (TREE_TYPE (callop)), + FUNCTION_ARG_CHAIN (callop)); + + /* First build up the conversion op. */ + + rettype = build_pointer_type (stattype); name = mangle_conv_op_name_for_type (rettype); - fntype = build_function_type (rettype, void_list_node); - fn = build_lang_decl (FUNCTION_DECL, name, fntype); + thistype = cp_build_qualified_type (type, TYPE_QUAL_CONST); + fntype = build_method_type_directly (thistype, rettype, void_list_node); + fn = convfn = build_lang_decl (FUNCTION_DECL, name, fntype); DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn @@ -5883,7 +5895,39 @@ maybe_add_lambda_conv_op (tree type) DECL_ARTIFICIAL (fn) = 1; DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; + DECL_ARGUMENTS (fn) = build_this_parm (fntype, TYPE_QUAL_CONST); + if (nested) + DECL_INTERFACE_KNOWN (fn) = 1; + + add_method (type, fn, NULL_TREE); + + /* Generic thunk code fails for varargs; we'll complain in mark_used if + the conversion op is used. */ + if (varargs_function_p (callop)) + { + DECL_DELETED_FN (fn) = 1; + return; + } + + /* Now build up the thunk to be returned. */ + + name = get_identifier ("_FUN"); + fn = statfn = build_lang_decl (FUNCTION_DECL, name, stattype); + DECL_SOURCE_LOCATION (fn) = DECL_SOURCE_LOCATION (callop); + if (TARGET_PTRMEMFUNC_VBIT_LOCATION == ptrmemfunc_vbit_in_pfn + && DECL_ALIGN (fn) < 2 * BITS_PER_UNIT) + DECL_ALIGN (fn) = 2 * BITS_PER_UNIT; + grokclassfn (type, fn, NO_SPECIAL); + set_linkage_according_to_type (type, fn); + rest_of_decl_compilation (fn, toplevel_bindings_p (), at_eof); + DECL_IN_AGGR_P (fn) = 1; + DECL_ARTIFICIAL (fn) = 1; + DECL_NOT_REALLY_EXTERN (fn) = 1; + DECL_DECLARED_INLINE_P (fn) = 1; DECL_STATIC_FUNCTION_P (fn) = 1; + DECL_ARGUMENTS (fn) = copy_list (TREE_CHAIN (DECL_ARGUMENTS (callop))); + for (arg = DECL_ARGUMENTS (fn); arg; arg = TREE_CHAIN (arg)) + DECL_CONTEXT (arg) = fn; if (nested) DECL_INTERFACE_KNOWN (fn) = 1; @@ -5891,17 +5935,55 @@ maybe_add_lambda_conv_op (tree type) if (nested) push_function_context (); - start_preparsed_function (fn, NULL_TREE, + + /* Generate the body of the thunk. */ + + start_preparsed_function (statfn, NULL_TREE, + SF_PRE_PARSED | SF_INCLASS_INLINE); + if (DECL_ONE_ONLY (statfn)) + { + /* Put the thunk in the same comdat group as the call op. */ + struct cgraph_node *callop_node, *thunk_node; + DECL_COMDAT_GROUP (statfn) = DECL_COMDAT_GROUP (callop); + callop_node = cgraph_node (callop); + thunk_node = cgraph_node (statfn); + gcc_assert (callop_node->same_comdat_group == NULL); + gcc_assert (thunk_node->same_comdat_group == NULL); + callop_node->same_comdat_group = thunk_node; + thunk_node->same_comdat_group = callop_node; + } + body = begin_function_body (); + compound_stmt = begin_compound_stmt (0); + + arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), void_zero_node); + argvec = make_tree_vector (); + VEC_quick_push (tree, argvec, arg); + for (arg = DECL_ARGUMENTS (statfn); arg; arg = TREE_CHAIN (arg)) + VEC_safe_push (tree, gc, argvec, arg); + call = build_cxx_call (callop, VEC_length (tree, argvec), + VEC_address (tree, argvec)); + CALL_FROM_THUNK_P (call) = 1; + finish_return_stmt (call); + + finish_compound_stmt (compound_stmt); + finish_function_body (body); + + expand_or_defer_fn (finish_function (2)); + + /* Generate the body of the conversion op. */ + + start_preparsed_function (convfn, NULL_TREE, SF_PRE_PARSED | SF_INCLASS_INLINE); body = begin_function_body (); compound_stmt = begin_compound_stmt (0); - finish_return_stmt (decay_conversion (callop)); + finish_return_stmt (decay_conversion (statfn)); finish_compound_stmt (compound_stmt); finish_function_body (body); expand_or_defer_fn (finish_function (2)); + if (nested) pop_function_context (); } -- cgit v1.2.1 From 5448d1376cd524c091e62d398d32426cf99397c7 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 1 Apr 2010 18:48:34 +0000 Subject: * semantics.c (maybe_add_lambda_conv_op): Use null_pointer_node instead of void_zero_node. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@157926 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1678e5078e8..1c47ded84d0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5955,7 +5955,8 @@ maybe_add_lambda_conv_op (tree type) body = begin_function_body (); compound_stmt = begin_compound_stmt (0); - arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), void_zero_node); + arg = build1 (NOP_EXPR, TREE_TYPE (DECL_ARGUMENTS (callop)), + null_pointer_node); argvec = make_tree_vector (); VEC_quick_push (tree, argvec, arg); for (arg = DECL_ARGUMENTS (statfn); arg; arg = TREE_CHAIN (arg)) -- cgit v1.2.1 From aad3e1b3626af198335f363a90c6ab79e3158f9a Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 6 Apr 2010 21:13:07 +0000 Subject: * parser.c (cp_parser_class_specifier): Set class location to that of IDENTIFIER_NODE instead of '{' when possible. * semantics.c (begin_class_definition): Do not overide locations with less precise ones. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158030 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 1c47ded84d0..5cf4b693f26 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2409,9 +2409,6 @@ begin_class_definition (tree t, tree attributes) pushtag (make_anon_name (), t, /*tag_scope=*/ts_current); } - /* Update the location of the decl. */ - DECL_SOURCE_LOCATION (TYPE_NAME (t)) = input_location; - if (TYPE_BEING_DEFINED (t)) { t = make_class_type (TREE_CODE (t)); -- cgit v1.2.1 From 8b25863e71a1ac1600d931290fb3d36c7c30671a Mon Sep 17 00:00:00 2001 From: jason Date: Wed, 7 Apr 2010 15:55:20 +0000 Subject: PR c++/11094, DR 408 * cp-tree.h (VAR_HAD_UNKNOWN_BOUND, SET_VAR_HAD_UNKNOWN_BOUND): New. * decl2.c (finish_static_data_member_decl): Set it. * decl.c (duplicate_decls): Propagate it. * pt.c (tsubst_decl): Don't substitute the domain of an array VAR_DECL if it's set. (regenerate_decl_from_template): Substitute it here. (type_dependent_expression_p): Return true if it's set. * semantics.c (finish_decltype_type): Instantiate such a variable. * typeck.c (cxx_sizeof_expr): Likewise. (strip_array_domain): New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158075 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 5cf4b693f26..d425402e3ce 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4836,6 +4836,14 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) /* The type denoted by decltype(e) is defined as follows: */ expr = resolve_nondeduced_context (expr); + + /* To get the size of a static data member declared as an array of + unknown bound, we need to instantiate it. */ + if (TREE_CODE (expr) == VAR_DECL + && VAR_HAD_UNKNOWN_BOUND (expr) + && DECL_TEMPLATE_INSTANTIATION (expr)) + instantiate_decl (expr, /*defer_ok*/true, /*expl_inst_mem*/false); + if (id_expression_or_member_access_p) { /* If e is an id-expression or a class member access (5.2.5 -- cgit v1.2.1 From 0ef106fc6f745b834e9a3f93075736d6f1eeb498 Mon Sep 17 00:00:00 2001 From: rguenth Date: Mon, 12 Apr 2010 09:52:50 +0000 Subject: 2010-04-12 Richard Guenther PR c++/43611 * semantics.c (expand_or_defer_fn_1): Do not keep extern template inline functions. * g++.dg/torture/pr43611.C: New testcase. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158218 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d425402e3ce..66d152de8b8 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3446,7 +3446,9 @@ expand_or_defer_fn_1 (tree fn) this function as needed so that finish_file will make sure to output it later. Similarly, all dllexport'd functions must be emitted; there may be callers in other DLLs. */ - if ((flag_keep_inline_functions && DECL_DECLARED_INLINE_P (fn)) + if ((flag_keep_inline_functions + && DECL_DECLARED_INLINE_P (fn) + && !DECL_REALLY_EXTERN (fn)) || lookup_attribute ("dllexport", DECL_ATTRIBUTES (fn))) mark_needed (fn); } -- cgit v1.2.1 From 2a6e66d9e381d340eed24302b919ffdbc74270ac Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 12 Apr 2010 19:58:49 +0000 Subject: PR c++/43641 * semantics.c (maybe_add_lambda_conv_op): Use build_call_a and tweak return value directly. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158241 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 66d152de8b8..ea01eb31378 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5968,9 +5968,12 @@ maybe_add_lambda_conv_op (tree type) VEC_quick_push (tree, argvec, arg); for (arg = DECL_ARGUMENTS (statfn); arg; arg = TREE_CHAIN (arg)) VEC_safe_push (tree, gc, argvec, arg); - call = build_cxx_call (callop, VEC_length (tree, argvec), - VEC_address (tree, argvec)); + call = build_call_a (callop, VEC_length (tree, argvec), + VEC_address (tree, argvec)); CALL_FROM_THUNK_P (call) = 1; + if (MAYBE_CLASS_TYPE_P (TREE_TYPE (call))) + call = build_cplus_new (TREE_TYPE (call), call); + call = convert_from_reference (call); finish_return_stmt (call); finish_compound_stmt (compound_stmt); -- cgit v1.2.1 From cca512c26b34cfa01922fb46fa70c0d17402477b Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:21:35 +0000 Subject: PR c++/43875 * semantics.c (lambda_return_type): Complain about braced-init-list. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158805 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index ea01eb31378..05c516870a9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5521,6 +5521,11 @@ tree lambda_return_type (tree expr) { tree type; + if (BRACE_ENCLOSED_INITIALIZER_P (expr)) + { + warning (0, "cannot deduce lambda return type from a braced-init-list"); + return void_type_node; + } if (type_dependent_expression_p (expr)) { type = cxx_make_type (DECLTYPE_TYPE); -- cgit v1.2.1 From 70b178b2d846a0bc8231fcdad3b5b9e175f5e676 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:25:29 +0000 Subject: * semantics.c (baselink_for_fns): Correct BASELINK_BINFO. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158806 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 05c516870a9..6bf33c7f5f2 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2692,7 +2692,8 @@ baselink_for_fns (tree fns) if (!cl) cl = DECL_CONTEXT (fn); cl = TYPE_BINFO (cl); - return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE); + return build_baselink (TYPE_BINFO (DECL_CONTEXT (fn)), cl, fns, + /*optype=*/NULL_TREE); } /* Returns true iff DECL is an automatic variable from a function outside -- 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/semantics.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 6bf33c7f5f2..7c039593608 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5869,6 +5869,32 @@ lambda_expr_this_capture (tree lambda) return result; } +/* Returns the method basetype of the innermost non-lambda function, or + NULL_TREE if none. */ + +tree +nonlambda_method_basetype (void) +{ + tree fn, type; + if (!current_class_ref) + return NULL_TREE; + + type = current_class_type; + if (!LAMBDA_TYPE_P (type)) + return type; + + /* Find the nearest enclosing non-lambda function. */ + fn = TYPE_NAME (type); + do + fn = decl_function_context (fn); + while (fn && LAMBDA_FUNCTION_P (fn)); + + if (!fn || !DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)) + return NULL_TREE; + + return TYPE_METHOD_BASETYPE (TREE_TYPE (fn)); +} + /* If the closure TYPE has a static op(), also add a conversion to function pointer. */ -- cgit v1.2.1 From f765949633861a91dbe3356ad50c8a649effc856 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:27:04 +0000 Subject: * semantics.c (finish_qualified_id_expr): Use maybe_dummy_object rather than checking current_class_ref directly. (finish_call_expr): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158808 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7c039593608..7bcd75690fc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1690,6 +1690,7 @@ finish_qualified_id_expr (tree qualifying_class, else if (BASELINK_P (expr) && !processing_template_decl) { tree fns; + tree ob; /* See if any of the functions are non-static members. */ fns = BASELINK_FUNCTIONS (expr); @@ -1697,10 +1698,10 @@ finish_qualified_id_expr (tree qualifying_class, fns = TREE_OPERAND (fns, 0); /* If so, the expression may be relative to 'this'. */ if (!shared_member_p (fns) - && current_class_ref - && DERIVED_FROM_P (qualifying_class, TREE_TYPE (current_class_ref))) + && (ob = maybe_dummy_object (qualifying_class, NULL), + !is_dummy_object (ob))) expr = (build_class_member_access_expr - (maybe_dummy_object (qualifying_class, NULL), + (ob, expr, BASELINK_ACCESS_BINFO (expr), /*preserve_reference=*/false, @@ -2002,31 +2003,18 @@ finish_call_expr (tree fn, VEC(tree,gc) **args, bool disallow_virtual, . operator.... [Otherwise] a contrived object of type T becomes the implied object argument. - This paragraph is unclear about this situation: + In this situation: struct A { void f(); }; struct B : public A {}; struct C : public A { void g() { B::f(); }}; - In particular, for `B::f', this paragraph does not make clear - whether "the class of that member function" refers to `A' or - to `B'. We believe it refers to `B'. */ - if (current_class_type - && DERIVED_FROM_P (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), - current_class_type) - && current_class_ref) - object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), - NULL); - else - { - tree representative_fn; + "the class of that member function" refers to `A'. But 11.2 + [class.access.base] says that we need to convert 'this' to B* as + part of the access, so we pass 'B' to maybe_dummy_object. */ - representative_fn = BASELINK_FUNCTIONS (fn); - if (TREE_CODE (representative_fn) == TEMPLATE_ID_EXPR) - representative_fn = TREE_OPERAND (representative_fn, 0); - representative_fn = get_first_fn (representative_fn); - object = build_dummy_object (DECL_CONTEXT (representative_fn)); - } + object = maybe_dummy_object (BINFO_TYPE (BASELINK_ACCESS_BINFO (fn)), + NULL); if (processing_template_decl) { -- cgit v1.2.1 From 70269a57a8e4b7428eff50077451d4a9648afe70 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 27 Apr 2010 21:30:56 +0000 Subject: * semantics.c (finish_non_static_data_member): Call maybe_dummy_object whenever object is NULL_TREE. Don't do 'this' capture here. (finish_qualified_id_expr): Pass NULL_TREE. (finish_id_expression): Likewise. (lambda_expr_this_capture): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@158809 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 7bcd75690fc..73fed153801 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1424,17 +1424,18 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) { gcc_assert (TREE_CODE (decl) == FIELD_DECL); - if (!object && cp_unevaluated_operand != 0) + if (!object) { - /* DR 613: Can use non-static data members without an associated - object in sizeof/decltype/alignof. */ tree scope = qualifying_scope; if (scope == NULL_TREE) scope = context_for_name_lookup (decl); object = maybe_dummy_object (scope, NULL); } - if (!object) + /* DR 613: Can use non-static data members without an associated + object in sizeof/decltype/alignof. */ + if (is_dummy_object (object) && cp_unevaluated_operand == 0 + && (!processing_template_decl || !current_class_ref)) { if (current_function_decl && DECL_STATIC_FUNCTION_P (current_function_decl)) @@ -1446,19 +1447,6 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) return error_mark_node; } - /* If decl is a non-capture field and object has a lambda type, - then we have a reference to a member of 'this' from a - lambda inside a non-static member function, and we must get to decl - through the 'this' capture. If decl is not a member of that object, - either, then its access will still fail later. */ - if (LAMBDA_TYPE_P (TREE_TYPE (object)) - && !LAMBDA_TYPE_P (DECL_CONTEXT (decl))) - object = cp_build_indirect_ref (lambda_expr_this_capture - (CLASSTYPE_LAMBDA_EXPR - (TREE_TYPE (object))), - RO_NULL, - /*complain=*/tf_warning_or_error); - if (current_class_ptr) TREE_USED (current_class_ptr) = 1; if (processing_template_decl && !qualifying_scope) @@ -1494,21 +1482,6 @@ finish_non_static_data_member (tree decl, tree object, tree qualifying_scope) else { tree access_type = TREE_TYPE (object); - tree lookup_context = context_for_name_lookup (decl); - - while (!DERIVED_FROM_P (lookup_context, access_type)) - { - access_type = TYPE_CONTEXT (access_type); - while (access_type && DECL_P (access_type)) - access_type = DECL_CONTEXT (access_type); - - if (!access_type) - { - error ("object missing in reference to %q+D", decl); - error ("from this location"); - return error_mark_node; - } - } perform_or_defer_access_check (TYPE_BINFO (access_type), decl, decl); @@ -1683,7 +1656,7 @@ finish_qualified_id_expr (tree qualifying_class, else if (TREE_CODE (expr) == FIELD_DECL) { push_deferring_access_checks (dk_no_check); - expr = finish_non_static_data_member (expr, current_class_ref, + expr = finish_non_static_data_member (expr, NULL_TREE, qualifying_class); pop_deferring_access_checks (); } @@ -3062,7 +3035,7 @@ finish_id_expression (tree id_expression, already. Turn off checking to avoid duplicate errors. */ push_deferring_access_checks (dk_no_check); decl = finish_non_static_data_member - (decl, current_class_ref, + (decl, NULL_TREE, /*qualifying_scope=*/NULL_TREE); pop_deferring_access_checks (); return decl; @@ -3143,7 +3116,7 @@ finish_id_expression (tree id_expression, Access checking has been performed during name lookup already. Turn off checking to avoid duplicate errors. */ push_deferring_access_checks (dk_no_check); - decl = finish_non_static_data_member (decl, current_class_ref, + decl = finish_non_static_data_member (decl, NULL_TREE, /*qualifying_scope=*/NULL_TREE); pop_deferring_access_checks (); } @@ -5844,7 +5817,7 @@ lambda_expr_this_capture (tree lambda) gcc_assert (TYPE_MAIN_VARIANT (TREE_TYPE (current_class_ref)) == TREE_TYPE (lambda)); result = finish_non_static_data_member (this_capture, - current_class_ref, + NULL_TREE, /*qualifying_scope=*/NULL_TREE); /* If 'this' is captured, each use of 'this' is transformed into an -- 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/semantics.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 73fed153801..d4ce01496ee 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1662,15 +1662,11 @@ finish_qualified_id_expr (tree qualifying_class, } else if (BASELINK_P (expr) && !processing_template_decl) { - tree fns; tree ob; /* See if any of the functions are non-static members. */ - fns = BASELINK_FUNCTIONS (expr); - if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) - fns = TREE_OPERAND (fns, 0); /* If so, the expression may be relative to 'this'. */ - if (!shared_member_p (fns) + if (!shared_member_p (expr) && (ob = maybe_dummy_object (qualifying_class, NULL), !is_dummy_object (ob))) expr = (build_class_member_access_expr @@ -3124,10 +3120,7 @@ finish_id_expression (tree id_expression, { tree first_fn; - first_fn = decl; - if (TREE_CODE (first_fn) == TEMPLATE_ID_EXPR) - first_fn = TREE_OPERAND (first_fn, 0); - first_fn = get_first_fn (first_fn); + first_fn = get_first_fn (decl); if (TREE_CODE (first_fn) == TEMPLATE_DECL) first_fn = DECL_TEMPLATE_RESULT (first_fn); -- 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/semantics.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index d4ce01496ee..f47a758191b 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -610,6 +610,13 @@ finish_expr_stmt (tree expr) { if (warn_sequence_point) verify_sequence_points (expr); + if (TREE_CODE (expr) != MODIFY_EXPR) + /* Expr is not being 'used' here, otherwise we whould have + called mark_{rl}value_use use here, which would have in turn + called mark_exp_read. Rather, we call mark_exp_read directly + to avoid some warnings when + -Wunused-but-set-{variable,parameter} is in effect. */ + mark_exp_read (expr); expr = convert_to_void (expr, "statement", tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) @@ -1238,6 +1245,8 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, otherwise we'll get an error. Gross, but ... */ STRIP_NOPS (operand); + operand = mark_lvalue_use (operand); + if (!lvalue_or_else (operand, lv_asm, tf_warning_or_error)) operand = error_mark_node; @@ -3182,6 +3191,8 @@ finish_typeof (tree expr) return type; } + expr = mark_type_use (expr); + type = unlowered_expr_type (expr); if (!type || type == unknown_type_node) @@ -4859,6 +4870,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) case PARM_DECL: case RESULT_DECL: case TEMPLATE_PARM_INDEX: + expr = mark_type_use (expr); type = TREE_TYPE (expr); break; @@ -4867,6 +4879,7 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) break; case COMPONENT_REF: + mark_type_use (expr); type = is_bitfield_expr_with_lowered_type (expr); if (!type) type = TREE_TYPE (TREE_OPERAND (expr, 1)); -- cgit v1.2.1 From 5f52d2e22c7355508a5a06812bf150125cbe5e89 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 6 May 2010 19:46:14 +0000 Subject: gcc: * gimplify.c (gimplify_expr): Set GS_ALL_DONE when appropriate. Don't change GS_OK to GS_ALL_DONE. Make sure that all cases set ret appropriately. (gimplify_compound_lval): Return GS_ALL_DONE as appropriate. gcc/cp: * semantics.c (simplify_aggr_init_expr): Use INIT_EXPR. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159125 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index f47a758191b..0847403c227 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3280,7 +3280,7 @@ simplify_aggr_init_expr (tree *tp) expand_call{,_inline}. */ cxx_mark_addressable (slot); CALL_EXPR_RETURN_SLOT_OPT (call_expr) = true; - call_expr = build2 (MODIFY_EXPR, TREE_TYPE (call_expr), slot, call_expr); + call_expr = build2 (INIT_EXPR, TREE_TYPE (call_expr), slot, call_expr); } else if (style == pcc) { -- cgit v1.2.1 From f302e37ac84681c0c057f25d0137ce23e2e6e50b Mon Sep 17 00:00:00 2001 From: jason Date: Mon, 10 May 2010 21:20:47 +0000 Subject: PR c++/44017 * semantics.c (baselink_for_fns): Revert earlier change. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159246 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 0847403c227..cbbcf96e2cc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2658,8 +2658,7 @@ baselink_for_fns (tree fns) if (!cl) cl = DECL_CONTEXT (fn); cl = TYPE_BINFO (cl); - return build_baselink (TYPE_BINFO (DECL_CONTEXT (fn)), cl, fns, - /*optype=*/NULL_TREE); + return build_baselink (cl, cl, fns, /*optype=*/NULL_TREE); } /* Returns true iff DECL is an automatic variable from a function outside -- cgit v1.2.1 From b2af2a9379ee112dba523c35b735c160547845a2 Mon Sep 17 00:00:00 2001 From: jakub Date: Tue, 11 May 2010 18:12:28 +0000 Subject: PR c++/44062 * c-parser.c (c_parser_expression): Mark LHS of a comma expression as read if it is a decl, handled component or COMPOUND_EXPR with that on the RHS. * c-typeck.c (c_process_expr_stmt): Mark RHS of COMPOUND_EXPR if it is a decl or handled component. * semantics.c (finish_expr_stmt): Don't call mark_exp_read here... * cvt.c (convert_to_void): ... but here. If expr is a COMPOUND_EXPR, look at its second operand. * c-c++-common/Wunused-var-7.c: New test. * g++.dg/warn/Wunused-var-9.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159286 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index cbbcf96e2cc..135de46abe7 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4,7 +4,7 @@ and during the instantiation of template functions. Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009 Free Software Foundation, Inc. + 2008, 2009, 2010 Free Software Foundation, Inc. Written by Mark Mitchell (mmitchell@usa.net) based on code found formerly in parse.y and pt.c. @@ -610,13 +610,6 @@ finish_expr_stmt (tree expr) { if (warn_sequence_point) verify_sequence_points (expr); - if (TREE_CODE (expr) != MODIFY_EXPR) - /* Expr is not being 'used' here, otherwise we whould have - called mark_{rl}value_use use here, which would have in turn - called mark_exp_read. Rather, we call mark_exp_read directly - to avoid some warnings when - -Wunused-but-set-{variable,parameter} is in effect. */ - mark_exp_read (expr); expr = convert_to_void (expr, "statement", tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) -- cgit v1.2.1 From 4fdaf896dddd224958053b670bc9be78f102e789 Mon Sep 17 00:00:00 2001 From: jason Date: Thu, 13 May 2010 05:04:14 +0000 Subject: * cp-tree.h (UNKNOWN_TYPE): Remove. * decl.c (cxx_init_decl_processing): Use LANG_TYPE instead. * error.c (dumy_type, dump_type_prefix, dump_type_suffix): Likewise. * typeck2.c (cxx_incomplete_type_diagnostic): Likewise. * class.c (instantiate_type): Check unknown_type_node rather than UNKNOWN_TYPE. * name-lookup.c (maybe_push_decl): Likewise. * rtti.c (get_tinfo_decl_dynamic): Likewise. (get_typeid): Likewise. * semantics.c (finish_offsetof): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159349 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 135de46abe7..47f3897c8d1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3210,7 +3210,7 @@ finish_offsetof (tree expr) } if (TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE || TREE_CODE (TREE_TYPE (expr)) == METHOD_TYPE - || TREE_CODE (TREE_TYPE (expr)) == UNKNOWN_TYPE) + || TREE_TYPE (expr) == unknown_type_node) { if (TREE_CODE (expr) == COMPONENT_REF || TREE_CODE (expr) == COMPOUND_EXPR) -- 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/semantics.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 47f3897c8d1..173ef961670 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2212,7 +2212,7 @@ finish_compound_literal (tree type, tree compound_literal) if (TREE_CODE (type) == ARRAY_TYPE) cp_complete_array_type (&type, compound_literal, false); compound_literal = digest_init (type, compound_literal); - if ((!at_function_scope_p () || cp_type_readonly (type)) + if ((!at_function_scope_p () || CP_TYPE_CONST_P (type)) && initializer_constant_valid_p (compound_literal, type)) { tree decl = create_temporary_var (type); @@ -5629,7 +5629,7 @@ capture_decltype (tree decl) if (TREE_CODE (type) != REFERENCE_TYPE) { if (!LAMBDA_EXPR_MUTABLE_P (lam)) - type = cp_build_qualified_type (type, (TYPE_QUALS (type) + type = cp_build_qualified_type (type, (cp_type_quals (type) |TYPE_QUAL_CONST)); type = build_reference_type (type); } -- cgit v1.2.1 From 0f71a63312aa6d9fb21c18993cffa4d13d25151d Mon Sep 17 00:00:00 2001 From: steven Date: Sat, 22 May 2010 22:24:53 +0000 Subject: gcc/ChangeLog: * coretypes.h (struct simple_bitmap_def, sbitmap, const_sbitmap): New core types. * sbitmap.h (struct sbitmap_def): Do not typedef here. * sbitmap.c: Include sbitmap.h. * basic-block.h: Do not include bitmap.h, sbitmap.h, partition.h, hard-reg-set.h. Split everything related to regsets out from here... * regset.h: ...to here. New file. * df.h: Include regset.h and sbitmap.h. * tree-flow.h: Likewise. * cfgloop.h: Likewise. * except.h: Do not include sbitmap.h. Include hashtab.h. * cgraph.h: Include vec.h and function.h. * reload.h (struct insn_chain): Change types of live_throughout and dead_or_set from regset_head to bitmap_head. (compute_use_by_pseudos): Be defined also if regset.h is not included. * ira-int.h (struct ira_spilled_reg_stack_slot): Change type of spilled_regs from regset_head to bitmap_head to avoid dependency in regset.h. * sel-sched-ir.h: Include regset.h. * reload.c: Include df.h before reload.h. * caller-save.c: Likewise. * reload1.c: Likewise. * ira.c: Likewise. (mark_elimination): Update type of r to bitmap, consistent with DF_LR_IN. * dominance.c: Include bitmap.h. * modulo-sched.c: Include df.h. * cfganal.c: Include bitmap.h and sbitmap.h. * cfgbuild.c: Include sbitmap.h. * lcm.c: Include sbitmap.h. * gcse.c (alloc_gcse_mem): Allocate regset with ALLOC_REG_SET. * domwalk.c: Include sbitmap.h, exclude ggc.h. * cfgexpand.c: Inlcude bitmap.h and sbitmap.h. * cselib.c: Include bitmap.h. * tree-optimize.c: Include regset.h. * stmt.c: Include bitmap.h. * Makefile.in: Update dependencies. cp/ChangeLog * semantics.c: Include bitmap.h. * Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159746 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 173ef961670..b97a4c363c5 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -47,6 +47,7 @@ along with GCC; see the file COPYING3. If not see #include "vec.h" #include "target.h" #include "gimple.h" +#include "bitmap.h" /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or -- 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/semantics.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index b97a4c363c5..72a72957abc 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -36,11 +36,8 @@ along with GCC; see the file COPYING3. If not see #include "except.h" #include "toplev.h" #include "flags.h" -#include "rtl.h" -#include "expr.h" #include "output.h" #include "timevar.h" -#include "debug.h" #include "diagnostic.h" #include "cgraph.h" #include "tree-iterator.h" @@ -49,6 +46,8 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "bitmap.h" +#include "rtl.h" /* For decl_default_tls_model. */ + /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or during template instantiation, which may be regarded as a -- cgit v1.2.1 From cb4070e00ced433c22465def62435fa9eee5a16e Mon Sep 17 00:00:00 2001 From: steven Date: Wed, 26 May 2010 08:36:49 +0000 Subject: gcc/ChangeLog: * rtl.h (decl_default_tls_model): Move prototype from here... * output.h: ...to here. * c-decl.c: Do not include rtl.h. * c-pragma.c: Likewise. * c-parser.c: Likewise. * c-gimplify.c: Likewise. And also not hard-reg-set. * c-common.c: Do not include rtl.h. Include tm_p.h and add a FIXME note for it. Add a FIXME note for expr.h. * config/i386/i386-protos.h (ix86_enum_va_list, ix86_fn_abi_va_list, ix86_canonical_va_list_type): Make visible even if RTX_CODE is not defined. cp/ChangeLog: * decl.c: Do not include rtl.h * semantics.c: Likewise. ada/ChangeLog: * gcc-interface/utils.c: Do not include rtl.h. fortran/ChangeLog: * trans-common.c: Do not include rtl.h, include output.h instead. * trans-decl.c: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@159856 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 72a72957abc..bf016f1f586 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -46,8 +46,6 @@ along with GCC; see the file COPYING3. If not see #include "gimple.h" #include "bitmap.h" -#include "rtl.h" /* For decl_default_tls_model. */ - /* There routines provide a modular interface to perform many parsing operations. They may therefore be used during actual parsing, or during template instantiation, which may be regarded as a -- cgit v1.2.1 From 93d0e758ba92bc644dc9b55c259baf9f6e2e9c24 Mon Sep 17 00:00:00 2001 From: jakub Date: Wed, 2 Jun 2010 19:52:07 +0000 Subject: PR debug/44367 * semantics.c (finalize_nrv): Don't copy DECL_ARTIFICIAL, DECL_IGNORED_P, DECL_SOURCE_LOCATION and DECL_ABSTRACT_ORIGIN from var to result. Set DECL_VALUE_EXPR on var. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160186 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index bf016f1f586..05d1cada906 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3504,14 +3504,15 @@ finalize_nrv (tree *tp, tree var, tree result) { struct nrv_data data; - /* Copy debugging information from VAR to RESULT. */ + /* Copy name from VAR to RESULT. */ DECL_NAME (result) = DECL_NAME (var); - DECL_ARTIFICIAL (result) = DECL_ARTIFICIAL (var); - DECL_IGNORED_P (result) = DECL_IGNORED_P (var); - DECL_SOURCE_LOCATION (result) = DECL_SOURCE_LOCATION (var); - DECL_ABSTRACT_ORIGIN (result) = DECL_ABSTRACT_ORIGIN (var); /* Don't forget that we take its address. */ TREE_ADDRESSABLE (result) = TREE_ADDRESSABLE (var); + /* Finally set DECL_VALUE_EXPR to avoid assigning + a stack slot at -O0 for the original var and debug info + uses RESULT location for VAR. */ + SET_DECL_VALUE_EXPR (var, result); + DECL_HAS_VALUE_EXPR_P (var) = 1; data.var = var; data.result = result; -- 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/semantics.c | 1 + 1 file changed, 1 insertion(+) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 05d1cada906..2d02690a717 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3255,6 +3255,7 @@ simplify_aggr_init_expr (tree *tp) fn, aggr_init_expr_nargs (aggr_init_expr), AGGR_INIT_EXPR_ARGP (aggr_init_expr)); + TREE_NOTHROW (call_expr) = TREE_NOTHROW (aggr_init_expr); if (style == ctor) { -- cgit v1.2.1 From 7bedc3a05d34cd81e4835a2d3ff8c0ec7108eeb5 Mon Sep 17 00:00:00 2001 From: steven Date: Sat, 5 Jun 2010 20:33:22 +0000 Subject: gcc/ChangeLog: * c-common.c: Move to c-family/. * c-common.def: Likewise. * c-common.h: Likewise. * c-cppbuiltin.c: Likewise. * c-dump.c: Likewise. * c-format.c: Likewise. * c-format.h : Likewise. * c-gimplify.c: Likewise. * c-lex.c: Likewise. * c-omp.c: Likewise. * c.opt: Likewise. * c-opts.c: Likewise. * c-pch.c: Likewise. * c-ppoutput.c: Likewise. * c-pragma.c: Likewise. * c-pragma.h: Likewise. * c-pretty-print.c: Likewise. * c-pretty-print.h: Likewise. * c-semantics.c: Likewise. * stub-objc.c: Likewise. * gengtype.c (get_file_langdir): Special-case files in c-family/. (get_output_file_with_visibility): Fix name for c-common.h. * c-config-lang.in: Update paths in gtfiles for files in c-family/. * c-tree.h: Update include path for moved files. * c-lang.c: Likewise. * c-lang.h: Likewise. * c-parser.c: Likewise. * c-convert.c: Likewise. * c-decl.c: Likewise. * c-objc-common.c: Likewise. * configure.ac: Make sure c-family/ exists in the build directory. * configure: Regenerate. * Makefile.in: Update paths for moved files. Regroup files per location and update dependencies. Move generated_files down after ALL_GTFILES_H. * config/spu/spu-c.c: Update paths for moved files. * config/mep/mep-pragma.c: Likewise. * config/darwin-c.c: Likewise. * config/i386/msformat-c.c: Likewise. * config/i386/i386-c.c: Likewise. * config/avr/avr-c.c: Likewise. * config/sol2-c.c: Likewise. * config/ia64/ia64-c.c: Likewise. * config/rs6000/rs6000-c.c: Likewise. * config/arm/arm.c: Likewise. * config/arm/arm-c.c: Likewise. * config/h8300/h8300.c: Likewise. * config/v850/v850-c.c: Likewise. * config/t-darwin: Fix dependencies for moved files. * config/t-sol2: Fix dependencies for moved files. * config/mep/t-mep: Fix dependencies for moved files. * config/ia64/t-ia64: Fix dependencies for moved files. * config/rs6000/t-rs6000: Fix dependencies for moved files. * config/v850/t-v850: Fix dependencies for moved files. * config/v850/t-v850e: Fix dependencies for moved files. * config/m32c/m32c-pragma.c * po/exgettext: Look in c-family/ also. c-family/ChangeLog: * c-common.c: Include gt-c-family-c-common.h. * c-pragma.c: Include gt-c-family-c-pragma.h. objc/ChangeLog: * objc-act.c: Update include path for moved files. * objc-lang.c: Likewise. * config-lang.in: Update paths in gtfiles for files in c-family/. objcp/ChangeLog: * objcp-lang.c: Update include path for moved files. * config-lang.in: Update paths in gtfiles for files in c-family/. cp/ChangeLog: * typeck.c: Update include path for moved files. * decl.c: Likewise. * rtti.c: Likewise. * cp-gimplify.c: Likewise. * cp-lang.c: Likewise. * pt.c: Likewise. * semantics.c: Likewise. * cxx-pretty-print.h: Likewise. * decl2.c: Likewise. * parser.c: Likewise. * cp-objcp-common.c: Likewise. * cp-tree.h: Likewise. * name-lookup.c: Likewise. * lex.c: Likewise. * name-lookup.h: Likewise. * config-lang.in: Update paths in gtfiles for files in c-family/. * Make-lang.in: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160330 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 2d02690a717..3e75240d034 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -30,7 +30,7 @@ along with GCC; see the file COPYING3. If not see #include "tm.h" #include "tree.h" #include "cp-tree.h" -#include "c-common.h" +#include "c-family/c-common.h" #include "tree-inline.h" #include "tree-mudflap.h" #include "except.h" -- cgit v1.2.1 From fd70b918fb48af1591d29b6496f293212a3b8456 Mon Sep 17 00:00:00 2001 From: froydnj Date: Wed, 9 Jun 2010 15:16:54 +0000 Subject: * call.c (build_call_n): Call XALLOCAVEC instead of alloca. (build_op_delete_call): Likewise. (build_over_call): Likewise. * cp-gimplify.c (cxx_omp_clause_apply_fn): Likewise. * pt.c (process_partial_specialization): Likewise. (tsubst_template_args): Likewise. * semantics.c (finish_asm_stmt): Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@160485 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 3e75240d034..8eb533614e0 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -1219,7 +1219,7 @@ finish_asm_stmt (int volatile_p, tree string, tree output_operands, tree operand; int i; - oconstraints = (const char **) alloca (noutputs * sizeof (char *)); + oconstraints = XALLOCAVEC (const char *, noutputs); string = resolve_asm_operand_names (string, output_operands, input_operands, labels); -- cgit v1.2.1 From e6bc58910451ad5ef38b579dcc45c12c1c1aa504 Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 22 Jun 2010 04:36:43 +0000 Subject: * semantics.c (check_trait_type): Check COMPLETE_TYPE_P for array element type. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161129 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8eb533614e0..4869cfc47e9 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5152,7 +5152,8 @@ check_trait_type (tree type) if (COMPLETE_TYPE_P (type)) return true; - if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type)) + if (TREE_CODE (type) == ARRAY_TYPE && !TYPE_DOMAIN (type) + && COMPLETE_TYPE_P (TREE_TYPE (type))) return true; if (VOID_TYPE_P (type)) -- cgit v1.2.1 From 596981c8fa329037fcb1297eaa219a36ad323e3e Mon Sep 17 00:00:00 2001 From: steven Date: Mon, 28 Jun 2010 10:52:46 +0000 Subject: gcc/ChangeLog: 2010-06-28 Steven Bosscher * system.h: Poison GCC_EXCEPT_H for front-end files. * langhooks.h (struct lang_hooks): Add eh_protect_cleanup_actions langhook. * langhooks-def.h (LANG_HOOKS_EH_PROTECT_CLEANUP_ACTIONS) New. Define to NULL by default. * except.h: Define GCC_EXCEPT_H. (doing_eh): Remove prototype. (init_eh, init_eh_for_function): Move prototypes to toplev.h. (lang_protect_cleanup_actions): Remove. * except.c (lang_protect_cleanup_actions): Remove. (doing_eh): Remove. (gen_eh_region): Don't check doing_eh here. * toplev.h (init_eh, init_eh_for_function_): Moved from except.h. * tree-eh.c (honor_protect_cleanup_actions): Use new langhook instead of lang_protect_cleanup_actions. * omp-low.c (maybe_catch_exception): Likewise. * Makefile.in: Update dependencies. gcc/c-family/ChangeLog: 2010-06-28 Steven Bosscher * c-cppbuiltin.c: Do not include except.h. gcc/objc/ChangeLog: 2010-06-28 Steven Bosscher * objc-act.c: Do not include except.h. gcc/cp/ChangeLog: 2010-06-28 Steven Bosscher * init.c: Do not include except.h. * decl.c: Likewise. * expr.c: Likewise. * cp-lang.c: Likewise. * pt.c: Likewise. * semantics.c: Likewise. * decl2.c: Likewise. * except.c: Likewise. (init_exception_processing): Do not set the removed lang_protect_cleanup_actions here. (cp_protect_cleanup_actions): Make non-static and remove prototype. (doing_eh): New, moved from except.c but removed the do_warning flag. (expand_start_catch_block): Update doing_eh call. (expand_end_catch_block): Likewise. (build_throw): Likewise. * cp-tree.h: Prototype cp_protect_cleanup_actions. * cp-objcp-common.h: Set LANG_HOOKS_EH_PROTECT_CLEANUP_ACTIONS to cp_protect_cleanup_actions. * Make-lang.in: Update dependencies. gcc/objcp/ChangeLog: 2010-06-28 Steven Bosscher * objcp-lang.c: Do not include except.h. * Make-lang.in: Update dependencies. gcc/java/ChangeLog: 2010-06-28 Steven Bosscher * lang.c: Do not include except.h * except.c: Likewise. (doing_eh): New, moved from except.c (in gcc/) but removed the do_warning flag. (maybe_start_try): Update doing_eh call. * Make-lang.in: Update dependencies. gcc/ada/ChangeLog: 2010-06-28 Steven Bosscher * gcc-interface/misc.c: Do not include except.h. * gcc-interface/Make-lang.in: Update dependencies. gcc/fortran/ChangeLog: 2010-06-28 Steven Bosscher * Make-lang.in: Update dependencies. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161484 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 1 - 1 file changed, 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 4869cfc47e9..e750937dfe1 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -33,7 +33,6 @@ along with GCC; see the file COPYING3. If not see #include "c-family/c-common.h" #include "tree-inline.h" #include "tree-mudflap.h" -#include "except.h" #include "toplev.h" #include "flags.h" #include "output.h" -- cgit v1.2.1 From 71e13640c689c89eb6d385204aa05ebf2fd0731f Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 29 Jun 2010 19:29:02 +0000 Subject: PR c++/44587 * pt.c (has_value_dependent_address): New. (value_dependent_expression_p): Check it. (convert_nontype_argument): Likewise. Call decay_conversion before folding if we want a pointer. * semantics.c (finish_id_expression): Don't add SCOPE_REF if the scope is the current instantiation. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161559 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index e750937dfe1..8baf76ac6ce 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3097,7 +3097,13 @@ finish_id_expression (tree id_expression, { tree r = convert_from_reference (decl); - if (processing_template_decl && TYPE_P (scope)) + /* In a template, return a SCOPE_REF for most qualified-ids + so that we can check access at instantiation time. But if + we're looking at a member of the current instantiation, we + know we have access and building up the SCOPE_REF confuses + non-type template argument handling. */ + if (processing_template_decl && TYPE_P (scope) + && !currently_open_class (scope)) r = build_qualified_name (TREE_TYPE (r), scope, decl, template_p); -- 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/semantics.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 8baf76ac6ce..9dae90b4c8f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3570,7 +3570,7 @@ cxx_omp_create_clause_info (tree c, tree type, bool need_default_ctor, CP_OMP_CLAUSE_INFO (c) = info; if (need_default_ctor - || (need_copy_ctor && !TYPE_HAS_TRIVIAL_INIT_REF (type))) + || (need_copy_ctor && !TYPE_HAS_TRIVIAL_COPY_CTOR (type))) { VEC(tree,gc) *vec; @@ -3624,7 +3624,7 @@ cxx_omp_create_clause_info (tree c, tree type, bool need_default_ctor, TREE_VEC_ELT (info, 1) = omp_clause_info_fndecl (t, type); } - if (need_copy_assignment && !TYPE_HAS_TRIVIAL_ASSIGN_REF (type)) + if (need_copy_assignment && !TYPE_HAS_TRIVIAL_COPY_ASSIGN (type)) { VEC(tree,gc) *vec; @@ -5011,7 +5011,7 @@ classtype_has_nothrow_assign_or_copy_p (tree type, bool assign_p) return false; fns = VEC_index (tree, CLASSTYPE_METHOD_VEC (type), ix); } - else if (TYPE_HAS_INIT_REF (type)) + else if (TYPE_HAS_COPY_CTOR (type)) { /* If construction of the copy constructor was postponed, create it now. */ @@ -5070,7 +5070,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) return (!CP_TYPE_CONST_P (type1) && type_code1 != REFERENCE_TYPE && (trivial_type_p (type1) || (CLASS_TYPE_P (type1) - && TYPE_HAS_TRIVIAL_ASSIGN_REF (type1)))); + && TYPE_HAS_TRIVIAL_COPY_ASSIGN (type1)))); case CPTK_HAS_NOTHROW_CONSTRUCTOR: type1 = strip_array_types (type1); @@ -5095,7 +5095,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) type" wording for this trait. */ type1 = strip_array_types (type1); return (trivial_type_p (type1) || type_code1 == REFERENCE_TYPE - || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_INIT_REF (type1))); + || (CLASS_TYPE_P (type1) && TYPE_HAS_TRIVIAL_COPY_CTOR (type1))); case CPTK_HAS_TRIVIAL_DESTRUCTOR: type1 = strip_array_types (type1); -- 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/semantics.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 9dae90b4c8f..adc5e7fe6ba 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5104,8 +5104,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) && TYPE_HAS_TRIVIAL_DESTRUCTOR (type1))); case CPTK_HAS_VIRTUAL_DESTRUCTOR: - return (CLASS_TYPE_P (type1) - && (t = locate_dtor (type1, NULL)) && DECL_VIRTUAL_P (t)); + return type_has_virtual_destructor (type1); case CPTK_IS_ABSTRACT: return (CLASS_TYPE_P (type1) && CLASSTYPE_PURE_VIRTUALS (type1)); -- 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/semantics.c | 100 ++++++----------------------------------------------- 1 file changed, 11 insertions(+), 89 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index adc5e7fe6ba..156f278e171 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -3527,31 +3527,6 @@ finalize_nrv (tree *tp, tree var, tree result) htab_delete (data.visited); } -/* Return the declaration for the function called by CALL_EXPR T, - TYPE is the class type of the clause decl. */ - -static tree -omp_clause_info_fndecl (tree t, tree type) -{ - tree ret = get_callee_fndecl (t); - - if (ret) - return ret; - - gcc_assert (TREE_CODE (t) == CALL_EXPR); - t = CALL_EXPR_FN (t); - STRIP_NOPS (t); - if (TREE_CODE (t) == OBJ_TYPE_REF) - { - t = cp_fold_obj_type_ref (t, type); - if (TREE_CODE (t) == ADDR_EXPR - && TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL) - return TREE_OPERAND (t, 0); - } - - return NULL_TREE; -} - /* Create CP_OMP_CLAUSE_INFO for clause C. Returns true if it is invalid. */ bool @@ -3569,80 +3544,27 @@ cxx_omp_create_clause_info (tree c, tree type, bool need_default_ctor, info = make_tree_vec (3); CP_OMP_CLAUSE_INFO (c) = info; - if (need_default_ctor - || (need_copy_ctor && !TYPE_HAS_TRIVIAL_COPY_CTOR (type))) + if (need_default_ctor || need_copy_ctor) { - VEC(tree,gc) *vec; - if (need_default_ctor) - vec = NULL; + t = get_default_ctor (type); else - { - t = build_int_cst (build_pointer_type (type), 0); - t = build1 (INDIRECT_REF, type, t); - vec = make_tree_vector_single (t); - } - t = build_special_member_call (NULL_TREE, complete_ctor_identifier, - &vec, type, LOOKUP_NORMAL, - tf_warning_or_error); + t = get_copy_ctor (type); - if (vec != NULL) - release_tree_vector (vec); - - if (targetm.cxx.cdtor_returns_this () || errorcount) - /* Because constructors and destructors return this, - the call will have been cast to "void". Remove the - cast here. We would like to use STRIP_NOPS, but it - wouldn't work here because TYPE_MODE (t) and - TYPE_MODE (TREE_OPERAND (t, 0)) are different. - They are VOIDmode and Pmode, respectively. */ - if (TREE_CODE (t) == NOP_EXPR) - t = TREE_OPERAND (t, 0); - - TREE_VEC_ELT (info, 0) = get_callee_fndecl (t); + if (t && !trivial_fn_p (t)) + TREE_VEC_ELT (info, 0) = t; } if ((need_default_ctor || need_copy_ctor) && TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type)) - { - t = build_int_cst (build_pointer_type (type), 0); - t = build1 (INDIRECT_REF, type, t); - t = build_special_member_call (t, complete_dtor_identifier, - NULL, type, LOOKUP_NORMAL, - tf_warning_or_error); + TREE_VEC_ELT (info, 1) = get_dtor (type); - if (targetm.cxx.cdtor_returns_this () || errorcount) - /* Because constructors and destructors return this, - the call will have been cast to "void". Remove the - cast here. We would like to use STRIP_NOPS, but it - wouldn't work here because TYPE_MODE (t) and - TYPE_MODE (TREE_OPERAND (t, 0)) are different. - They are VOIDmode and Pmode, respectively. */ - if (TREE_CODE (t) == NOP_EXPR) - t = TREE_OPERAND (t, 0); - - TREE_VEC_ELT (info, 1) = omp_clause_info_fndecl (t, type); - } - - if (need_copy_assignment && !TYPE_HAS_TRIVIAL_COPY_ASSIGN (type)) + if (need_copy_assignment) { - VEC(tree,gc) *vec; - - t = build_int_cst (build_pointer_type (type), 0); - t = build1 (INDIRECT_REF, type, t); - vec = make_tree_vector_single (t); - t = build_special_member_call (t, ansi_assopname (NOP_EXPR), - &vec, type, LOOKUP_NORMAL, - tf_warning_or_error); - release_tree_vector (vec); - - /* We'll have called convert_from_reference on the call, which - may well have added an indirect_ref. It's unneeded here, - and in the way, so kill it. */ - if (TREE_CODE (t) == INDIRECT_REF) - t = TREE_OPERAND (t, 0); + t = get_copy_assign (type); - TREE_VEC_ELT (info, 2) = omp_clause_info_fndecl (t, type); + if (t && !trivial_fn_p (t)) + TREE_VEC_ELT (info, 2) = t; } return errorcount != save_errorcount; @@ -5076,7 +4998,7 @@ trait_expr_value (cp_trait_kind kind, tree type1, tree type2) type1 = strip_array_types (type1); return (trait_expr_value (CPTK_HAS_TRIVIAL_CONSTRUCTOR, type1, type2) || (CLASS_TYPE_P (type1) - && (t = locate_ctor (type1, NULL)) + && (t = locate_ctor (type1)) && TYPE_NOTHROW_P (TREE_TYPE (t)))); case CPTK_HAS_TRIVIAL_CONSTRUCTOR: -- cgit v1.2.1 From dab3247a40d1376d0e1492670884a3041a86f840 Mon Sep 17 00:00:00 2001 From: pzhao Date: Tue, 6 Jul 2010 05:53:49 +0000 Subject: /cp 2010-07-06 Shujing Zhao * cp-tree.h (impl_conv_void): New type. (convert_to_void): Adjust prototype. * cvt.c (convert_to_void): Use impl_conv_void, emit and adjust the diagnostic for easy translation. Change caller. * typeck.c: Update call to convert_to_void. * semantics.c: Likewise. * init.c: Likewise. /testsuite 2010-07-06 Shujing Zhao * g++.dg/warn/noeffect2.C: Adjust expected warning. * g++.dg/warn/volatile1.C: Likewise. * g++.dg/template/warn1.C: Likewise. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@161863 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 156f278e171..887bb42e75f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -607,10 +607,10 @@ finish_expr_stmt (tree expr) { if (warn_sequence_point) verify_sequence_points (expr); - expr = convert_to_void (expr, "statement", tf_warning_or_error); + expr = convert_to_void (expr, ICV_STATEMENT, tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) - convert_to_void (build_non_dependent_expr (expr), "statement", + convert_to_void (build_non_dependent_expr (expr), ICV_STATEMENT, tf_warning_or_error); if (check_for_bare_parameter_packs (expr)) @@ -868,11 +868,11 @@ finish_for_expr (tree expr, tree for_stmt) { if (warn_sequence_point) verify_sequence_points (expr); - expr = convert_to_void (expr, "3rd expression in for", + expr = convert_to_void (expr, ICV_THIRD_IN_FOR, tf_warning_or_error); } else if (!type_dependent_expression_p (expr)) - convert_to_void (build_non_dependent_expr (expr), "3rd expression in for", + convert_to_void (build_non_dependent_expr (expr), ICV_THIRD_IN_FOR, tf_warning_or_error); expr = maybe_cleanup_point_expr_void (expr); if (check_for_bare_parameter_packs (expr)) -- cgit v1.2.1 From 1767a056f10a2ccbc900df04d01193da73a3d272 Mon Sep 17 00:00:00 2001 From: froydnj Date: Thu, 15 Jul 2010 14:31:28 +0000 Subject: gcc/ * tree.h (DECL_CHAIN): Define. * alias.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-decl.c: Likewise. * c-parser.c: Likewise. * c-typeck.c: Likewise. * cfgexpand.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/alpha/alpha.c: Likewise. * config/arm/arm.c: Likewise. * config/frv/frv.c: Likewise. * config/i386/i386.c: Likewise. * config/i386/winnt-cxx.c: Likewise. * config/ia64/ia64.c: Likewise. * config/iq2000/iq2000.c: Likewise. * config/mep/mep.c: Likewise. * config/mips/mips.c: Likewise. * config/pa/som.h: Likewise. * config/rs6000/rs6000.c: Likewise. * config/s390/s390.c: Likewise. * config/sh/sh.c: Likewise. * config/sh/symbian-cxx.c: Likewise. * config/sparc/sparc.c: Likewise. * config/spu/spu.c: Likewise. * config/stormy16/stormy16.c: Likewise. * config/vxworks.c: Likewise. * config/xtensa/xtensa.c: Likewise. * coverage.c: Likewise. * dbxout.c: Likewise. * dwarf2out.c: Likewise. * emit-rtl.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gimple-low.c: Likewise. * gimple-pretty-print.c: Likewise. * gimplify.c: Likewise. * integrate.c: Likewise. * ipa-inline.c: Likewise. * ipa-prop.c: Likewise. * ipa-split.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa-type-escape.c: Likewise. * langhooks.c: Likewise. * lto-cgraph.c: Likewise. * omp-low.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-complex.c: Likewise. * tree-dfa.c: Likewise. * tree-dump.c: Likewise. * tree-inline.c: Likewise. * tree-mudflap.c: Likewise. * tree-nested.c: Likewise. * tree-object-size.c: Likewise. * tree-pretty-print.c: Likewise. * tree-sra.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-math-opts.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-tailcall.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. * gcc-interface/utils2.c: Likewise. gcc/c-family/ * c-common.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * c-format.c: Likewise. gcc/cp/ * cp-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * call.c: Likewise. * class.c: Likewise. * cp-gimplify.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * init.c: Likewise. * mangle.c: Likewise. * name-lookup.c: Likewise. * optimize.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * rtti.c: Likewise. * search.c: Likewise. * semantics.c: Likewise. * typeck.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * f95-lang.c: Carefully replace TREE_CHAIN with DECL_CHAIN. * trans-common.c: Likewise. * trans-decl.c: Likewise. * trans-types.c: Likewise. * trans.c: Likewise. gcc/java/ * java-tree.h: Carefully replace TREE_CHAIN with DECL_CHAIN. * boehm.c: Likewise. * class.c: Likewise. * decl.c: Likewise. * expr.c: Likewise. * jcf-parse.c: Likewise. * typeck.c: Likewise. * verify-glue.c: Likewise. gcc/objc/ * objc-act.c: Carefully replace TREE_CHAIN with DECL_CHAIN. gcc/testsuite/ * g++.dg/plugin/attribute_plugin.c: Carefully replace TREE_CHAIN with DECL_CHAIN. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162223 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 887bb42e75f..a39e0b8dc1f 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -2418,7 +2418,7 @@ finish_member_declaration (tree decl) return; /* We should see only one DECL at a time. */ - gcc_assert (TREE_CHAIN (decl) == NULL_TREE); + gcc_assert (DECL_CHAIN (decl) == NULL_TREE); /* Set up access control for DECL. */ TREE_PRIVATE (decl) @@ -2460,7 +2460,7 @@ finish_member_declaration (tree decl) CLASSTYPE_METHOD_VEC. */ if (add_method (current_class_type, decl, NULL_TREE)) { - TREE_CHAIN (decl) = TYPE_METHODS (current_class_type); + DECL_CHAIN (decl) = TYPE_METHODS (current_class_type); TYPE_METHODS (current_class_type) = decl; maybe_add_class_template_decl_list (current_class_type, decl, @@ -2493,7 +2493,7 @@ finish_member_declaration (tree decl) = chainon (TYPE_FIELDS (current_class_type), decl); else { - TREE_CHAIN (decl) = TYPE_FIELDS (current_class_type); + DECL_CHAIN (decl) = TYPE_FIELDS (current_class_type); TYPE_FIELDS (current_class_type) = decl; } @@ -3319,7 +3319,7 @@ emit_associated_thunks (tree fn) { tree thunk; - for (thunk = DECL_THUNKS (fn); thunk; thunk = TREE_CHAIN (thunk)) + for (thunk = DECL_THUNKS (fn); thunk; thunk = DECL_CHAIN (thunk)) { if (!THUNK_ALIAS (thunk)) { @@ -3329,7 +3329,7 @@ emit_associated_thunks (tree fn) tree probe; for (probe = DECL_THUNKS (thunk); - probe; probe = TREE_CHAIN (probe)) + probe; probe = DECL_CHAIN (probe)) use_thunk (probe, /*emit_p=*/1); } } @@ -5850,8 +5850,8 @@ maybe_add_lambda_conv_op (tree type) DECL_NOT_REALLY_EXTERN (fn) = 1; DECL_DECLARED_INLINE_P (fn) = 1; DECL_STATIC_FUNCTION_P (fn) = 1; - DECL_ARGUMENTS (fn) = copy_list (TREE_CHAIN (DECL_ARGUMENTS (callop))); - for (arg = DECL_ARGUMENTS (fn); arg; arg = TREE_CHAIN (arg)) + DECL_ARGUMENTS (fn) = copy_list (DECL_CHAIN (DECL_ARGUMENTS (callop))); + for (arg = DECL_ARGUMENTS (fn); arg; arg = DECL_CHAIN (arg)) DECL_CONTEXT (arg) = fn; if (nested) DECL_INTERFACE_KNOWN (fn) = 1; @@ -5884,7 +5884,7 @@ maybe_add_lambda_conv_op (tree type) null_pointer_node); argvec = make_tree_vector (); VEC_quick_push (tree, argvec, arg); - for (arg = DECL_ARGUMENTS (statfn); arg; arg = TREE_CHAIN (arg)) + for (arg = DECL_ARGUMENTS (statfn); arg; arg = DECL_CHAIN (arg)) VEC_safe_push (tree, gc, argvec, arg); call = build_call_a (callop, VEC_length (tree, argvec), VEC_address (tree, argvec)); -- cgit v1.2.1 From 773ccee521ae391a69d16eed32a740f08ffc9c0f Mon Sep 17 00:00:00 2001 From: jason Date: Tue, 20 Jul 2010 01:31:42 +0000 Subject: PR c++/44996 * semantics.c (finish_decltype_type): Correct decltype of parenthesized rvalue reference variable. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@162323 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/cp/semantics.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'gcc/cp/semantics.c') diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index a39e0b8dc1f..949e108902a 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -4899,8 +4899,9 @@ finish_decltype_type (tree expr, bool id_expression_or_member_access_p) type = TYPE_MAIN_VARIANT (type); else if (real_lvalue_p (expr)) { - if (TREE_CODE (type) != REFERENCE_TYPE) - type = build_reference_type (type); + if (TREE_CODE (type) != REFERENCE_TYPE + || TYPE_REF_IS_RVALUE (type)) + type = build_reference_type (non_reference (type)); } else type = non_reference (type); -- cgit v1.2.1