diff options
author | Douglas Gregor <doug.gregor@gmail.com> | 2008-03-25 13:53:58 +0000 |
---|---|---|
committer | Doug Gregor <dgregor@gcc.gnu.org> | 2008-03-25 13:53:58 +0000 |
commit | 5ade1ed2c08bf2f327ee24afc57bc263fd90e6e1 (patch) | |
tree | 3ef47d27df52cfcaa5644727ec9e934a79cad636 /gcc/cp/rtti.c | |
parent | de6adfa2f4dfd7afd05eecab3b6cb6b2321d6ef2 (diff) | |
download | gcc-5ade1ed2c08bf2f327ee24afc57bc263fd90e6e1.zip gcc-5ade1ed2c08bf2f327ee24afc57bc263fd90e6e1.tar.gz gcc-5ade1ed2c08bf2f327ee24afc57bc263fd90e6e1.tar.bz2 |
typeck.c (composite_pointer_type_r): Add SFINAE support.
2008-03-25 Douglas Gregor <doug.gregor@gmail.com>
* typeck.c (composite_pointer_type_r): Add SFINAE support.
(composite_pointer_type): Ditto.
(common_type): Fix call to composite_pointer_type.
(cxx_sizeof_nowarn): New; used to be a macro.
(cxx_sizeof_expr): Add SFINAE support.
(cxx_alignof_expr): Ditto.
(decay_conversion): Fix calls for SFINAE support.
(rationalize_conditional_expr): Add SFINAE support.
(build_class_member_access_expr): Ditto.
(finish_class_member_access_expr): Ditto.
(build_x_indirect_ref): Ditto.
(build_indirect_ref): Original version renamed to
cp_build_indirect_ref; new version provides a bridge from
c-common.
(cp_build_indirect_ref): Was build_indirect_ref; added SFINAE
support.
(get_member_function_from_ptrfunc): Fix calls for SFINAE support.
(build_function_call): Original version renamed to
cp_build_function_call; new version provides a bridge from
c-common.
(cp_build_function_call): Was build_function_call; added SFINAE
support.
(convert_arguments): Add SFINAE support.
(build_x_binary_op): Ditto.
(build_binary_op): Original version renamed to cp_build_binary_op;
new version provides a bridge from c-common.
(cp_build_binary_op): Was build_binary_op; added SFINAE support.
(pointer_diff): Fix calls for SFINAE.
(build_x_unary_op): Add SFINAE support.
(condition_conversion): Fix calls for SFINAE.
(build_unary_op): Original version renamed to cp_build_unary_op;
new version provides a bridge from c-common.
(cp_build_unary_op): Was build_unary_op; added SFINAE support.
(unary_complex_lvalue): Fix calls for SFINAE.
(build_x_conditional_expr): Add SFINAE support.
(build_x_compound_expr_from_list): Fix calls for SFINAE.
(build_x_compound_expr): Add SFINAE support.
(convert_ptrmem): Fix calls for SFINAE.
(build_static_cast_1): Add SFINAE support.
(build_static_cast): Ditto.
(build_reinterpret_cast_1): Ditto.
(build_reinterpret_cast): Ditto.
(build_const_cast_1): Ditto.
(build_const_cast): Ditto.
(build_c_cast): Ditto.
(build_modify_expr): Original version renamed to
cp_build_modify_expr; new version provides a bridge from c-common.
(cp_build_modify_expr): Was build_modify_expr; added SFINAE
support.
(build_x_modify_expr): Add SFINAE support.
(build_ptrmemfunc): Fix calls for SFINAE.
(convert_for_assignment): Add SFINAE support.
(convert_for_initialization): Ditto.
(check_return_expr): Fix calls for SFINAE.
(lvalue_or_else): Add SFINAE support.
* init.c (perform_member_init): Fix calls for SFINAE.
(emit_mem_initializers): Ditto.
(expand_virtual_init): Ditto.
(expand_cleanup_for_base): Ditto.
(build_aggr_init): Add SFINAE support.
(expand_default_init): Ditto.
(expand_aggr_init_1): Fix calls for SFINAE.
(build_offset_ref): Ditto.
(build_new_1): Add SFINAE support.
(build_new): Ditto.
(build_vec_delete_1): Fix calls for SFINAE.
(get_temp_regvar): Ditto.
(build_vec_init): Add SFINAE support.
(build_dtor_call): Fix calls for SFINAE.
(build_delete): Ditto.
(push_base_cleanups): Ditto.
(build_vec_delete_1): Ditto.
* class.c (build_base_path): Fix calls for SFINAE.
(build_simple_base_path): Ditto.
(convert_to_base_statically): Ditto.
(build_vfn_ref): Ditto.
(resolve_address_of_overloaded_function): Ditto.
* decl.c (check_initializer): Fix calls for SFINAE.
(register_dtor_fn): Ditto.
(compute_array_index_type): Ditto.
(finish_enum): Ditto.
(start_preparsed_function): Ditto.
(cxx_maybe_build_cleanup): Ditto.
* call.c (convert_like): Add COMPLAIN argument.
(convert_like_with_context): Ditto.
(build_this): Fix calls for SFINAE.
(build_user_type_conversion): Ditto.
(resolve_args): Ditto.
(build_new_function_call): Add SFINAE support.
(build_operator_new_call): Fix calls for SFINAE.
(build_object_call): Add SFINAE support.
(build_conditional_expr): Ditto.
(build_new_op): Ditto.
(build_op_delete_call): Fix calls for SFINAE.
(build_temp): Ditto.
(convert_like_real): Add SFINAE support.
(build_x_va_arg): Fix calls for SFINAE.
(convert_default_arg): Ditto.
(build_over_call): Add SFINAE support.
(build_java_interface_fn_ref): Fix calls for SFINAE.
(build_special_member_call): Add SFINAE support.
(build_new_method_call): Ditto.
(perform_implicit_conversion): Ditto.
(perform_direct_initialization_if_possible): Ditto.
(initialize_reference): Fix calls for SFINAE.
* method.c (do_build_assign_ref): Fix calls for SFINAE.
* rtti.c (build_headof): Fix calls for SFINAE.
(get_tinfo_decl_dynamic): Ditto.
(get_typeid): Ditto.
(build_dynamic_cast_1): Add SFINAE support.
(build_dynamic_cast): Ditto.
(tinfo_base_init): Fix calls for SFINAE.
* except.c (do_get_exception_ptr): Fix calls for SFINAE.
(do_end_catch): Ditto.
(initialize_handler_parm): Ditto.
(expand_start_catch_block): Ditto.
(do_allocate_exception): Ditto.
(do_free_exception): Ditto.
(build_throw): Ditto.
* cvt.c (build_up_reference): Fix calls for SFINAE.
(convert_to_reference): Ditto.
(ocp_convert): Ditto.
(convert_to_void): Add SFINAE support.
* tree.c (build_dummy_object): Fix calls for SFINAE.
(stabilize_expr): Ditto.
* cp-tree.h (build_conditional_expr): Add tsubst_flags_t
parameter.
(build_new_method_call): Ditto.
(build_special_member_call): Ditto.
(build_new_op): Ditto.
(perform_implicit_conversion): Ditto.
(perform_direct_initialization_if_possible): Ditto.
(convert_to_void): Ditto.
(build_aggr_init): Ditto.
(build_new): Ditto.
(build_vec_init): Ditto.
(build_dynamic_cast): Ditto.
(finish_call_expr): Ditto
(cxx_sizeof_or_alignof_expr): Add COMPLAIN parameter.
(cxx_sizeof_nowarn): Remove macro; add function declaration.
(build_class_member_access_expr): Add tsubst_flags_t parameter.
(finish_class_member_access_expr): Ditto.
(build_x_indirect_ref): Ditto.
(cp_build_indirect_ref): New.
(cp_build_function_call): Add tsubst_flags_t parameter.
(build_x_unary_op): Ditto.
(cp_build_unary_op): New.
(build_x_conditional_expr): Add tsubst_flags_t parameter.
(build_x_compound_expr): Ditto.
(build_compound_expr): Ditto.
(build_static_cast): Ditto.
(build_reinterpret_cast): Ditto.
(build_const_cast): Ditto.
(build_c_cast): Ditto.
(build_x_modify_expr): Ditto.
(cp_build_modify_expr): New.
(convert_for_initialization): Add tsubst_flags_t parameter.
(cp_build_binary_op): Remove macro; add function declaration.
(invalid_nonstatic_memfn_p): Add tsubst_flags_t parameter.
(lvalue_or_else): Ditto.
(build_functional_cast): Ditto.
* typeck2.c (digest_init): Fix calls for SFINAE.
(process_init_constructor_array): Ditto.
(process_init_constructor_record): Ditto.
(build_x_arrow): Ditto.
(build_m_component_ref): Ditto.
(build_functional_cast): Add SFINAE support.
* pt.c (tsubst_copy_and_build): Add (more) SFINAE support.
* semantics.c (simplify_loop_decl_cond): Fix calls for SFINAE.
(finish_expr_stmt): Ditto.
(finish_for_expr): Ditto.
(finish_asm_stmt): Ditto.
(finish_non_static_data_member): Ditto.
(finish_qualified_id_expr): Ditto.
(finish_call_expr): Add SFINAE support.
(finish_increment_expr): Fix calls for SFINAE.
(finish_unary_op_expr): Ditto.
(simplify_aggr_init_expr): Ditto.
(finish_omp_clauses): Ditto.
(finish_omp_for): Ditto.
(finish_omp_barrier): Ditto.
(finish_omo_flush): Ditto.
* decl2.c (grok_array_decl): Fix calls or SFINAE.
(build_anon_union_vars): Ditto.
(get_guard_cond): Ditto.
(set_guard): Ditto.
(one_static_initialization_or_destruction): Ditto.
(do_static_initialization_or_destruction): Ditto.
(generate_ctor_or_dtor_function): Ditto.
(build_offset_ref_call_from_tree): Ditto.
* parser.c (cp_parser_postfix_expression): Fix calls for SFINAE.
(cp_parser_postfix_dot_deref_expression): Ditto.
(cp_parser_unary_expression): Ditto.
(cp_parser_new_expression): Ditto.
(cp_parser_cast_expression): Ditto.
(cp_parser_binary_expression): Ditto.
(cp_parser_question_colon_clause): Ditto.
(cp_parser_assignment_expression): Ditto.
(cp_parser_expression): Ditto.
(cp_parser_builtin_offsetof): Ditto.
(cp_parser_template_argument): Ditto.
(cp_parser_functional_cast): Ditto.
2008-03-25 Douglas Gregor <doug.gregor@gmail.com>
* c-common.c (c_sizeof_or_alignof_type): If we're not allowed to
complain when we hit an error, return ERROR_MARK_NODE.
2008-03-25 Douglas Gregor <doug.gregor@gmail.com>
* g++.dg/template/sfinae4.C: New.
* g++.dg/template/sfinae5.C: New.
* g++.dg/template/sfinae6.C: New.
* g++.dg/template/sfinae6_neg.C: New.
* g++.dg/template/sfinae7.C: New.
* g++.dg/template/sfinae8.C: New.
* g++.dg/template/sfinae9.C: New.
* g++.dg/template/sfinae10.C: New.
* g++.dg/template/sfinae11.C: New.
* g++.dg/template/sfinae12.C: New.
* g++.dg/template/sfinae13.C: New.
* g++.dg/template/sfinae14C: New.
From-SVN: r133519
Diffstat (limited to 'gcc/cp/rtti.c')
-rw-r--r-- | gcc/cp/rtti.c | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/gcc/cp/rtti.c b/gcc/cp/rtti.c index 8bd51c8..d17ef64 100644 --- a/gcc/cp/rtti.c +++ b/gcc/cp/rtti.c @@ -104,7 +104,7 @@ static GTY (()) VEC(tinfo_s,gc) *tinfo_descs; static tree ifnonnull (tree, tree); static tree tinfo_name (tree); -static tree build_dynamic_cast_1 (tree, tree); +static tree build_dynamic_cast_1 (tree, tree, tsubst_flags_t); static tree throw_bad_cast (void); static tree throw_bad_typeid (void); static tree get_tinfo_decl_dynamic (tree); @@ -188,7 +188,9 @@ build_headof (tree exp) index = build_int_cst (NULL_TREE, -2 * TARGET_VTABLE_DATA_ENTRY_DISTANCE); - offset = build_vtbl_ref (build_indirect_ref (exp, NULL), index); + offset = build_vtbl_ref (cp_build_indirect_ref (exp, NULL, + tf_warning_or_error), + index); type = build_qualified_type (ptr_type_node, cp_type_quals (TREE_TYPE (exp))); @@ -272,7 +274,7 @@ get_tinfo_decl_dynamic (tree exp) /* Otherwise return the type_info for the static type of the expr. */ t = get_tinfo_ptr (TYPE_MAIN_VARIANT (type)); - return build_indirect_ref (t, NULL); + return cp_build_indirect_ref (t, NULL, tf_warning_or_error); } static bool @@ -463,7 +465,8 @@ get_typeid (tree type) if (!type) return error_mark_node; - return build_indirect_ref (get_tinfo_ptr (type), NULL); + return cp_build_indirect_ref (get_tinfo_ptr (type), NULL, + tf_warning_or_error); } /* Check whether TEST is null before returning RESULT. If TEST is used in @@ -483,7 +486,7 @@ ifnonnull (tree test, tree result) paper. */ static tree -build_dynamic_cast_1 (tree type, tree expr) +build_dynamic_cast_1 (tree type, tree expr, tsubst_flags_t complain) { enum tree_code tc = TREE_CODE (type); tree exprtype = TREE_TYPE (expr); @@ -626,8 +629,9 @@ build_dynamic_cast_1 (tree type, tree expr) && TREE_CODE (TREE_TYPE (old_expr)) == RECORD_TYPE) { tree expr = throw_bad_cast (); - warning (0, "dynamic_cast of %q#D to %q#T can never succeed", - old_expr, type); + if (complain & tf_warning) + warning (0, "dynamic_cast of %q#D to %q#T can never succeed", + old_expr, type); /* Bash it to the expected type. */ TREE_TYPE (expr) = type; return expr; @@ -640,8 +644,9 @@ build_dynamic_cast_1 (tree type, tree expr) if (TREE_CODE (op) == VAR_DECL && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE) { - warning (0, "dynamic_cast of %q#D to %q#T can never succeed", - op, type); + if (complain & tf_warning) + warning (0, "dynamic_cast of %q#D to %q#T can never succeed", + op, type); retval = build_int_cst (type, 0); return retval; } @@ -650,7 +655,8 @@ build_dynamic_cast_1 (tree type, tree expr) /* Use of dynamic_cast when -fno-rtti is prohibited. */ if (!flag_rtti) { - error ("%<dynamic_cast%> not permitted with -fno-rtti"); + if (complain & tf_error) + error ("%<dynamic_cast%> not permitted with -fno-rtti"); return error_mark_node; } @@ -658,10 +664,10 @@ build_dynamic_cast_1 (tree type, tree expr) static_type = TYPE_MAIN_VARIANT (TREE_TYPE (exprtype)); td2 = get_tinfo_decl (target_type); mark_used (td2); - td2 = build_unary_op (ADDR_EXPR, td2, 0); + td2 = cp_build_unary_op (ADDR_EXPR, td2, 0, complain); td3 = get_tinfo_decl (static_type); mark_used (td3); - td3 = build_unary_op (ADDR_EXPR, td3, 0); + td3 = cp_build_unary_op (ADDR_EXPR, td3, 0, complain); /* Determine how T and V are related. */ boff = dcast_base_hint (static_type, target_type); @@ -671,7 +677,7 @@ build_dynamic_cast_1 (tree type, tree expr) expr1 = expr; if (tc == REFERENCE_TYPE) - expr1 = build_unary_op (ADDR_EXPR, expr1, 0); + expr1 = cp_build_unary_op (ADDR_EXPR, expr1, 0, complain); elems[0] = expr1; elems[1] = td3; @@ -726,13 +732,14 @@ build_dynamic_cast_1 (tree type, tree expr) errstr = "source type is not polymorphic"; fail: - error ("cannot dynamic_cast %qE (of type %q#T) to type %q#T (%s)", - expr, exprtype, type, errstr); + if (complain & tf_error) + error ("cannot dynamic_cast %qE (of type %q#T) to type %q#T (%s)", + expr, exprtype, type, errstr); return error_mark_node; } tree -build_dynamic_cast (tree type, tree expr) +build_dynamic_cast (tree type, tree expr, tsubst_flags_t complain) { if (type == error_mark_node || expr == error_mark_node) return error_mark_node; @@ -744,7 +751,7 @@ build_dynamic_cast (tree type, tree expr) return convert_from_reference (expr); } - return convert_from_reference (build_dynamic_cast_1 (type, expr)); + return convert_from_reference (build_dynamic_cast_1 (type, expr, complain)); } /* Return the runtime bit mask encoding the qualifiers of TYPE. */ @@ -876,7 +883,8 @@ tinfo_base_init (tinfo_s *ti, tree target) } vtable_ptr = get_vtable_decl (real_type, /*complete=*/1); - vtable_ptr = build_unary_op (ADDR_EXPR, vtable_ptr, 0); + vtable_ptr = cp_build_unary_op (ADDR_EXPR, vtable_ptr, 0, + tf_warning_or_error); /* We need to point into the middle of the vtable. */ vtable_ptr = build2 |