aboutsummaryrefslogtreecommitdiff
path: root/gcc/cp/class.c
AgeCommit message (Collapse)AuthorFilesLines
2011-06-29re PR c++/45923 (constexpr diagnostics, more more)Jason Merrill1-1/+65
PR c++/45923 * class.c (explain_non_literal_class): New. (finalize_literal_type_property): Call it. * cp-tree.h: Declare it. * semantics.c (ensure_literal_type_for_constexpr_object): Call it. (is_valid_constexpr_fn): Likewise. (massage_constexpr_body): Split out from... (register_constexpr_fundef): ...here. (is_instantiation_of_constexpr): New. (expand_or_defer_fn_1): Leave DECL_SAVED_TREE alone in that case. (explain_invalid_constexpr_fn): New. (cxx_eval_call_expression): Call it. (potential_constant_expression_1): Likewise. Avoid redundant errors. * method.c (process_subob_fn): Diagnose non-constexpr. (walk_field_subobs): Likewise. (synthesized_method_walk): Don't shortcut if we want diagnostics. (explain_implicit_non_constexpr): New. (defaulted_late_check): Use it. * call.c (build_cxx_call): Remember location. From-SVN: r175646
2011-06-29class.c (finalize_literal_type_property): Update conditions.Jason Merrill1-4/+2
* class.c (finalize_literal_type_property): Update conditions. * method.c (defaulted_late_check): Set TYPE_HAS_CONSTEXPR_CTOR. From-SVN: r175644
2011-06-23re PR c++/49440 (Invalid dynamic_cast for unnamed namespace)Jason Merrill1-14/+3
PR c++/49440 * class.c (set_linkage_according_to_type): Just check TREE_PUBLIC on the type's name. From-SVN: r175340
2011-06-14re PR c++/49369 (typeof() strips const from member when used in const method)Jason Merrill1-16/+8
PR c++/49369 * class.c (build_base_path): Fix cv-quals in unevaluated context. From-SVN: r175042
2011-05-24re PR c++/48884 (decltype's operand doesn't consider friend declaration)Jason Merrill1-3/+17
PR c++/48884 * class.c (pushclass): Accept NULL argument. (popclass): Deal with popping null class. * pt.c (push_access_scope, pop_access_scope): Use them rather than push_to_top_level/pop_from_top_level. (push_deduction_access_scope, pop_defarg_context): New. (fn_type_unification): Use them. * name-lookup.c (lookup_name_real_1): Check current_class_type. From-SVN: r174139
2011-05-18re PR c++/48948 ([C++0x] constexpr friend function cannot be defined in-class)Jason Merrill1-2/+14
PR c++/48948 PR c++/49015 * class.c (finalize_literal_type_property): Do check for constexpr member functions of non-literal class. (finish_struct): Don't call check_deferred_constexpr_decls. * cp-tree.h: Don't declare it. (DECL_DEFERRED_CONSTEXPR_CHECK): Remove. * decl.c (grok_special_member_properties): Don't check it (grokfnedcl): Don't call validate_constexpr_fundecl. (start_preparsed_function): Do call it. * pt.c (tsubst_decl): Don't call it. (instantiate_class_template_1): Don't call check_deferred_constexpr_decls. * semantics.c (literal_type_p): Check for any incompleteness. (ensure_literal_type_for_constexpr_object): Likewise. (is_valid_constexpr_fn): Revert deferral changes. (validate_constexpr_fundecl): Likewise. (register_constexpr_fundef): Likewise. (check_deferred_constexpr_decls): Remove. From-SVN: r173869
2011-05-14Implement final on class.Ville Voutilainen1-0/+4
* class.c (check_bases): Diagnose derivation from a final class. * cp-tree.h (lang_type_class): Add is_final and adjust dummy. (CLASSTYPE_FINAL): New. * parser.c (cp_parser_class_head): Parse class-virt-specifier, set CLASSTYPE_FINAL. * pt.c (instantiate_class_template_1): Copy CLASSTYPE_FINAL. From-SVN: r173761
2011-05-11re PR c++/48948 ([C++0x] constexpr friend function cannot be defined in-class)Jason Merrill1-7/+2
PR c++/48948 * semantics.c (validate_constexpr_fundecl): Defer checking if an argument type is being defined. (is_valid_constexpr_fn): Add defer_ok parm. (cxx_eval_call_expression): Adjust. (check_deferred_constexpr_decls): New. (literal_type_p): Make sure type isn't being defined. (ensure_literal_type_for_constexpr_object): Handle type being defined. * cp-tree.h: Declare check_deferred_constexpr_decls. * decl.c (grokfndecl): Call validate_constexpr_fundecl here. (start_preparsed_function, cp_finish_decl): Not here. * class.c (finalize_literal_type_property): Don't call validate_constexpr_fundecl. (finish_struct): Call check_deferred_constexpr_decls. * pt.c (tsubst_decl): Call validate_constexpr_fundecl. (instantiate_class_template): Call check_deferred_constexpr_decls. From-SVN: r173683
2011-05-10re PR c++/48930 ([C++0x] Invalid implicitly declared default c'tor)Jason Merrill1-0/+21
PR c++/48930 * class.c (type_build_ctor_call): New. * cp-tree.h: Declare it. * decl.c (check_initializer): Use it instead of TYPE_NEEDS_CONSTRUCTING. * init.c (build_value_init, build_value_init_noctor): Likewise. (perform_member_init, expand_aggr_init_1, build_new_1): Likewise. (build_vec_init): Likewise. * typeck2.c (process_init_constructor_array): Likewise. (process_init_constructor_record): Likewise. From-SVN: r173628
2011-05-10Fixes for override/final.Ville Voutilainen1-6/+9
* class.c (check_for_override): Diagnose final on a nonvirtual member function, diagnose override for a virtual with no matching override. Don't fiddle around with DECL_VINDEX. From-SVN: r173626
2011-05-09Implement final/override for member functions.Ville Voutilainen1-0/+5
gcc/ * tree.h (TYPE_UNQUALIFIED, TYPE_QUAL_CONST): Convert to enum. (TYPE_QUAL_VOLATILE, TYPE_QUAL_RESTRICT): Likewise. gcc/cp/ * class.c (check_for_override): Check for DECL_OVERRIDE_P. * cp-tree.h (DECL_OVERRIDE_P, DECL_FINAL_P): New. (cp_virt_specifiers, enum virt_specifier): New. * decl.c (set_virt_specifiers): New. (grokdeclarator): Use them. Diagnose virt-specifiers on non-fields. * parser.c (make_call_declarator): add virt-specifiers parameter. (cp_parser_lambda_declarator_opt): Adjust. (cp_parser_direct_declarator): Likewise. (cp_parser_virt_specifier_seq_opt): New. * search.c (check_final_overrider): Diagnose attempts to override a final member function. From-SVN: r173581
2011-05-09re PR c++/48574 (ICE)Dodji Seketeli1-1/+1
Fix PR c++/48574 gcc/cp/ PR c++/48574 * class.c (fixed_type_or_null): Use type_dependent_p_push to test if the instance has a dependent initializer. gcc/testsuite/ PR c++/48574 * g++.dg/template/dependent-expr8.C: New test case. From-SVN: r173570
2011-05-04re PR c++/48749 (internal compiler error: tree check: expected field_decl)Jason Merrill1-1/+11
PR c++/48749 * class.c (resolves_to_fixed_type_p): Don't look closely in templates. From-SVN: r173412
2011-04-27class.c (resolve_address_of_overloaded_function): Don't change OVERLOAD to ↵Jason Merrill1-8/+1
TREE_LIST. * class.c (resolve_address_of_overloaded_function): Don't change OVERLOAD to TREE_LIST. * pt.c (print_candidates_1): Remove nonsensical assert. From-SVN: r173037
2011-04-26class.c (cp_fold_obj_type_ref): Remove.Martin Jambor1-28/+0
2011-04-26 Martin Jambor <mjambor@suse.cz> * class.c (cp_fold_obj_type_ref): Remove. * cp-tree.h (cp_fold_obj_type_ref): Remove declaration. From-SVN: r172977
2011-04-17re PR middle-end/20991 (ICE in cgraph_mark_reachable_node)Jan Hubicka1-2/+0
* cgraph.c (cgraph_clone_node): Do not handle vtable_method * cgraph.h (struct cgraph_local_info): Drop vtable_method. * cgraphunit.c (cgraph_copy_node_for_versioning): Drop vtable_method. * lto-cgraph.c (lto_output_node, input_overwrite_node): Drop vtable method. * gimple-fold.c (can_refer_decl_in_current_unit_p): Mention PR20991 in gimple-fold.c * varasm.c (mark_decl_referenced): Drop vtable_method handling code. * cp/class.c (cp_fold_obj_type_ref): Drop vtable_method. From-SVN: r172613
2011-04-13re PR c++/48574 (ICE)Dodji Seketeli1-0/+1
Fix PR c++/48574 gcc/cp/ * class.c (fixed_type_or_null): We cannot determine the dynamic type of a reference variable if its initializer is dependent. gcc/testsuite/ * g++.dg/template/dependent-expr7.C: New test case. From-SVN: r172375
2011-04-12class.c (cp_fold_obj_type_ref): Call cgraph_get_node instead of ↵Martin Jambor1-1/+1
cgraph_get_create_node. 2011-04-12 Martin Jambor <mjambor@suse.cz> gcc/cp/ * class.c (cp_fold_obj_type_ref): Call cgraph_get_node instead of cgraph_get_create_node. * decl2.c (cp_write_global_declarations): Call cgraph_get_node instead of cgraph_get_create_node. * method.c (make_alias_for_thunk): Call cgraph_get_node instead of cgraph_get_create_node, assert it returns non-NULL. (use_thunk): Likewise. * optimize.c (maybe_clone_body): Call cgraph_same_body_alias only when flag_syntax_only is not set. Call cgraph_get_node instead of cgraph_get_create_node. (maybe_clone_body): Call cgraph_get_node instead of cgraph_get_create_node. From-SVN: r172308
2011-04-12cgraph.h (cgraph_node): Remove function declaration.Martin Jambor1-1/+1
2011-04-12 Martin Jambor <mjambor@suse.cz> * cgraph.h (cgraph_node): Remove function declaration. (cgraph_create_node): Declare. (cgraph_get_create_node): Likewise. * cgraph.c (cgraph_create_node): Renamed to cgraph_create_node_1. Updated all callers. (cgraph_node): Renamed to cgraph_create_node, assert that a node for the decl does not already exist. Call cgraph_get_create_node instead of cgraph_node. (cgraph_get_create_node): New function. (cgraph_same_body_alias): Update comment. (cgraph_set_call_stmt): Call cgraph_get_node instead of cgraph_node, assert it does not return NULL. (cgraph_update_edges_for_call_stmt): Likewise. (cgraph_clone_edge): Likewise. (cgraph_create_virtual_clone): Likewise. (cgraph_update_edges_for_call_stmt_node): Call cgraph_get_create_node instead of cgraph_node. (cgraph_add_new_function): Call cgraph_create_node or cgraph_get_create_node instead of cgraph_node. * cgraphbuild.c (record_reference): Call cgraph_get_create_node instead of cgraph_node. (record_eh_tables): Likewise. (mark_address): Likewise. (mark_load): Likewise. (build_cgraph_edges): Call cgraph_get_create_node instead of cgraph_node. (rebuild_cgraph_edges): Likewise. * cgraphunit.c (cgraph_finalize_function): Call cgraph_get_create_node instead of cgraph_node. (cgraph_copy_node_for_versioning): Call cgraph_create_node instead of cgraph_node. * lto-symtab.c (lto_symtab_merge_cgraph_nodes_1): Call cgraph_create_node instead of cgraph_node. * c-decl.c (finish_function): Call cgraph_get_create_node instead of cgraph_node. * lto-cgraph.c (input_node): Likewise. * lto-streamer-in.c (input_function): Likewise. * varasm.c (mark_decl_referenced): Likewise. (assemble_alias): Likewise. gcc/c-family/ * c-gimplify.c (c_genericize): Call cgraph_get_create_node instead of cgraph_node. gcc/cp/ * cp/class.c (cp_fold_obj_type_ref): Call cgraph_get_create_node instead of cgraph_node. * cp/decl2.c (cxx_callgraph_analyze_expr): Likewise. (cp_write_global_declarations): Likewise. * cp/optimize.c (maybe_clone_body): Likewise. * cp/semantics.c (maybe_add_lambda_conv_op): Likewise. * cp/mangle.c (mangle_decl): Likewise. * cp/method.c (make_alias_for_thunk): Likewise. (use_thunk): Likewise. gcc/ada/ * gcc-interface/utils.c (end_subprog_body): Call cgraph_get_create_node instead of cgraph_node. gcc/fortran/ * trans-decl.c (gfc_generate_function_code): Call cgraph_get_create_node instead of cgraph_node. gcc/objc/ * objc-act.c (mark_referenced_methods): Call cgraph_get_create_node instead of cgraph_node. From-SVN: r172307
2011-03-29re PR c++/48296 ([C++0x] constexpr member function cannot use the class type ↵Jason Merrill1-12/+6
it belongs as parameter type or return type) PR c++/48296 * decl.c (cp_finish_decl): Defer validation of constexpr member functions. * class.c (finalize_literal_type_property): Validate them here. * semantics.c (is_valid_constexpr_fn): Don't check completeness. From-SVN: r171661
2011-03-25Core 1135Jason Merrill1-0/+2
Core 1135 * method.c (defaulted_late_check): Check for exception spec mismatch. (defaultable_fn_check): Allow exception spec and virtual. * class.c (check_for_override): A virtual dtor is non-trivial. From-SVN: r171462
2011-02-28re PR c++/47873 (virtual Inheritance - Covariant Virtual Function - Segfault)Jason Merrill1-2/+2
PR c++/47873 * class.c (update_vtable_entry_for_fn): Check BINFO_LOST_PRIMARY_P after checking for a non-thunk. From-SVN: r170576
2011-02-22re PR c++/47666 (ICE in dfs_walk_once)Dodji Seketeli1-28/+65
Fix PR c++/47666 gcc/cp/ PR c++/47666 * class.c (dfs_declare_virt_assop_and_dtor) (declare_virt_assop_and_dtor): New static functions. (add_implicitly_declared_members): Use declare_virt_assop_and_dtor. gcc/testsuite/ PR c++/47666 * g++.dg/inherit/virtual7.C: New test. From-SVN: r170413
2011-02-10class.c (type_has_constexpr_default_constructor): Make sure the caller ↵Jason Merrill1-1/+5
stripped an enclosing array. * class.c (type_has_constexpr_default_constructor): Make sure the caller stripped an enclosing array. * init.c (perform_member_init): Strip arrays before calling it. From-SVN: r170006
2010-11-08Correct conversion/overflow behavior.Jason Merrill1-0/+3
* cvt.c (ignore_overflows): Move here from typeck.c. (ocp_convert): Use it. (cp_fold_convert): Use it. Don't call rvalue. * typeck.c (build_static_cast_1): Don't use it. Do call rvalue. * error.c (location_of): Handle expressions, too. * class.c (check_bitfield_decl): Set input_location around call to cxx_constant_value. * semantics.c (cxx_eval_outermost_constant_expr): Don't print the expression if it already had TREE_OVERFLOW set. (reduced_constant_expression_p): Check TREE_OVERFLOW_P for C++98, too. (verify_constant): Allow overflow with a permerror if we're enforcing. (cxx_eval_outermost_constant_expr): Use verify_constant. (adjust_temp_type): Use cp_fold_convert. * decl.c (build_enumerator): Don't call constant_expression_warning. * decl2.c (grokbitfield): Likewise. From-SVN: r166453
2010-11-04semantics.c (speculative_access_check): New.Jason Merrill1-1/+1
* semantics.c (speculative_access_check): New. * cp-tree.h: Declare it. * call.c (build_over_call): Use it. * class.c (type_has_constexpr_default_constructor): Use locate_ctor. * method.c (locate_ctor): Use push/pop_deferring_access_checks. From-SVN: r166317
2010-11-03builtins.c (fold_builtin_signbit): Use build_zero_cst instead of fold_convert.Nathan Froyd1-4/+2
gcc/ * builtins.c (fold_builtin_signbit): Use build_zero_cst instead of fold_convert. * c-typeck.c (build_function_call_vec): Likewise. * cfgexpand.c (expand_debug_expr): Likewise. * cgraphunit.c (assemble_thunk): Likewise. * config/sparc/sparc.c (sparc_fold_builtin): Likewise. * fold-const.c (fold_unary_loc, fold_mult_zconjz): Likewise. (fold_binary_loc, fold_ternary_loc): Likewise. * gimple-fold.c (get_symbol_constant_value): Likewise. * gimple-low.c (lower_builtin_setjmp): Likewise. * gimple.c (gimple_cond_get_ops_from_tree): Likewise. * gimplify.c (gimplify_init_constructor): Likewise. * lambda.h (build_linear_expr): Likewise. * omp-low.c (omp_reduction_init): Likewise. * tree-inline.c (remap_ssa_name): Likewise. * tree-object-size.c (compute_object_sizes): Likewise. * tree-sra.c (init_subtree_with_zero): Likewise. (sra_ipa_modify_assign): Likewise. * tree-ssa-copy.c (propagate_tree_value_into_stmt): Likewise. * tree-ssa-reassoc.c (eliminate_duplicate_pair): Likewise. (eliminate_plus_minus_pair, eliminate_not_pairs): Likewise. (undistribute_ops_list): Likewise. * tree-ssa-sccvn.c (vn_reference_lookup_3): Likewise. * tree-vect-stmts.c (vectorizable_call): Likewise. * tree.c (build_vector_from_ctor, build_one_cst): Likewise. (build_zero_cst): Handle more cases directly. Update comment. gcc/cp/ * class.c (build_base_path, add_vcall_offset): Use build_zero_cst instead of fold_convert. * init.c (build_zero_init): Likewise. * typeck.c (cp_build_binary_op): Likewise. gcc/fortran/ * trans-decl.c (add_argument_checking): Use build_zero_cst instead of fold_convert. * trans-expr.c (gfc_conv_missing_dummy, fill_with_spaces): Likewise. * trans-stmt.c (gfc_trans_do): Likewise. From-SVN: r166227
2010-11-02Restore canonical type comparison for dependent type(def)sDodji Seketeli1-1/+1
This patch restores canonical type comparison for dependent types and then dependent typedefs. After this patch, two template type parameters T are equal if they have the same index, level, *and* number of sibling parameters. The novelty is to take in account the number of sibling parameters. To do this we first build the template parameters w/o taking in account their number of siblings. When we know the number of template parameters we fix up each template parameter with the number of slibling parameters and we build the appropriate canonical types accordingly. The patch fixes the fallouts deemed necessary. This fixes PR c++/45606 but actually fixes all the previous bugs related to dependent typedef comparison we had since we started to properly representing dependent typedefs. gcc/cp/ChangeLog: PR c++/45606 * cp-tree.h (TEMPLATE_TYPE_PARM_SIBLING_PARMS): Remove. (struct template_parm_index_s)<num_siblings>: New field. (TEMPLATE_PARM_NUM_SIBLINGS): New accessor. (process_template_parm): Extend the API to accept the number of template parms in argument. (cp_set_underlying_type): Remove this. * class.c (build_self_reference): Require canonical type equality back on the self reference of class. * decl2.c (grokfield): Require canonical type equality back on typedef class fields. * name-lookup.c (pushdecl_maybe_friend): Require canonical type equality back on typedefs. * parser.c (cp_parser_template_parameter_list): Do not require canonical type equality on dependent types created during template parameters parsing. * pt.c (fixup_template_type_parm_type, fixup_template_parm_index) (fixup_template_parm, fixup_template_parms): New private functions. (current_template_args): Declare this. (process_template_parm): Pass the total number of template parms to canonical_type_parameter. (build_template_parm_index): Add a new argument to carry the total number of template parms. (reduce_template_parm_level, process_template_parm, make_auto): Adjust. (current_template_args): Fix this for template template parameters. (tsubst_template_parm): Split out of ... (tsubst_template_parms): ... this. (reduce_template_parm_level): Don't loose TEMPLATE_PARM_NUM_SIBLINGS when cloning a TEMPLATE_PARM_INDEX. (template_parm_to_arg): Extracted this function from current_template_args. Make it represent invalid template parms with an error_mark_node instead of a LIST_TREE containing an error_mark_node. (current_template_args): Use template_parm_to_arg. (dependent_template_arg_p): Consider an invalid template argument as dependent. (end_template_parm_list): Do not update template sibling parms here anymore. Use fixup_template_parms instead. (process_template_parm): Pass the number of template parms to canonical_type_parameter. (make_auto): Require structural equality on auto TEMPLATE_TYPE_PARM for now. (unify)<BOUND_TEMPLATE_TEMPLATE_PARM>: Coerce template parameters using all the arguments deduced so far. (tsubst)<TEMPLATE_TYPE_PARM>: Pass the number of sibling parms to canonical_type_parameter. * tree.c (cp_set_underlying_type): Remove. * typeck.c (get_template_parms_of_dependent_type) (incompatible_dependent_types_p): Remove. (structural_comptypes): Do not call incompatible_dependent_types_p anymore. (comp_template_parms_position): Re-organized. Take the length of template parms list in account. gcc/testsuite/ChangeLog: PR c++/45606 * g++.dg/template/typedef36.C: New test. * gcc/testsuite/g++.dg/template/canon-type-9.C: Likewise. * g++.dg/template/canon-type-10.C: Likewise. * g++.dg/template/canon-type-11.C: Likewise. * g++.dg/template/canon-type-12.C: Likewise. * g++.dg/template/canon-type-13.C: Likewise. From-SVN: r166179
2010-11-01call.c (null_ptr_cst_p): Use maybe_constant_value.Jason Merrill1-1/+1
* call.c (null_ptr_cst_p): Use maybe_constant_value. (set_up_extended_ref_temp): Support constant initialization. (initialize_reference): Adjust. * class.c (check_bitfield_decl): Use cxx_constant_value. * cvt.c (ocp_convert): Don't use integral_constant_value when converting to class type. * decl.c (finish_case_label): Use maybe_constant_value. (build_init_list_var_init): Support constant initialization. (check_initializer): Likewise. Reorganize. (cp_finish_decl): Likewise. (expand_static_init): Likewise. (compute_array_index_type): Use maybe_constant_value. Add complain parm. (create_array_type_for_decl, grokdeclarator): Pass it. (build_enumerator): Use cxx_constant_value. * decl2.c (grokfield): Use maybe_constant_init. * except.c (check_noexcept_r): Handle constexpr. (build_noexcept_spec): Use maybe_constant_value. * init.c (expand_default_init): Support constant initialization. (build_vec_init): Likewise. (constant_value_1): Adjust. (build_new_1): Adjust. * parser.c (cp_parser_constant_expression): Allow non-integral in C++0x mode. (cp_parser_direct_declarator): Don't fold yet in C++0x mode. (cp_parser_initializer_clause): Toss folded result if non-constant. * pt.c (fold_decl_constant_value): Remove. (convert_nontype_argument): Use maybe_constant_value. Give clearer error about overflow. (tsubst): Move array bounds handling into compute_array_index_type. (value_dependent_expression_p): Handle constant CALL_EXPR. * semantics.c (finish_static_assert): Use maybe_constant_value. (ensure_literal_type_for_constexpr_object): Make sure type is complete. (potential_constant_expression): Use maybe_constant_value. * tree.c (cast_valid_in_integral_constant_expression_p): Any cast is potentially valid in C++0x. * typeck2.c (store_init_value): Handle constant init. (check_narrowing): Use maybe_constant_value. (build_functional_cast): Set TREE_CONSTANT on literal T(). * cp-tree.h (DECL_INTEGRAL_CONSTANT_VAR_P): Remove. (LOOKUP_ALREADY_DIGESTED): New. (compute_array_index_type): Adjust prototype. From-SVN: r166167
2010-10-31class.c (is_really_empty_class): Work when type is not complete.Jason Merrill1-17/+24
* class.c (is_really_empty_class): Work when type is not complete. (synthesized_default_constructor_is_constexpr): New. (add_implicitly_declared_members): Use it. (type_has_constexpr_default_constructor): Likewise. * cp-tree.h: Declare it. * method.c (synthesized_method_walk): Use it. From-SVN: r166124
2010-10-30class.c (layout_vtable_decl): Call build_array_of_n_type.Nathan Froyd1-6/+5
* class.c (layout_vtable_decl): Call build_array_of_n_type. (build_vtt, build_ctor_vtabl_group): Likewise. From-SVN: r166090
2010-10-27method.c (synthesized_method_walk): Track constexprness too.Gabriel Dos Reis1-1/+14
* method.c (synthesized_method_walk): Track constexprness too. (process_subob_fn, walk_field_subobs): Likewise. (implicitly_declare_fn): Set DECL_DECLARED_CONSTEXPR_P. (defaulted_late_check): Handle DECL_DECLARED_CONSTEXPR_P. * class.c (add_implicitly_declared_members): Handle constexpr default ctor. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r166014
2010-10-27parser.c (cp_parser_ctor_initializer_opt_and_function_body): Make sure a ↵Gabriel Dos Reis1-0/+13
constexpr ctor has an empty body. * parser.c (cp_parser_ctor_initializer_opt_and_function_body): Make sure a constexpr ctor has an empty body. * class.c (type_has_constexpr_default_constructor): New. * cp-tree.h: Declare it. * init.c (perform_member_init): Complain about uninitialized member in constexpr ctor. (emit_mem_initializers): And uninitialized base. * decl.c (check_tag_decl): Fix typo. * semantics.c (valid_type_in_constexpr_fundecl_p): New fn. (is_valid_constexpr_fn): New fn. (validate_constexpr_fundecl): Use it. * decl.c (validate_constexpr_redeclaration): New. (duplicate_decls): Use it. (cp_finish_decl): Call validate_constexpr_fundecl and ensure_literal_type_for_constexpr_object here. (start_decl): Not here. Don't ICE on constexpr reference. (check_for_uninitialized_const_var): Don't handle constexpr specially. (grokfndecl): Set DECL_DECLARED_CONSTEXPR_P. (check_static_variable_definition): Give friendly message about missing constexpr. (grokdeclarator): Complain about typedef and volatile with constexpr. Reorganize. Give sorry about non-static data members in C++0x mode. (start_preparsed_function): Check validate_constexpr_fundecl here. (check_function_type): Not here. * decl2.c (finish_static_data_member_decl): Don't complain about in-class init. * parser.c (CP_PARSER_FLAGS_ONLY_TYPE_OR_CONSTEXPR): New. (cp_parser_condition): Pass it to cp_parser_decl_specifier_seq. (cp_parser_decl_specifier_seq): Handle it. (cp_parser_explicit_instantiation): Diagnose inline and constexpr. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r166013
2010-10-27class.c (check_bases): Propagate non-literality.Gabriel Dos Reis1-0/+49
* class.c (check_bases): Propagate non-literality. (check_field_decls): Likewise. (finalize_literal_type_property): New. (check_bases_and_members): Call it. * cp-tree.h (TYPE_HAS_CONSTEXPR_CTOR): New. (lang_type_class): Add has_constexpr_ctor field. (DECL_DECLARED_CONSTEXPR_P): Strip template. * decl.c (grok_special_member_properties): Set TYPE_HAS_CONSTEXPR_CTOR. Co-Authored-By: Jason Merrill <jason@redhat.com> From-SVN: r166012
2010-10-13re PR c++/45984 (ICE: canonical types differ for identical types)Jason Merrill1-2/+21
PR c++/45984 * class.c (fixup_attribute_variants): New fn. * cp-tree.h: Declare it. * pt.c (instantiate_class_template): Call it. * semantics.c (begin_class_definition): Call it. From-SVN: r165443
2010-09-27Require lvalues as specified by the standard.Jason Merrill1-6/+4
* typeck.c (lvalue_or_else): Use real_lvalue_p. (cp_build_addr_expr_1): Split out of cp_build_unary_op. (cp_build_addr_expr, cp_build_addr_expr_strict): Interfaces. (decay_conversion, get_member_function_from_ptrfunc): Adjust. (build_x_unary_op, build_reinterpret_cast_1): Adjust. (build_const_cast_1): Adjust. * cp-tree.h: Declare new fns. * call.c (build_this, convert_like_real, build_over_call): Adjust. (initialize_reference): Adjust. * class.c (build_base_path, convert_to_base_statically): Adjust. (build_vfn_ref, resolve_address_of_overloaded_function): Adjust. * cvt.c (build_up_reference, convert_to_reference): Adjust. * decl.c (register_dtor_fn): Adjust. * decl2.c (build_offset_ref_call_from_tree): Adjust. * except.c (initialize_handler_parm): Adjust. * init.c (build_offset_ref, build_delete, build_vec_delete): Adjust. * rtti.c (build_dynamic_cast_1, tinfo_base_init): Adjust. * tree.c (stabilize_expr): Adjust. From-SVN: r164666
2010-09-15re PR c++/45635 (Failed to bootstrap on Linux/ia64)Jakub Jelinek1-6/+12
PR c++/45635 * class.c (build_vtbl_initializer): Use fn instead of init's operand as first argument to FDESC_EXPR. From-SVN: r164311
2010-09-10re PR tree-optimization/45605 (Missed devirtualization)Jan Hubicka1-2/+2
PR tree-optimization/45605 * cp/class.c (build_vtbl_initializer): Avoid wrong type conversion in ADDR_EXPR From-SVN: r164148
2010-08-20vec.h (FOR_EACH_VEC_ELT): Define.Nathan Froyd1-2/+2
gcc/ * vec.h (FOR_EACH_VEC_ELT): Define. * c-decl.c: Use it. * cfgloop.c: Likewise. * cfgloopmanip.c: Likewise. * cgraph.c: Likewise. * cgraphunit.c: Likewise. * combine.c: Likewise. * config/bfin/bfin.c: Likewise. * config/mips/mips.c: Likewise. * config/rs6000/rs6000.c: Likewise. * dbxout.c: Likewise. * df-scan.c: Likewise. * dominance.c: Likewise. * dse.c: Likewise. * dwarf2out.c: Likewise. * except.c: Likewise. * expr.c: Likewise. * function.c: Likewise. * gcse.c: Likewise. * genattr.c: Likewise. * ggc-common.c: Likewise. * gimplify.c: Likewise. * graphite-blocking.c: Likewise. * graphite-clast-to-gimple.c: Likewise. * graphite-dependences.c: Likewise. * graphite-interchange.c: Likewise. * graphite-poly.c: Likewise. * graphite-scop-detection.c: Likewise. * graphite-sese-to-poly.c: Likewise. * graphite.c: Likewise. * haifa-sched.c: Likewise. * ifcvt.c: Likewise. * implicit-zee.c: Likewise. * ipa-prop.c: Likewise. * ipa-struct-reorg.c: Likewise. * ipa.c: Likewise. * ira-build.c: Likewise. * ira-color.c: Likewise. * ira-emit.c: Likewise. * lambda-code.c: Likewise. * loop-invariant.c: Likewise. * loop-unroll.c: Likewise. * lower-subreg.c: Likewise. * lto-cgraph.c: Likewise. * lto-opts.c: Likewise. * lto-streamer-in.c: Likewise. * lto-streamer-out.c: Likewise. * lto-streamer.c: Likewise. * lto-symtab.c: Likewise. * matrix-reorg.c: Likewise. * opts.c: Likewise. * predict.c: Likewise. * print-tree.c: Likewise. * sdbout.c: Likewise. * sel-sched-dump.c: Likewise. * sel-sched-ir.c: Likewise. * sel-sched.c: Likewise. * sese.c: Likewise. * stor-layout.c: Likewise. * tree-cfg.c: Likewise. * tree-cfgcleanup.c: Likewise. * tree-chrec.c: Likewise. * tree-data-ref.c: Likewise. * tree-emutls.c: Likewise. * tree-inline.c: Likewise. * tree-into-ssa.c: Likewise. * tree-loop-distribution.c: Likewise. * tree-loop-linear.c: Likewise. * tree-mudflap.c: Likewise. * tree-outof-ssa.c: Likewise. * tree-parloops.c: Likewise. * tree-predcom.c: Likewise. * tree-pretty-print.c: Likewise. * tree-scalar-evolution.c: Likewise. * tree-ssa-live.c: Likewise. * tree-ssa-loop-im.c: Likewise. * tree-ssa-loop-ivcanon.c: Likewise. * tree-ssa-loop-ivopts.c: Likewise. * tree-ssa-loop-manip.c: Likewise. * tree-ssa-loop-niter.c: Likewise. * tree-ssa-loop-prefetch.c: Likewise. * tree-ssa-phiprop.c: Likewise. * tree-ssa-pre.c: Likewise. * tree-ssa-reassoc.c: Likewise. * tree-ssa-sccvn.c: Likewise. * tree-ssa-structalias.c: Likewise. * tree-ssa.c: Likewise. * tree-vect-data-refs.c: Likewise. * tree-vect-loop-manip.c: Likewise. * tree-vect-loop.c: Likewise. * tree-vect-patterns.c: Likewise. * tree-vect-slp.c: Likewise. * tree-vect-stmts.c: Likewise. * tree-vrp.c: Likewise. * tree.c: Likewise. * value-prof.c: Likewise. * var-tracking.c: Likewise. * varasm.c: Likewise. * vmsdbgout.c: Likewise. gcc/ada/ * gcc-interface/decl.c: Use FOR_EACH_VEC_ELT. * gcc-interface/trans.c: Likewise. * gcc-interface/utils.c: Likewise. gcc/c-family/ * c-common.c: Use FOR_EACH_VEC_ELT. * c-gimplify.c: Likewise. * c-pragma.c: Likewise. gcc/cp/ * call.c: Use FOR_EACH_VEC_ELT. * class.c: Likewise. * decl.c: Likewise. * decl2.c: Likewise. * error.c: Likewise. * except.c: Likewise. * mangle.c: Likewise. * method.c: Likewise. * name-lookup.c: Likewise. * parser.c: Likewise. * pt.c: Likewise. * repo.c: Likewise. * semantics.c: Likewise. * typeck2.c: Likewise. gcc/fortran/ * trans-openmp.c: Use FOR_EACH_VEC_ELT. gcc/java/ * class.c: Use FOR_EACH_VEC_ELT. * expr.c: Likewise. * jcf-parse.c: Likewise. * resource.c: Likewise. gcc/lto/ * lto.c: Use FOR_EACH_VEC_ELT. From-SVN: r163401
2010-08-17class.c (note_name_declared_in_class): Make in 'extern "C"' blocks...Kai Tietz1-1/+7
2010-08-17 Kai Tietz <kai.tietz@onevision.com> * class.c (note_name_declared_in_class): Make in 'extern "C"' blocks, or if -fms-extensions is enabled check, check permissive. From-SVN: r163300
2010-07-15re PR c++/44909 ([C++0x] Copy constructors implicitly deleted)Jason Merrill1-60/+13
PR c++/44909 * call.c (add_function_candidate): If we're working on an implicit declaration, don't consider candidates that won't match. * typeck.c (same_type_ignoring_top_level_qualifiers_p): Now a fn. * cp-tree.h (same_type_ignoring_top_level_qualifiers_p): Adjust. Revert: * cp-tree.h (struct lang_type_class): Add has_user_opeq. (TYPE_HAS_USER_OPEQ): New. * decl.c (grok_special_member_properties): Set it. * class.c (add_implicitly_declared_members): Don't lazily declare constructors/operator= if a base or member has a user-declared one. (check_bases_and_members, check_bases): Adjust. (check_field_decls, check_field_decl): Adjust. From-SVN: r162233
2010-07-15tree.h (DECL_CHAIN): Define.Nathan Froyd1-49/+49
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. From-SVN: r162223
2010-07-14Implement C++0x unrestricted unions (N2544)Jason Merrill1-5/+11
Implement C++0x unrestricted unions (N2544) * class.c (check_field_decl): Loosen union handling in C++0x. * method.c (walk_field_subobs): Split out from... (synthesized_method_walk): ...here. Set msg before loops. (process_subob_fn): Check for triviality in union members. * init.c (sort_mem_initializers): Splice out uninitialized anonymous unions and union members. (push_base_cleanups): Don't automatically destroy anonymous unions and union members. From-SVN: r162187
2010-07-13re PR c++/44909 ([C++0x] Copy constructors implicitly deleted)Jason Merrill1-13/+60
PR c++/44909 * cp-tree.h (struct lang_type_class): Add has_user_opeq. (TYPE_HAS_USER_OPEQ): New. * decl.c (grok_special_member_properties): Set it. * class.c (add_implicitly_declared_members): Don't lazily declare constructors/operator= if a base or member has a user-declared one. (check_bases_and_members, check_bases): Adjust. (check_field_decls, check_field_decl): Adjust. * method.c (synthesized_method_walk): Initialize check_vdtor. From-SVN: r162159
2010-07-09re PR c++/43120 (Virtual inheritance with covariant return type confuses GCC)Jason Merrill1-48/+40
PR c++/43120 * cp-tree.h (BV_LOST_PRIMARY): New macro. * class.c (update_vtable_entry_for_fn): Fix covariant thunk logic. Set BV_LOST_PRIMARY. (build_vtbl_initializer): Check BV_LOST_PRIMARY. From-SVN: r162008
2010-07-08re PR c++/43120 (Virtual inheritance with covariant return type confuses GCC)Jason Merrill1-6/+9
PR c++/43120 * class.c (update_vtable_entry_for_fn): Fix handling of dummy virtual bases for covariant thunks. From-SVN: r161954
2010-07-02re PR c++/44780 (Bogus set-but-not-used variable warning)Jakub Jelinek1-1/+1
PR c++/44780 * typeck.c (convert_for_assignment): When converting a convertible vector type or objc++ types, call mark_rvalue_use. * typeck2.c (build_m_component_ref): Use return values from mark_rvalue_use or mark_lvalue_use. * class.c (build_base_path): Likewise. * call.c (build_conditional_expr): Likewise. * c-c++-common/Wunused-var-12.c: New test. From-SVN: r161742
2010-06-29Enable implicitly declared move constructor/operator= (N3053).Jason Merrill1-15/+25
gcc/cp/ * class.c (add_implicitly_declared_members): A class with no explicitly declared copy or move constructor gets both declared implicitly, and similarly for operator=. (check_bases): A type with no copy ctor does not inhibit a const copy ctor in a derived class. (check_field_decl): Likewise. (check_bases_and_members): A nonexistent copy ctor/op= is non-trivial. * tree.c (type_has_nontrivial_copy_init): Adjust semantics. (trivially_copyable_p): Likewise. * call.c (convert_like_real): Use type_has_nontrivial_copy_init. * class.c (finish_struct_bits): Likewise. * tree.c (build_target_expr_with_type): Likewise. * typeck2.c (store_init_value): Likewise. libstdc++-v3/ * include/bits/unordered_map.h: Explicitly default copy constructors. * include/bits/unordered_set.h: Likewise. From-SVN: r161582
2010-06-29Enable implicitly deleted functions (N2346)Jason Merrill1-4/+3
Enable implicitly deleted functions (N2346) * class.c (check_bases_and_members): Adjust lambda flags. * method.c (implicitly_declare_fn): Set DECL_DELETED_FN if appropriate. From-SVN: r161581
2010-06-29Machinery to support implicit delete/move.Jason Merrill1-2/+62
* 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. From-SVN: r161579