diff options
author | Nathan Sidwell <nathan@acm.org> | 2017-10-31 14:39:44 +0000 |
---|---|---|
committer | Nathan Sidwell <nathan@gcc.gnu.org> | 2017-10-31 14:39:44 +0000 |
commit | 88a819bee1d2286c8b8c742aa8ac79eda8a9c204 (patch) | |
tree | dc1df4321c6847d88a2b11efff77e2d138f03f45 | |
parent | f6a35e8954606007940045101284fbd7c251ed76 (diff) | |
download | gcc-88a819bee1d2286c8b8c742aa8ac79eda8a9c204.zip gcc-88a819bee1d2286c8b8c742aa8ac79eda8a9c204.tar.gz gcc-88a819bee1d2286c8b8c742aa8ac79eda8a9c204.tar.bz2 |
[C++ PATCH] overloaded operator fns [2/N]
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg02326.html
gcc/cp/
* cp-tree.h (ovl_op_identifier): New.
(assign_op_identifier, call_op_identifier): Adjust.
(cp_operator_id, cp_assignment_operator_ide): Delete.
(SET_OVERLOADED_OPERATOR_CODE): Delete.
(OVL_OP_INFO): New.
* call.c (op_error): Use OVL_OP_INFO.
(build_conditional_expr_1): Use ovl_op_identifier.
(build_new_op_1): Use OVL_OP_INFO & ovl_op_identifier.
(build_op_delete_call): Likewise.
* class.c (type_requires_array_cookie): Use ovl_op_identifier.
* decl.c (duplicate_decls): Directly copy operator code.
(builtin_function_1): Do not set operator code.
(build_library_fn): Directly set operator code.
(push_cp_library_fn): Use ovl_op_identifier.
(grok_op_properties): Directly set operator code.
* decl2.c (maybe_warn_sized_delete): Use ovl_op_identifier.
* error.c (dump_expr): Use OVL_OP_INFO.
(op_to_string): Add assop arg. Use OVL_OP_INFO.
(assop_to_string): Delete.
(args_to_string): Adjust.
* init.c (build_new_1): Use ovl_op_identifier.
* mangle.c (write_unqualified_name): Use OVL_OP_INFO.
(write_expression): Likewise.
* method.c (synthesized_method_walk): Use ovl_op_identifier.
(implicitly_declare_fn): Use assign_op_identifier. Directly set
operator code.
* name-lookup.c (get_class_binding): Use assign_op_identifier.
* parser.c (cp_parser_operator): Use ovl_op_identifier.
(cp_parser_omp_clause_reduction): Likewise.
* semantics.c (omp_reduction_id): Likewise.
* typeck.c (cxx_sizeof_or_alignof_type): Use OVL_OP_INFO.
libcc1/
* libcp1plugin.cc (plugin_build_decl): Use ovl_op_identifier.
Directly set operator code.
(plugin_build_dependent_expr): Use ovl_op_identifier.
From-SVN: r254267
-rw-r--r-- | gcc/cp/ChangeLog | 32 | ||||
-rw-r--r-- | gcc/cp/call.c | 24 | ||||
-rw-r--r-- | gcc/cp/class.c | 2 | ||||
-rw-r--r-- | gcc/cp/cp-tree.h | 26 | ||||
-rw-r--r-- | gcc/cp/decl.c | 16 | ||||
-rw-r--r-- | gcc/cp/decl2.c | 2 | ||||
-rw-r--r-- | gcc/cp/error.c | 29 | ||||
-rw-r--r-- | gcc/cp/init.c | 2 | ||||
-rw-r--r-- | gcc/cp/mangle.c | 27 | ||||
-rw-r--r-- | gcc/cp/method.c | 8 | ||||
-rw-r--r-- | gcc/cp/name-lookup.c | 2 | ||||
-rw-r--r-- | gcc/cp/parser.c | 18 | ||||
-rw-r--r-- | gcc/cp/semantics.c | 2 | ||||
-rw-r--r-- | gcc/cp/typeck.c | 2 | ||||
-rw-r--r-- | libcc1/ChangeLog | 6 | ||||
-rw-r--r-- | libcc1/libcp1plugin.cc | 35 |
16 files changed, 114 insertions, 119 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 7ab9cf3..cca3a4b 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,37 @@ 2017-10-31 Nathan Sidwell <nathan@acm.org> + * cp-tree.h (ovl_op_identifier): New. + (assign_op_identifier, call_op_identifier): Adjust. + (cp_operator_id, cp_assignment_operator_ide): Delete. + (SET_OVERLOADED_OPERATOR_CODE): Delete. + (OVL_OP_INFO): New. + * call.c (op_error): Use OVL_OP_INFO. + (build_conditional_expr_1): Use ovl_op_identifier. + (build_new_op_1): Use OVL_OP_INFO & ovl_op_identifier. + (build_op_delete_call): Likewise. + * class.c (type_requires_array_cookie): Use ovl_op_identifier. + * decl.c (duplicate_decls): Directly copy operator code. + (builtin_function_1): Do not set operator code. + (build_library_fn): Directly set operator code. + (push_cp_library_fn): Use ovl_op_identifier. + (grok_op_properties): Directly set operator code. + * decl2.c (maybe_warn_sized_delete): Use ovl_op_identifier. + * error.c (dump_expr): Use OVL_OP_INFO. + (op_to_string): Add assop arg. Use OVL_OP_INFO. + (assop_to_string): Delete. + (args_to_string): Adjust. + * init.c (build_new_1): Use ovl_op_identifier. + * mangle.c (write_unqualified_name): Use OVL_OP_INFO. + (write_expression): Likewise. + * method.c (synthesized_method_walk): Use ovl_op_identifier. + (implicitly_declare_fn): Use assign_op_identifier. Directly set + operator code. + * name-lookup.c (get_class_binding): Use assign_op_identifier. + * parser.c (cp_parser_operator): Use ovl_op_identifier. + (cp_parser_omp_clause_reduction): Likewise. + * semantics.c (omp_reduction_id): Likewise. + * typeck.c (cxx_sizeof_or_alignof_type): Use OVL_OP_INFO. + * cp-tree.h (assign_op_identifier, call_op_identifier): Define. (LAMBDA_FUNCTION_P): Use DECL_OVERLOADED_OPERATOR_IS. (DECL_OVERLOADED_OPERATOR_P): Just retuurn true/false. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index d899d45..6875492 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -4620,12 +4620,8 @@ static void op_error (location_t loc, enum tree_code code, enum tree_code code2, tree arg1, tree arg2, tree arg3, bool match) { - const char *opname; - - if (code == MODIFY_EXPR) - opname = assignment_operator_name_info[code2].name; - else - opname = operator_name_info[code].name; + bool assop = code == MODIFY_EXPR; + const char *opname = OVL_OP_INFO (assop, assop ? code2 : code)->name; switch (code) { @@ -5184,7 +5180,7 @@ build_conditional_expr_1 (location_t loc, tree arg1, tree arg2, tree arg3, add_builtin_candidates (&candidates, COND_EXPR, NOP_EXPR, - cp_operator_id (COND_EXPR), + ovl_op_identifier (false, COND_EXPR), args, LOOKUP_NORMAL, complain); @@ -5574,7 +5570,6 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, { struct z_candidate *candidates = 0, *cand; vec<tree, va_gc> *arglist; - tree fnname; tree args[3]; tree result = NULL_TREE; bool result_valid_p = false; @@ -5591,14 +5586,13 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, || error_operand_p (arg3)) return error_mark_node; - if (code == MODIFY_EXPR) + bool ismodop = code == MODIFY_EXPR; + if (ismodop) { code2 = TREE_CODE (arg3); arg3 = NULL_TREE; - fnname = cp_assignment_operator_id (code2); } - else - fnname = cp_operator_id (code); + tree fnname = ovl_op_identifier (ismodop, ismodop ? code2 : code); arg1 = prep_operand (arg1); @@ -5793,7 +5787,7 @@ build_new_op_1 (location_t loc, enum tree_code code, int flags, tree arg1, ? G_("no %<%D(int)%> declared for postfix %qs," " trying prefix operator instead") : G_("no %<%D(int)%> declared for postfix %qs"); - permerror (loc, msg, fnname, operator_name_info[code].name); + permerror (loc, msg, fnname, OVL_OP_INFO (false, code)->name); } if (!flag_permissive) @@ -6205,7 +6199,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, type = strip_array_types (TREE_TYPE (TREE_TYPE (addr))); - fnname = cp_operator_id (code); + fnname = ovl_op_identifier (false, code); if (CLASS_TYPE_P (type) && COMPLETE_TYPE_P (complete_type (type)) @@ -6434,7 +6428,7 @@ build_op_delete_call (enum tree_code code, tree addr, tree size, if (complain & tf_error) error ("no suitable %<operator %s%> for %qT", - operator_name_info[(int)code].name, type); + OVL_OP_INFO (false, code)->name, type); return error_mark_node; } diff --git a/gcc/cp/class.c b/gcc/cp/class.c index 96009df..9755f18 100644 --- a/gcc/cp/class.c +++ b/gcc/cp/class.c @@ -5304,7 +5304,7 @@ type_requires_array_cookie (tree type) the array to the deallocation function, so we will need to store a cookie. */ fns = lookup_fnfields (TYPE_BINFO (type), - cp_operator_id (VEC_DELETE_EXPR), + ovl_op_identifier (false, VEC_DELETE_EXPR), /*protect=*/0); /* If there are no `operator []' members, or the lookup is ambiguous, then we don't need a cookie. */ diff --git a/gcc/cp/cp-tree.h b/gcc/cp/cp-tree.h index 9c183a7..a9b2304 100644 --- a/gcc/cp/cp-tree.h +++ b/gcc/cp/cp-tree.h @@ -245,24 +245,14 @@ extern GTY(()) tree cp_global_trees[CPTI_MAX]; then deletes the entire object. */ #define deleting_dtor_identifier cp_global_trees[CPTI_DELETING_DTOR_IDENTIFIER] -#define assign_op_identifier (cp_assignment_operator_id (NOP_EXPR)) -#define call_op_identifier (cp_operator_id (CALL_EXPR)) +#define ovl_op_identifier(ISASS, CODE) (OVL_OP_INFO(ISASS, CODE)->identifier) +#define assign_op_identifier (ovl_op_identifier (true, NOP_EXPR)) +#define call_op_identifier (ovl_op_identifier (false, CALL_EXPR)) /* The name used for conversion operators -- but note that actual conversion functions use special identifiers outside the identifier table. */ #define conv_op_identifier cp_global_trees[CPTI_CONV_OP_IDENTIFIER] -/* The name of the identifier used internally to represent operator CODE. */ -#define cp_operator_id(CODE) \ - (operator_name_info[(int) (CODE)].identifier) - -/* The name of the identifier used to represent assignment operator CODE, - both simple (i.e., operator= with CODE == NOP_EXPR) and compound (e.g., - operator+= with CODE == PLUS_EXPR). Includes copy and move assignment. - Use copy_fn_p() to test specifically for copy assignment. */ -#define cp_assignment_operator_id(CODE) \ - (assignment_operator_name_info[(int) (CODE)].identifier) - #define delta_identifier cp_global_trees[CPTI_DELTA_IDENTIFIER] #define in_charge_identifier cp_global_trees[CPTI_IN_CHARGE_IDENTIFIER] /* The name of the parameter that contains a pointer to the VTT to use @@ -2810,10 +2800,6 @@ struct GTY(()) lang_decl { #define SET_VAR_HAD_UNKNOWN_BOUND(NODE) \ (DECL_LANG_SPECIFIC (VAR_DECL_CHECK (NODE))->u.base.unknown_bound_p = true) -/* Set the overloaded operator code for NODE to CODE. */ -#define SET_OVERLOADED_OPERATOR_CODE(NODE, CODE) \ - (LANG_DECL_FN_CHECK (NODE)->operator_code = (CODE)) - /* True iff decl NODE is for an overloaded operator. */ #define DECL_OVERLOADED_OPERATOR_P(NODE) \ IDENTIFIER_ANY_OP_P (DECL_NAME (NODE)) @@ -5506,6 +5492,12 @@ extern GTY(()) operator_name_info_t operator_name_info extern GTY(()) operator_name_info_t assignment_operator_name_info [(int) MAX_TREE_CODES]; +/* Given an ass_op_p boolean and a tree code, return a pointer to its + overloaded operator info. */ +#define OVL_OP_INFO(IS_ASS_P, TREE_CODE) \ + (((IS_ASS_P) ? assignment_operator_name_info : operator_name_info) \ + + (TREE_CODE)) + /* A type-qualifier, or bitmask therefore, using the TYPE_QUAL constants. */ diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a983adf..82d9326 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -1922,8 +1922,8 @@ next_arg:; DECL_OVERRIDE_P (newdecl) |= DECL_OVERRIDE_P (olddecl); DECL_THIS_STATIC (newdecl) |= DECL_THIS_STATIC (olddecl); if (DECL_OVERLOADED_OPERATOR_P (olddecl)) - SET_OVERLOADED_OPERATOR_CODE - (newdecl, DECL_OVERLOADED_OPERATOR_CODE (olddecl)); + DECL_OVERLOADED_OPERATOR_CODE (newdecl) + = DECL_OVERLOADED_OPERATOR_CODE (olddecl); new_defines_function = DECL_INITIAL (newdecl) != NULL_TREE; /* Optionally warn about more than one declaration for the same @@ -4359,7 +4359,6 @@ builtin_function_1 (tree decl, tree context, bool is_global) retrofit_lang_decl (decl); DECL_ARTIFICIAL (decl) = 1; - SET_OVERLOADED_OPERATOR_CODE (decl, ERROR_MARK); SET_DECL_LANGUAGE (decl, lang_c); /* Runtime library routines are, by definition, available in an external shared object. */ @@ -4447,7 +4446,7 @@ build_library_fn (tree name, enum tree_code operator_code, tree type, DECL_EXTERNAL (fn) = 1; TREE_PUBLIC (fn) = 1; DECL_ARTIFICIAL (fn) = 1; - SET_OVERLOADED_OPERATOR_CODE (fn, operator_code); + DECL_OVERLOADED_OPERATOR_CODE (fn) = operator_code; SET_DECL_LANGUAGE (fn, lang_c); /* Runtime library routines are, by definition, available in an external shared object. */ @@ -4512,9 +4511,8 @@ static tree push_cp_library_fn (enum tree_code operator_code, tree type, int ecf_flags) { - tree fn = build_cp_library_fn (cp_operator_id (operator_code), - operator_code, - type, ecf_flags); + tree fn = build_cp_library_fn (ovl_op_identifier (false, operator_code), + operator_code, type, ecf_flags); pushdecl (fn); if (flag_tm) apply_tm_attr (fn, get_identifier ("transaction_safe")); @@ -12938,7 +12936,7 @@ grok_op_properties (tree decl, bool complain) } while (0); gcc_assert (operator_code != MAX_TREE_CODES); - SET_OVERLOADED_OPERATOR_CODE (decl, operator_code); + DECL_OVERLOADED_OPERATOR_CODE (decl) = operator_code; if (operator_code == NEW_EXPR || operator_code == VEC_NEW_EXPR || operator_code == DELETE_EXPR || operator_code == VEC_DELETE_EXPR) @@ -13111,7 +13109,7 @@ grok_op_properties (tree decl, bool complain) gcc_unreachable (); } - SET_OVERLOADED_OPERATOR_CODE (decl, operator_code); + DECL_OVERLOADED_OPERATOR_CODE (decl) = operator_code; if ((operator_code == POSTINCREMENT_EXPR || operator_code == POSTDECREMENT_EXPR) diff --git a/gcc/cp/decl2.c b/gcc/cp/decl2.c index 8035865..a23b96c 100644 --- a/gcc/cp/decl2.c +++ b/gcc/cp/decl2.c @@ -4455,7 +4455,7 @@ maybe_warn_sized_delete (enum tree_code code) tree sized = NULL_TREE; tree unsized = NULL_TREE; - for (ovl_iterator iter (get_global_binding (cp_operator_id (code))); + for (ovl_iterator iter (get_global_binding (ovl_op_identifier (false, code))); iter; ++iter) { tree fn = *iter; diff --git a/gcc/cp/error.c b/gcc/cp/error.c index 7a98d2e..2537713 100644 --- a/gcc/cp/error.c +++ b/gcc/cp/error.c @@ -50,13 +50,12 @@ static cxx_pretty_printer * const cxx_pp = &actual_pretty_printer; # define NEXT_CODE(T) (TREE_CODE (TREE_TYPE (T))) static const char *args_to_string (tree, int); -static const char *assop_to_string (enum tree_code); static const char *code_to_string (enum tree_code); static const char *cv_to_string (tree, int); static const char *decl_to_string (tree, int); static const char *expr_to_string (tree); static const char *fndecl_to_string (tree, int); -static const char *op_to_string (enum tree_code); +static const char *op_to_string (bool, enum tree_code); static const char *parm_to_string (int); static const char *type_to_string (tree, int); @@ -2230,8 +2229,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case INIT_EXPR: case MODIFY_EXPR: - dump_binary_op (pp, assignment_operator_name_info[NOP_EXPR].name, - t, flags); + dump_binary_op (pp, OVL_OP_INFO (true, NOP_EXPR)->name, t, flags); break; case PLUS_EXPR: @@ -2255,7 +2253,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case EQ_EXPR: case NE_EXPR: case EXACT_DIV_EXPR: - dump_binary_op (pp, operator_name_info[TREE_CODE (t)].name, t, flags); + dump_binary_op (pp, OVL_OP_INFO (false, TREE_CODE (t))->name, t, flags); break; case CEIL_DIV_EXPR: @@ -2386,14 +2384,14 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case TRUTH_NOT_EXPR: case PREDECREMENT_EXPR: case PREINCREMENT_EXPR: - dump_unary_op (pp, operator_name_info [TREE_CODE (t)].name, t, flags); + dump_unary_op (pp, OVL_OP_INFO (false, TREE_CODE (t))->name, t, flags); break; case POSTDECREMENT_EXPR: case POSTINCREMENT_EXPR: pp_cxx_left_paren (pp); dump_expr (pp, TREE_OPERAND (t, 0), flags | TFF_EXPR_IN_PARENS); - pp_cxx_ws_string (pp, operator_name_info[TREE_CODE (t)].name); + pp_cxx_ws_string (pp, OVL_OP_INFO (false, TREE_CODE (t))->name); pp_cxx_right_paren (pp); break; @@ -2656,7 +2654,7 @@ dump_expr (cxx_pretty_printer *pp, tree t, int flags) case REALPART_EXPR: case IMAGPART_EXPR: - pp_cxx_ws_string (pp, operator_name_info[TREE_CODE (t)].name); + pp_cxx_ws_string (pp, OVL_OP_INFO (false, TREE_CODE (t))->name); pp_cxx_whitespace (pp); dump_expr (pp, TREE_OPERAND (t, 0), flags); break; @@ -3136,9 +3134,9 @@ parm_to_string (int p) } static const char * -op_to_string (enum tree_code p) +op_to_string (bool assop, enum tree_code p) { - tree id = operator_name_info[p].identifier; + tree id = ovl_op_identifier (assop, p); return id ? IDENTIFIER_POINTER (id) : M_("<unknown>"); } @@ -3180,13 +3178,6 @@ type_to_string (tree typ, int verbose) } static const char * -assop_to_string (enum tree_code p) -{ - tree id = assignment_operator_name_info[(int) p].identifier; - return id ? IDENTIFIER_POINTER (id) : M_("{unknown}"); -} - -static const char * args_to_string (tree p, int verbose) { int flags = 0; @@ -4044,9 +4035,9 @@ cp_printer (pretty_printer *pp, text_info *text, const char *spec, case 'E': result = expr_to_string (next_tree); break; case 'F': result = fndecl_to_string (next_tree, verbose); break; case 'L': result = language_to_string (next_lang); break; - case 'O': result = op_to_string (next_tcode); break; + case 'O': result = op_to_string (false, next_tcode); break; case 'P': result = parm_to_string (next_int); break; - case 'Q': result = assop_to_string (next_tcode); break; + case 'Q': result = op_to_string (true, next_tcode); break; case 'S': result = subst_to_string (next_tree); break; case 'T': result = type_to_string (next_tree, verbose); break; case 'V': result = cv_to_string (next_tree, verbose); break; diff --git a/gcc/cp/init.c b/gcc/cp/init.c index ad30f24..9e6e3af 100644 --- a/gcc/cp/init.c +++ b/gcc/cp/init.c @@ -3055,7 +3055,7 @@ build_new_1 (vec<tree, va_gc> **placement, tree type, tree nelts, tree fnname; tree fns; - fnname = cp_operator_id (array_p ? VEC_NEW_EXPR : NEW_EXPR); + fnname = ovl_op_identifier (false, array_p ? VEC_NEW_EXPR : NEW_EXPR); member_new_p = !globally_qualified_p && CLASS_TYPE_P (elt_type) diff --git a/gcc/cp/mangle.c b/gcc/cp/mangle.c index d01e652..fe0aeac 100644 --- a/gcc/cp/mangle.c +++ b/gcc/cp/mangle.c @@ -1345,13 +1345,10 @@ write_unqualified_name (tree decl) } else if (DECL_OVERLOADED_OPERATOR_P (decl)) { - operator_name_info_t *oni; - if (DECL_ASSIGNMENT_OPERATOR_P (decl)) - oni = assignment_operator_name_info; - else - oni = operator_name_info; - - write_string (oni[DECL_OVERLOADED_OPERATOR_CODE (decl)].mangled_name); + const char *mangled_name + = (OVL_OP_INFO (DECL_ASSIGNMENT_OPERATOR_P (decl), + DECL_OVERLOADED_OPERATOR_CODE (decl))->mangled_name); + write_string (mangled_name); } else if (UDLIT_OPER_P (DECL_NAME (decl))) write_literal_operator_name (DECL_NAME (decl)); @@ -3064,8 +3061,8 @@ write_expression (tree expr) else if (TREE_CODE (expr) == MODOP_EXPR) { enum tree_code subop = TREE_CODE (TREE_OPERAND (expr, 1)); - const char *name = (assignment_operator_name_info[(int) subop] - .mangled_name); + const char *name = OVL_OP_INFO (true, subop)->mangled_name; + write_string (name); write_expression (TREE_OPERAND (expr, 0)); write_expression (TREE_OPERAND (expr, 2)); @@ -3090,7 +3087,7 @@ write_expression (tree expr) if (NEW_EXPR_USE_GLOBAL (expr)) write_string ("gs"); - write_string (operator_name_info[(int) code].mangled_name); + write_string (OVL_OP_INFO (false, code)->mangled_name); for (t = placement; t; t = TREE_CHAIN (t)) write_expression (TREE_VALUE (t)); @@ -3130,7 +3127,7 @@ write_expression (tree expr) if (DELETE_EXPR_USE_GLOBAL (expr)) write_string ("gs"); - write_string (operator_name_info[(int) code].mangled_name); + write_string (OVL_OP_INFO (false, code)->mangled_name); write_expression (TREE_OPERAND (expr, 0)); } @@ -3195,7 +3192,7 @@ write_expression (tree expr) if (TREE_CODE (ob) == ARROW_EXPR) { - write_string (operator_name_info[(int)code].mangled_name); + write_string (OVL_OP_INFO (false, code)->mangled_name); ob = TREE_OPERAND (ob, 0); write_expression (ob); } @@ -3212,7 +3209,7 @@ write_expression (tree expr) } /* If it wasn't any of those, recursively expand the expression. */ - name = operator_name_info[(int) code].mangled_name; + name = OVL_OP_INFO (false, code)->mangled_name; /* We used to mangle const_cast and static_cast like a C cast. */ if (code == CONST_CAST_EXPR @@ -3221,7 +3218,7 @@ write_expression (tree expr) if (abi_warn_or_compat_version_crosses (6)) G.need_abi_warning = 1; if (!abi_version_at_least (6)) - name = operator_name_info[CAST_EXPR].mangled_name; + name = OVL_OP_INFO (false, CAST_EXPR)->mangled_name; } if (name == NULL) @@ -3322,7 +3319,7 @@ write_expression (tree expr) if (i == 0) { int fcode = TREE_INT_CST_LOW (operand); - write_string (operator_name_info[fcode].mangled_name); + write_string (OVL_OP_INFO (false, fcode)->mangled_name); continue; } else if (code == BINARY_LEFT_FOLD_EXPR) diff --git a/gcc/cp/method.c b/gcc/cp/method.c index e88e508..034431d 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1703,12 +1703,12 @@ synthesized_method_walk (tree ctype, special_function_kind sfk, bool const_p, { /* Unlike for base ctor/op=/dtor, for operator delete it's fine to have a null fn (no class-specific op delete). */ - fn = locate_fn_flags (ctype, cp_operator_id (DELETE_EXPR), + fn = locate_fn_flags (ctype, ovl_op_identifier (false, DELETE_EXPR), ptr_type_node, flags, tf_none); if (fn && fn == error_mark_node) { if (complain & tf_error) - locate_fn_flags (ctype, cp_operator_id (DELETE_EXPR), + locate_fn_flags (ctype, ovl_op_identifier (false, DELETE_EXPR), ptr_type_node, flags, complain); if (deleted_p) *deleted_p = true; @@ -2008,7 +2008,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, || kind == sfk_move_assignment) { return_type = build_reference_type (type); - name = cp_assignment_operator_id (NOP_EXPR); + name = assign_op_identifier; } else name = ctor_identifier; @@ -2078,7 +2078,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, if (!IDENTIFIER_CDTOR_P (name)) /* Assignment operator. */ - SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR); + DECL_OVERLOADED_OPERATOR_CODE (fn) = NOP_EXPR; else if (IDENTIFIER_CTOR_P (name)) DECL_CXX_CONSTRUCTOR_P (fn) = true; else diff --git a/gcc/cp/name-lookup.c b/gcc/cp/name-lookup.c index b1b4ebb..1b35390 100644 --- a/gcc/cp/name-lookup.c +++ b/gcc/cp/name-lookup.c @@ -1299,7 +1299,7 @@ get_class_binding (tree klass, tree name, int type_or_fns) if (CLASSTYPE_LAZY_DESTRUCTOR (klass)) lazily_declare_fn (sfk_destructor, klass); } - else if (name == cp_assignment_operator_id (NOP_EXPR)) + else if (name == assign_op_identifier) { if (CLASSTYPE_LAZY_COPY_ASSIGN (klass)) lazily_declare_fn (sfk_copy_assignment, klass); diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c index a536b808..bcaefde 100644 --- a/gcc/cp/parser.c +++ b/gcc/cp/parser.c @@ -15006,7 +15006,7 @@ cp_parser_operator (cp_parser* parser) operator token. */ if (op != ERROR_MARK) { - id = assop ? cp_assignment_operator_id (op) : cp_operator_id (op); + id = ovl_op_identifier (assop, op); if (!consumed) cp_lexer_consume_token (parser->lexer); } @@ -32588,21 +32588,21 @@ cp_parser_omp_clause_reduction (cp_parser *parser, tree list) code = MIN_EXPR; else if (strcmp (p, "max") == 0) code = MAX_EXPR; - else if (id == cp_operator_id (PLUS_EXPR)) + else if (id == ovl_op_identifier (false, PLUS_EXPR)) code = PLUS_EXPR; - else if (id == cp_operator_id (MULT_EXPR)) + else if (id == ovl_op_identifier (false, MULT_EXPR)) code = MULT_EXPR; - else if (id == cp_operator_id (MINUS_EXPR)) + else if (id == ovl_op_identifier (false, MINUS_EXPR)) code = MINUS_EXPR; - else if (id == cp_operator_id (BIT_AND_EXPR)) + else if (id == ovl_op_identifier (false, BIT_AND_EXPR)) code = BIT_AND_EXPR; - else if (id == cp_operator_id (BIT_IOR_EXPR)) + else if (id == ovl_op_identifier (false, BIT_IOR_EXPR)) code = BIT_IOR_EXPR; - else if (id == cp_operator_id (BIT_XOR_EXPR)) + else if (id == ovl_op_identifier (false, BIT_XOR_EXPR)) code = BIT_XOR_EXPR; - else if (id == cp_operator_id (TRUTH_ANDIF_EXPR)) + else if (id == ovl_op_identifier (false, TRUTH_ANDIF_EXPR)) code = TRUTH_ANDIF_EXPR; - else if (id == cp_operator_id (TRUTH_ORIF_EXPR)) + else if (id == ovl_op_identifier (false, TRUTH_ORIF_EXPR)) code = TRUTH_ORIF_EXPR; id = omp_reduction_id (code, id, NULL_TREE); tree scope = parser->scope; diff --git a/gcc/cp/semantics.c b/gcc/cp/semantics.c index 89bea1e..b513c4d 100644 --- a/gcc/cp/semantics.c +++ b/gcc/cp/semantics.c @@ -5099,7 +5099,7 @@ omp_reduction_id (enum tree_code reduction_code, tree reduction_id, tree type) case BIT_IOR_EXPR: case TRUTH_ANDIF_EXPR: case TRUTH_ORIF_EXPR: - reduction_id = cp_operator_id (reduction_code); + reduction_id = ovl_op_identifier (false, reduction_code); break; case MIN_EXPR: p = "min"; diff --git a/gcc/cp/typeck.c b/gcc/cp/typeck.c index 3cc746a..38fd158 100644 --- a/gcc/cp/typeck.c +++ b/gcc/cp/typeck.c @@ -1562,7 +1562,7 @@ cxx_sizeof_or_alignof_type (tree type, enum tree_code op, bool complain) if (complain) pedwarn (input_location, OPT_Wpointer_arith, "invalid application of %qs to a member function", - operator_name_info[(int) op].name); + OVL_OP_INFO (false, op)->name); else return error_mark_node; value = size_one_node; diff --git a/libcc1/ChangeLog b/libcc1/ChangeLog index ea7a1ae..70998bc 100644 --- a/libcc1/ChangeLog +++ b/libcc1/ChangeLog @@ -1,3 +1,9 @@ +2017-10-31 Nathan Sidwell <nathan@acm.org> + + * libcp1plugin.cc (plugin_build_decl): Use ovl_op_identifier. + Directly set operator code. + (plugin_build_dependent_expr): Use ovl_op_identifier. + 2017-10-04 Nathan Sidwell <nathan@acm.org> * libcp1plugin.cc (supplement_binding): Don't use diff --git a/libcc1/libcp1plugin.cc b/libcc1/libcp1plugin.cc index 12ea4ed..d83521e 100644 --- a/libcc1/libcp1plugin.cc +++ b/libcc1/libcp1plugin.cc @@ -1346,12 +1346,7 @@ plugin_build_decl (cc1_plugin::connection *self, } if (opcode != ERROR_MARK) - { - if (assop) - identifier = cp_assignment_operator_id (opcode); - else - identifier = cp_operator_id (opcode); - } + identifier = ovl_op_identifier (assop, opcode); } decl = build_lang_decl_loc (loc, code, identifier, sym_type); /* FIXME: current_lang_name is lang_name_c while compiling an @@ -1410,19 +1405,14 @@ plugin_build_decl (cc1_plugin::connection *self, DECL_DECLARED_INLINE_P (decl) = 1; DECL_INITIAL (decl) = error_mark_node; } - if (ctor || dtor) - { - if (ctor) - DECL_CXX_CONSTRUCTOR_P (decl) = 1; - if (dtor) - DECL_CXX_DESTRUCTOR_P (decl) = 1; - } - else - { - if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION) - && opcode != ERROR_MARK) - SET_OVERLOADED_OPERATOR_CODE (decl, opcode); - } + + if (ctor) + DECL_CXX_CONSTRUCTOR_P (decl) = 1; + else if (dtor) + DECL_CXX_DESTRUCTOR_P (decl) = 1; + else if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION) + && opcode != ERROR_MARK) + DECL_OVERLOADED_OPERATOR_CODE (decl) = opcode; } else if (RECORD_OR_UNION_CODE_P (code)) { @@ -2649,12 +2639,7 @@ plugin_build_dependent_expr (cc1_plugin::connection *self, gcc_assert (convop || !conv_type); if (opcode != ERROR_MARK) - { - if (assop) - identifier = cp_assignment_operator_id (opcode); - else - identifier = cp_operator_id (opcode); - } + identifier = ovl_op_identifier (assop, opcode); gcc_assert (identifier); } |