diff options
author | Mark Mitchell <mark@codesourcery.com> | 2003-07-08 01:38:44 +0000 |
---|---|---|
committer | Mark Mitchell <mmitchel@gcc.gnu.org> | 2003-07-08 01:38:44 +0000 |
commit | ee76b9314ba2aa2dc1f59c4efa32ac42dd84147d (patch) | |
tree | fd553211eb12fd2f9ce0b66abea29db6c18cd0f0 /gcc/cp/decl2.c | |
parent | 923c4cf299afcff993b1ae8f510e997d3aca94f5 (diff) | |
download | gcc-ee76b9314ba2aa2dc1f59c4efa32ac42dd84147d.zip gcc-ee76b9314ba2aa2dc1f59c4efa32ac42dd84147d.tar.gz gcc-ee76b9314ba2aa2dc1f59c4efa32ac42dd84147d.tar.bz2 |
cp-tree.h (build_scoped_method_call): Remove.
* cp-tree.h (build_scoped_method_call): Remove.
(lookup_qualified_name): Remove parameter.
(tsubst_copy_and_build): Declare.
(finish_qualified_object_call_expr): Remove.
(check_accessibility_of_qualified_id): New function.
(finish_qualified_id_expr): Likewise.
(non_reference): Likewise.
(build_expr_from-tree): Remove.
* call.c (non_reference): Remove.
(build_scoped_method_call): Likewise.
(build_method_call): Use error_operand_p. Assert that we are not
processing a template.
(standard_conversion): Use non_reference.
* class.c (build_vtbl_entry_ref): Likewise.
(build_vtbl_ref_1): Likewise.
* cvt.c (build_expr_type_conversion): Use non_reference.
* decl.c (lookup_qualified_name): Remove flags parameter.
(grok_op_properties): Use non_reference.
* decl2.c (grok_array_decl): Likewise.
(build_expr_from_tree): Remove.
(build_offset_ref_call_from_tree): Update comment.
* error.c (parm_to_string): Call reinit_global_formatting_buffer.
* except.c (prepare_eh_types): Use non_reference.
(can_convert_eh): Likewise.
* init.c (build_dtor_call): Avoid using build_method_call.
* mangle.c (write_template_param): Remove misleading comment.
* method.c (locate_copy): Use non_reference.
* parser.c (cp_parser_scope_through_which_access_occurs): Remove.
(cp_parser_primary_expression): Do not create SCOPE_REFs is
non-dependent contexts.
(cp_parser_postfix_expression): Use finish_qualified_id_expr.
(cp_parser_direct_declarator): Use tsubst_copy_and_build, not
build_expr_from_tree.
(cp_parser_lookup_name): Adjust call to lookup_qualified_name.
Use check_accessibility_of_qualified_id.
* pt.c (maybe_fold_nontype_arg): Use tsubst_copy_and_build, not
build_expr_from_tree.
(tsubst_baselink): New function.
(tsubst_qualified_id): Likewise.
(tsubst_copy): Use them. Remove support for METHOD_CALL_EXPR.
(tsubst_expr): Adjust call to lookup_qualified_name.
(tsubst_copy_and_build): Handle SCOPE_REFs specially. Adjust
handling of CALL_EXPRs.
(value_dependent_expression_p): Use INTEGRAL_OR_ENUMERATION_TYPE_P.
* rtti.c (get_tinfo_decl_dynamic): Use non_reference.
* search.c (check_final_overrider): Likewise.
* semantics.c (check_accessibility_of_qualified_id): New function.
(finish_qualified_object_call_expr): Remove.
* typeck.c (target_type): Use non_reference.
(cxx_sizeof_or_alignof_type): Likewise.
(dubious_conversion_warnings): Likewise.
(convert_for_initialization): Likewise.
(non_reference): New function.
From-SVN: r69063
Diffstat (limited to 'gcc/cp/decl2.c')
-rw-r--r-- | gcc/cp/decl2.c | 426 |
1 files changed, 3 insertions, 423 deletions
diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 39f6ca5..7158f10 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -409,8 +409,7 @@ grok_array_decl (tree array_expr, tree index_exp) my_friendly_assert (type, 20030626); - if (TREE_CODE (type) == REFERENCE_TYPE) - type = TREE_TYPE (type); + type = non_reference (type); /* If they have an `operator[]', use that. */ if (IS_AGGR_TYPE (type) || IS_AGGR_TYPE (TREE_TYPE (index_exp))) @@ -2938,415 +2937,6 @@ finish_file () input_location = locus; } -/* T is the parse tree for an expression. Return the expression after - performing semantic analysis. */ - -tree -build_expr_from_tree (tree t) -{ - if (t == NULL_TREE || t == error_mark_node) - return t; - - switch (TREE_CODE (t)) - { - case IDENTIFIER_NODE: - return do_identifier (t, NULL_TREE); - - case LOOKUP_EXPR: - if (LOOKUP_EXPR_GLOBAL (t)) - { - tree token = TREE_OPERAND (t, 0); - return do_scoped_id (token, IDENTIFIER_GLOBAL_VALUE (token)); - } - else - { - t = do_identifier (TREE_OPERAND (t, 0), NULL_TREE); - if (TREE_CODE (t) == ALIAS_DECL) - t = DECL_INITIAL (t); - return t; - } - - case TEMPLATE_ID_EXPR: - { - tree template; - tree args; - tree object; - - template = build_expr_from_tree (TREE_OPERAND (t, 0)); - args = build_expr_from_tree (TREE_OPERAND (t, 1)); - - if (TREE_CODE (template) == COMPONENT_REF) - { - object = TREE_OPERAND (template, 0); - template = TREE_OPERAND (template, 1); - } - else - object = NULL_TREE; - - template = lookup_template_function (template, args); - if (object) - return build (COMPONENT_REF, TREE_TYPE (template), - object, template); - else - return template; - } - - case INDIRECT_REF: - return build_x_indirect_ref - (build_expr_from_tree (TREE_OPERAND (t, 0)), "unary *"); - - case CAST_EXPR: - return build_functional_cast - (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0))); - - case REINTERPRET_CAST_EXPR: - return build_reinterpret_cast - (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0))); - - case CONST_CAST_EXPR: - return build_const_cast - (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0))); - - case DYNAMIC_CAST_EXPR: - return build_dynamic_cast - (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0))); - - case STATIC_CAST_EXPR: - return build_static_cast - (TREE_TYPE (t), build_expr_from_tree (TREE_OPERAND (t, 0))); - - case PREDECREMENT_EXPR: - case PREINCREMENT_EXPR: - case POSTDECREMENT_EXPR: - case POSTINCREMENT_EXPR: - case NEGATE_EXPR: - case BIT_NOT_EXPR: - case ABS_EXPR: - case TRUTH_NOT_EXPR: - case ADDR_EXPR: - case CONVERT_EXPR: /* Unary + */ - case REALPART_EXPR: - case IMAGPART_EXPR: - if (TREE_TYPE (t)) - return t; - return build_x_unary_op (TREE_CODE (t), - build_expr_from_tree (TREE_OPERAND (t, 0))); - - case PLUS_EXPR: - case MINUS_EXPR: - case MULT_EXPR: - case TRUNC_DIV_EXPR: - case CEIL_DIV_EXPR: - case FLOOR_DIV_EXPR: - case ROUND_DIV_EXPR: - case EXACT_DIV_EXPR: - case BIT_AND_EXPR: - case BIT_ANDTC_EXPR: - case BIT_IOR_EXPR: - case BIT_XOR_EXPR: - case TRUNC_MOD_EXPR: - case FLOOR_MOD_EXPR: - case TRUTH_ANDIF_EXPR: - case TRUTH_ORIF_EXPR: - case TRUTH_AND_EXPR: - case TRUTH_OR_EXPR: - case RSHIFT_EXPR: - case LSHIFT_EXPR: - case RROTATE_EXPR: - case LROTATE_EXPR: - case EQ_EXPR: - case NE_EXPR: - case MAX_EXPR: - case MIN_EXPR: - case LE_EXPR: - case GE_EXPR: - case LT_EXPR: - case GT_EXPR: - case MEMBER_REF: - return build_x_binary_op - (TREE_CODE (t), - build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1))); - - case DOTSTAR_EXPR: - return build_m_component_ref - (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1))); - - case SCOPE_REF: - return build_offset_ref (TREE_OPERAND (t, 0), TREE_OPERAND (t, 1)); - - case ARRAY_REF: - if (TREE_OPERAND (t, 0) == NULL_TREE) - /* new-type-id */ - return build_nt (ARRAY_REF, NULL_TREE, - build_expr_from_tree (TREE_OPERAND (t, 1))); - return grok_array_decl (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1))); - - case SIZEOF_EXPR: - case ALIGNOF_EXPR: - { - tree r = build_expr_from_tree (TREE_OPERAND (t, 0)); - if (!TYPE_P (r)) - return TREE_CODE (t) == SIZEOF_EXPR ? expr_sizeof (r) : c_alignof_expr (r); - else - return cxx_sizeof_or_alignof_type (r, TREE_CODE (t), true); - } - - case MODOP_EXPR: - return build_x_modify_expr - (build_expr_from_tree (TREE_OPERAND (t, 0)), - TREE_CODE (TREE_OPERAND (t, 1)), - build_expr_from_tree (TREE_OPERAND (t, 2))); - - case ARROW_EXPR: - return build_x_arrow - (build_expr_from_tree (TREE_OPERAND (t, 0))); - - case NEW_EXPR: - return build_new - (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1)), - build_expr_from_tree (TREE_OPERAND (t, 2)), - NEW_EXPR_USE_GLOBAL (t)); - - case DELETE_EXPR: - return delete_sanity - (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1)), - DELETE_EXPR_USE_VEC (t), DELETE_EXPR_USE_GLOBAL (t)); - - case COMPOUND_EXPR: - if (TREE_OPERAND (t, 1) == NULL_TREE) - return build_x_compound_expr - (build_expr_from_tree (TREE_OPERAND (t, 0))); - else - abort (); - - case METHOD_CALL_EXPR: - if (TREE_CODE (TREE_OPERAND (t, 0)) == SCOPE_REF) - { - tree ref = TREE_OPERAND (t, 0); - tree name = TREE_OPERAND (ref, 1); - - if (TREE_CODE (name) == TEMPLATE_ID_EXPR) - name = build_nt (TEMPLATE_ID_EXPR, - TREE_OPERAND (name, 0), - build_expr_from_tree (TREE_OPERAND (name, 1))); - - return build_scoped_method_call - (build_expr_from_tree (TREE_OPERAND (t, 1)), - build_expr_from_tree (TREE_OPERAND (ref, 0)), - name, - build_expr_from_tree (TREE_OPERAND (t, 2))); - } - else - { - tree fn = TREE_OPERAND (t, 0); - - /* We can get a TEMPLATE_ID_EXPR here on code like: - - x->f<2>(); - - so we must resolve that. However, we can also get things - like a BIT_NOT_EXPR here, when referring to a destructor, - and things like that are not correctly resolved by - build_expr_from_tree. So, just use build_expr_from_tree - when we really need it. */ - if (TREE_CODE (fn) == TEMPLATE_ID_EXPR) - fn = lookup_template_function - (TREE_OPERAND (fn, 0), - build_expr_from_tree (TREE_OPERAND (fn, 1))); - - return build_method_call - (build_expr_from_tree (TREE_OPERAND (t, 1)), - fn, - build_expr_from_tree (TREE_OPERAND (t, 2)), - NULL_TREE, LOOKUP_NORMAL); - } - - case CALL_EXPR: - if (TREE_CODE (TREE_OPERAND (t, 0)) == SCOPE_REF) - { - tree ref = TREE_OPERAND (t, 0); - tree name = TREE_OPERAND (ref, 1); - tree fn, scope, args; - - if (TREE_CODE (name) == TEMPLATE_ID_EXPR) - name = build_nt (TEMPLATE_ID_EXPR, - TREE_OPERAND (name, 0), - build_expr_from_tree (TREE_OPERAND (name, 1))); - - scope = build_expr_from_tree (TREE_OPERAND (ref, 0)); - args = build_expr_from_tree (TREE_OPERAND (t, 1)); - fn = resolve_scoped_fn_name (scope, name); - - return build_call_from_tree (fn, args, 1); - } - else - { - tree name = TREE_OPERAND (t, 0); - tree id; - tree args = build_expr_from_tree (TREE_OPERAND (t, 1)); - if (args != NULL_TREE && TREE_CODE (name) == LOOKUP_EXPR - && !LOOKUP_EXPR_GLOBAL (name) - && TREE_CODE ((id = TREE_OPERAND (name, 0))) == IDENTIFIER_NODE - && (!current_class_type - || !lookup_member (current_class_type, id, 0, false))) - { - /* Do Koenig lookup if there are no class members. */ - name = do_identifier (id, args); - } - else if (TREE_CODE (name) == TEMPLATE_ID_EXPR - || ! really_overloaded_fn (name)) - name = build_expr_from_tree (name); - - if (TREE_CODE (name) == OFFSET_REF) - return build_offset_ref_call_from_tree (name, args); - if (TREE_CODE (name) == COMPONENT_REF) - return finish_object_call_expr (TREE_OPERAND (name, 1), - TREE_OPERAND (name, 0), - args); - name = convert_from_reference (name); - return build_call_from_tree (name, args, - /*disallow_virtual=*/false); - } - - case COND_EXPR: - return build_x_conditional_expr - (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1)), - build_expr_from_tree (TREE_OPERAND (t, 2))); - - case PSEUDO_DTOR_EXPR: - return (finish_pseudo_destructor_expr - (build_expr_from_tree (TREE_OPERAND (t, 0)), - build_expr_from_tree (TREE_OPERAND (t, 1)), - build_expr_from_tree (TREE_OPERAND (t, 2)))); - - case TREE_LIST: - { - tree purpose, value, chain; - - if (t == void_list_node) - return t; - - purpose = TREE_PURPOSE (t); - if (purpose) - purpose = build_expr_from_tree (purpose); - value = TREE_VALUE (t); - if (value) - value = build_expr_from_tree (value); - chain = TREE_CHAIN (t); - if (chain && chain != void_type_node) - chain = build_expr_from_tree (chain); - return tree_cons (purpose, value, chain); - } - - case COMPONENT_REF: - { - tree object = build_expr_from_tree (TREE_OPERAND (t, 0)); - tree member = TREE_OPERAND (t, 1); - - if (!CLASS_TYPE_P (TREE_TYPE (object))) - { - if (TREE_CODE (member) == BIT_NOT_EXPR) - return finish_pseudo_destructor_expr (object, - NULL_TREE, - TREE_TYPE (object)); - else if (TREE_CODE (member) == SCOPE_REF - && (TREE_CODE (TREE_OPERAND (member, 1)) == BIT_NOT_EXPR)) - return finish_pseudo_destructor_expr (object, - TREE_OPERAND (t, 0), - TREE_TYPE (object)); - } - else if (TREE_CODE (member) == SCOPE_REF - && TREE_CODE (TREE_OPERAND (member, 1)) == TEMPLATE_ID_EXPR) - { - tree tmpl; - tree args; - - /* Lookup the template functions now that we know what the - scope is. */ - tmpl = TREE_OPERAND (TREE_OPERAND (member, 1), 0); - args = TREE_OPERAND (TREE_OPERAND (member, 1), 1); - member = lookup_qualified_name (TREE_OPERAND (member, 0), - tmpl, - /*is_type=*/0, - /*flags=*/0); - if (BASELINK_P (member)) - BASELINK_FUNCTIONS (member) - = build_nt (TEMPLATE_ID_EXPR, BASELINK_FUNCTIONS (member), - args); - else - { - error ("`%D' is not a member of `%T'", - tmpl, TREE_TYPE (object)); - return error_mark_node; - } - } - - - return finish_class_member_access_expr (object, member); - } - - case THROW_EXPR: - return build_throw (build_expr_from_tree (TREE_OPERAND (t, 0))); - - case CONSTRUCTOR: - { - tree r; - tree elts; - tree type = TREE_TYPE (t); - bool purpose_p; - - /* digest_init will do the wrong thing if we let it. */ - if (type && TYPE_PTRMEMFUNC_P (type)) - return t; - - r = NULL_TREE; - /* We do not want to process the purpose of aggregate - initializers as they are identifier nodes which will be - looked up by digest_init. */ - purpose_p = !(type && IS_AGGR_TYPE (type)); - for (elts = CONSTRUCTOR_ELTS (t); elts; elts = TREE_CHAIN (elts)) - { - tree purpose = TREE_PURPOSE (elts); - tree value = TREE_VALUE (elts); - - if (purpose && purpose_p) - purpose = build_expr_from_tree (purpose); - value = build_expr_from_tree (value); - r = tree_cons (purpose, value, r); - } - - r = build_constructor (NULL_TREE, nreverse (r)); - TREE_HAS_CONSTRUCTOR (r) = TREE_HAS_CONSTRUCTOR (t); - - if (type) - return digest_init (type, r, 0); - return r; - } - - case TYPEID_EXPR: - if (TYPE_P (TREE_OPERAND (t, 0))) - return get_typeid (TREE_OPERAND (t, 0)); - return build_typeid (build_expr_from_tree (TREE_OPERAND (t, 0))); - - case PARM_DECL: - case VAR_DECL: - return convert_from_reference (t); - - case VA_ARG_EXPR: - return build_va_arg (build_expr_from_tree (TREE_OPERAND (t, 0)), - TREE_TYPE (t)); - - default: - return t; - } -} - /* FN is an OFFSET_REF indicating the function to call in parse-tree form; it has not yet been semantically analyzed. ARGS are the arguments to the function. They have already been semantically @@ -3359,22 +2949,12 @@ build_offset_ref_call_from_tree (tree fn, tree args) my_friendly_assert (TREE_CODE (fn) == OFFSET_REF, 20020725); - /* A qualified name corresponding to a non-static member - function or a pointer-to-member is represented as an - OFFSET_REF. - - For both of these function calls, FN will be an OFFSET_REF. - - struct A { void f(); }; - void A::f() { (A::f) (); } + /* A qualified name corresponding to a bound pointer-to-member is + represented as an OFFSET_REF: struct B { void g(); }; void (B::*p)(); void B::g() { (this->*p)(); } */ - - /* This code is not really correct (for example, it does not - handle the case that `A::f' is overloaded), but it is - historically how we have handled this situation. */ if (TREE_CODE (TREE_OPERAND (fn, 1)) == FIELD_DECL) /* This case should now be handled elsewhere. */ abort (); |