From: Nathan Sidwell Date: Fri, 16 Jun 2017 18:38:28 +0000 (+0000) Subject: * pt.c (tsubst_baselink): Fix & clarify formatting. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4086ef7d8979cf55a8908a3a100f2c2b9377f295;p=gcc.git * pt.c (tsubst_baselink): Fix & clarify formatting. From-SVN: r249273 --- diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 11f2d03ef5f..ce1e8d09c77 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,7 @@ 2017-06-16 Nathan Sidwell + * pt.c (tsubst_baselink): Fix & clarify formatting. + * cp-tree.h (build_this_parm, cp_build_parm_decl, build_artificial_parm): Add FN parm. * decl.c (start_cleanup_fn): Adjust. diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c index 91b98d4de9f..3dad0fc6741 100644 --- a/gcc/cp/pt.c +++ b/gcc/cp/pt.c @@ -14215,93 +14215,89 @@ tsubst (tree t, tree args, tsubst_flags_t complain, tree in_decl) } } -/* Like tsubst_expr for a BASELINK. OBJECT_TYPE, if non-NULL, is the - type of the expression on the left-hand side of the "." or "->" - operator. */ +/* tsubst a BASELINK. OBJECT_TYPE, if non-NULL, is the type of the + expression on the left-hand side of the "." or "->" operator. A + baselink indicates a function from a base class. Both the + BASELINK_ACCESS_BINFO and the base class referenced may indicate + bases of the template class, rather than the instantiated class. + In addition, lookups that were not ambiguous before may be + ambiguous now. Therefore, we perform the lookup again. */ static tree tsubst_baselink (tree baselink, tree object_type, tree args, tsubst_flags_t complain, tree in_decl) { - tree name; - tree qualifying_scope; - tree fns; - tree optype; - tree template_args = 0; - bool template_id_p = false; - bool qualified = BASELINK_QUALIFIED_P (baselink); - - /* A baselink indicates a function from a base class. Both the - BASELINK_ACCESS_BINFO and the base class referenced may - indicate bases of the template class, rather than the - instantiated class. In addition, lookups that were not - ambiguous before may be ambiguous now. Therefore, we perform - the lookup again. */ - qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink)); - qualifying_scope = tsubst (qualifying_scope, args, - complain, in_decl); - fns = BASELINK_FUNCTIONS (baselink); - optype = tsubst (BASELINK_OPTYPE (baselink), args, complain, in_decl); - if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) - { - template_id_p = true; - template_args = TREE_OPERAND (fns, 1); - fns = TREE_OPERAND (fns, 0); - if (template_args) - template_args = tsubst_template_args (template_args, args, - complain, in_decl); - } - name = OVL_NAME (fns); - if (IDENTIFIER_TYPENAME_P (name)) - name = mangle_conv_op_name_for_type (optype); - baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1); - if (!baselink) - { - if (constructor_name_p (name, qualifying_scope)) - { - if (complain & tf_error) - error ("cannot call constructor %<%T::%D%> directly", - qualifying_scope, name); - } - return error_mark_node; - } + bool qualified = BASELINK_QUALIFIED_P (baselink); + + tree qualifying_scope = BINFO_TYPE (BASELINK_ACCESS_BINFO (baselink)); + qualifying_scope = tsubst (qualifying_scope, args, complain, in_decl); + + tree optype = BASELINK_OPTYPE (baselink); + optype = tsubst (optype, args, complain, in_decl); + + tree template_args = NULL_TREE; + bool template_id_p = false; + tree fns = BASELINK_FUNCTIONS (baselink); + if (TREE_CODE (fns) == TEMPLATE_ID_EXPR) + { + template_id_p = true; + template_args = TREE_OPERAND (fns, 1); + fns = TREE_OPERAND (fns, 0); + if (template_args) + template_args = tsubst_template_args (template_args, args, + complain, in_decl); + } - /* If lookup found a single function, mark it as used at this - point. (If it lookup found multiple functions the one selected - later by overload resolution will be marked as used at that - point.) */ - if (BASELINK_P (baselink)) - fns = BASELINK_FUNCTIONS (baselink); - if (!template_id_p && !really_overloaded_fn (fns) - && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error)) + tree name = OVL_NAME (fns); + if (IDENTIFIER_TYPENAME_P (name)) + name = mangle_conv_op_name_for_type (optype); + + baselink = lookup_fnfields (qualifying_scope, name, /*protect=*/1); + if (!baselink) + { + if ((complain & tf_error) && constructor_name_p (name, qualifying_scope)) + error ("cannot call constructor %<%T::%D%> directly", + qualifying_scope, name); return error_mark_node; + } + + /* If lookup found a single function, mark it as used at this point. + (If it lookup found multiple functions the one selected later by + overload resolution will be marked as used at that point.) */ + if (BASELINK_P (baselink)) + fns = BASELINK_FUNCTIONS (baselink); + if (!template_id_p && !really_overloaded_fn (fns) + && !mark_used (OVL_FIRST (fns), complain) && !(complain & tf_error)) + return error_mark_node; - /* Add back the template arguments, if present. */ - if (BASELINK_P (baselink) && template_id_p) - BASELINK_FUNCTIONS (baselink) - = build2 (TEMPLATE_ID_EXPR, - unknown_type_node, - BASELINK_FUNCTIONS (baselink), - template_args); - /* Update the conversion operator type. */ - if (BASELINK_P (baselink)) + if (BASELINK_P (baselink)) + { + /* Add back the template arguments, if present. */ + if (template_id_p) + BASELINK_FUNCTIONS (baselink) + = build2 (TEMPLATE_ID_EXPR, unknown_type_node, + BASELINK_FUNCTIONS (baselink), template_args); + + /* Update the conversion operator type. */ BASELINK_OPTYPE (baselink) = optype; + } - if (!object_type) - object_type = current_class_type; + if (!object_type) + object_type = current_class_type; - if (qualified || name == complete_dtor_identifier) - { - baselink = adjust_result_of_qualified_name_lookup (baselink, - qualifying_scope, - object_type); - if (!qualified) - /* We need to call adjust_result_of_qualified_name_lookup in case the - destructor names a base class, but we unset BASELINK_QUALIFIED_P - so that we still get virtual function binding. */ - BASELINK_QUALIFIED_P (baselink) = false; - } - return baselink; + if (qualified || name == complete_dtor_identifier) + { + baselink = adjust_result_of_qualified_name_lookup (baselink, + qualifying_scope, + object_type); + if (!qualified) + /* We need to call adjust_result_of_qualified_name_lookup in case the + destructor names a base class, but we unset BASELINK_QUALIFIED_P + so that we still get virtual function binding. */ + BASELINK_QUALIFIED_P (baselink) = false; + } + + return baselink; } /* Like tsubst_expr for a SCOPE_REF, given by QUALIFIED_ID. DONE is