Commit d6ef53f2 by Nathan Sidwell Committed by Nathan Sidwell

cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.

	gcc/cp/
	* cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
	(DECL_COMPLETE_CONSTRUCTOR_P): Directly compare
	identifier.
	(DECL_BASE_CONSTRUCTOR_P, DECL_COMPLETE_DESTRUCTOR_P)
	DECL_BASE_DESTRUCTOR_P, DECL_DELETING_DESTRUCTOR_P): Likewise.
	(DECL_ASSIGNMENT_OPERATOR_P): Use IDENTIFIER_ASSIGN_OP_P.
	* decl.c (grok_op_properties): Adjust identifier checking.
	* init.c (expand_default_init): Adjust identifier descision.
	* method.c (implicitly_declare_fn): Don't use
	DECL_ASSIGNMENT_OPERATOR_P.
	* search.c (lookup_fnfields_1): Use IDENTIFIER_CTOR_P,
	IDENTIFIER_DTOR_P.
	* call.c (in_charge_arg_for_name): Reimplement.
	(build_special_member_call): Use IDENTIFIER_CDTOR_P,
	IDENTIFIER_DTOR_P.

	libcc1/
	* libcp1plugin.cc (plugin_build_decl): Don't set
	DECL_ASSIGNMENT_OPERATOR_P.
(--This line, and those below, will be ignored--

M    gcc/cp/init.c
M    gcc/cp/decl.c
M    gcc/cp/method.c
M    gcc/cp/cp-tree.h
M    gcc/cp/call.c
M    gcc/cp/search.c
M    gcc/cp/ChangeLog
M    libcc1/ChangeLog
M    libcc1/libcp1plugin.cc

From-SVN: r249657
parent 0ffdc300
2017-06-26 Nathan Sidwell <nathan@acm.org>
* cp-tree.h (lang_decl_fn): Remove assignment_operator_p field.
(DECL_COMPLETE_CONSTRUCTOR_P): Directly compare
identifier.
(DECL_BASE_CONSTRUCTOR_P, DECL_COMPLETE_DESTRUCTOR_P,
DECL_BASE_DESTRUCTOR_P, DECL_DELETING_DESTRUCTOR_P): Likewise.
(DECL_ASSIGNMENT_OPERATOR_P): Use IDENTIFIER_ASSIGN_OP_P.
* decl.c (grok_op_properties): Adjust identifier checking.
* init.c (expand_default_init): Adjust identifier descision.
* method.c (implicitly_declare_fn): Don't use
DECL_ASSIGNMENT_OPERATOR_P.
* search.c (lookup_fnfields_1): Use IDENTIFIER_CTOR_P,
IDENTIFIER_DTOR_P.
* call.c (in_charge_arg_for_name): Reimplement.
(build_special_member_call): Use IDENTIFIER_CDTOR_P,
IDENTIFIER_DTOR_P.
2017-06-26 Marek Polacek <polacek@redhat.com> 2017-06-26 Marek Polacek <polacek@redhat.com>
PR c/80116 PR c/80116
......
...@@ -8677,20 +8677,22 @@ build_cxx_call (tree fn, int nargs, tree *argarray, ...@@ -8677,20 +8677,22 @@ build_cxx_call (tree fn, int nargs, tree *argarray,
tree tree
in_charge_arg_for_name (tree name) in_charge_arg_for_name (tree name)
{ {
if (name == base_ctor_identifier if (IDENTIFIER_CTOR_P (name))
|| name == base_dtor_identifier) {
return integer_zero_node; if (name == complete_ctor_identifier)
else if (name == complete_ctor_identifier) return integer_one_node;
return integer_one_node; gcc_checking_assert (name == base_ctor_identifier);
else if (name == complete_dtor_identifier) }
return integer_two_node; else
else if (name == deleting_dtor_identifier) {
return integer_three_node; if (name == complete_dtor_identifier)
return integer_two_node;
/* This function should only be called with one of the names listed else if (name == deleting_dtor_identifier)
above. */ return integer_three_node;
gcc_unreachable (); gcc_checking_assert (name == base_dtor_identifier);
return NULL_TREE; }
return integer_zero_node;
} }
/* We've built up a constructor call RET. Complain if it delegates to the /* We've built up a constructor call RET. Complain if it delegates to the
...@@ -8729,11 +8731,7 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args, ...@@ -8729,11 +8731,7 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args,
vec<tree, va_gc> *allocated = NULL; vec<tree, va_gc> *allocated = NULL;
tree ret; tree ret;
gcc_assert (name == complete_ctor_identifier gcc_assert (IDENTIFIER_CDTOR_P (name)
|| name == base_ctor_identifier
|| name == complete_dtor_identifier
|| name == base_dtor_identifier
|| name == deleting_dtor_identifier
|| name == cp_assignment_operator_id (NOP_EXPR)); || name == cp_assignment_operator_id (NOP_EXPR));
if (TYPE_P (binfo)) if (TYPE_P (binfo))
{ {
...@@ -8753,9 +8751,7 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args, ...@@ -8753,9 +8751,7 @@ build_special_member_call (tree instance, tree name, vec<tree, va_gc> **args,
instance = build_dummy_object (class_type); instance = build_dummy_object (class_type);
else else
{ {
if (name == complete_dtor_identifier if (IDENTIFIER_DTOR_P (name))
|| name == base_dtor_identifier
|| name == deleting_dtor_identifier)
gcc_assert (args == NULL || vec_safe_is_empty (*args)); gcc_assert (args == NULL || vec_safe_is_empty (*args));
/* Convert to the base class, if necessary. */ /* Convert to the base class, if necessary. */
......
...@@ -1776,6 +1776,7 @@ struct GTY(()) language_function { ...@@ -1776,6 +1776,7 @@ struct GTY(()) language_function {
(operator_name_info[(int) (CODE)].identifier) (operator_name_info[(int) (CODE)].identifier)
#define cp_assignment_operator_id(CODE) \ #define cp_assignment_operator_id(CODE) \
(assignment_operator_name_info[(int) (CODE)].identifier) (assignment_operator_name_info[(int) (CODE)].identifier)
/* In parser.c. */ /* In parser.c. */
extern tree cp_literal_operator_id (const char *); extern tree cp_literal_operator_id (const char *);
...@@ -2495,25 +2496,27 @@ struct GTY(()) lang_decl_fn { ...@@ -2495,25 +2496,27 @@ struct GTY(()) lang_decl_fn {
struct lang_decl_min min; struct lang_decl_min min;
/* In an overloaded operator, this is the value of /* In an overloaded operator, this is the value of
DECL_OVERLOADED_OPERATOR_P. */ DECL_OVERLOADED_OPERATOR_P.
FIXME: We should really do better in compressing this. */
ENUM_BITFIELD (tree_code) operator_code : 16; ENUM_BITFIELD (tree_code) operator_code : 16;
unsigned global_ctor_p : 1; unsigned global_ctor_p : 1;
unsigned global_dtor_p : 1; unsigned global_dtor_p : 1;
unsigned assignment_operator_p : 1;
unsigned static_function : 1; unsigned static_function : 1;
unsigned pure_virtual : 1; unsigned pure_virtual : 1;
unsigned defaulted_p : 1; unsigned defaulted_p : 1;
unsigned has_in_charge_parm_p : 1; unsigned has_in_charge_parm_p : 1;
unsigned has_vtt_parm_p : 1; unsigned has_vtt_parm_p : 1;
unsigned pending_inline_p : 1; unsigned pending_inline_p : 1;
unsigned nonconverting : 1; unsigned nonconverting : 1;
unsigned thunk_p : 1; unsigned thunk_p : 1;
unsigned this_thunk_p : 1; unsigned this_thunk_p : 1;
unsigned hidden_friend_p : 1; unsigned hidden_friend_p : 1;
unsigned omp_declare_reduction_p : 1; unsigned omp_declare_reduction_p : 1;
/* 2 spare bits on 32-bit hosts, 34 on 64-bit hosts. */ /* 3 spare bits. */
/* 32-bits padding on 64-bit host. */
/* For a non-thunk function decl, this is a tree list of /* For a non-thunk function decl, this is a tree list of
friendly classes. For a thunk function decl, it is the friendly classes. For a thunk function decl, it is the
...@@ -2694,14 +2697,12 @@ struct GTY(()) lang_decl { ...@@ -2694,14 +2697,12 @@ struct GTY(()) lang_decl {
/* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a complete
object. */ object. */
#define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \ #define DECL_COMPLETE_CONSTRUCTOR_P(NODE) \
(DECL_CONSTRUCTOR_P (NODE) \ (DECL_NAME (NODE) == complete_ctor_identifier)
&& DECL_NAME (NODE) == complete_ctor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base /* Nonzero if NODE (a FUNCTION_DECL) is a constructor for a base
object. */ object. */
#define DECL_BASE_CONSTRUCTOR_P(NODE) \ #define DECL_BASE_CONSTRUCTOR_P(NODE) \
(DECL_CONSTRUCTOR_P (NODE) \ (DECL_NAME (NODE) == base_ctor_identifier)
&& DECL_NAME (NODE) == base_ctor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the /* Nonzero if NODE (a FUNCTION_DECL) is a constructor, but not either the
specialized in-charge constructor or the specialized not-in-charge specialized in-charge constructor or the specialized not-in-charge
...@@ -2733,20 +2734,17 @@ struct GTY(()) lang_decl { ...@@ -2733,20 +2734,17 @@ struct GTY(()) lang_decl {
/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
object. */ object. */
#define DECL_COMPLETE_DESTRUCTOR_P(NODE) \ #define DECL_COMPLETE_DESTRUCTOR_P(NODE) \
(DECL_DESTRUCTOR_P (NODE) \ (DECL_NAME (NODE) == complete_dtor_identifier)
&& DECL_NAME (NODE) == complete_dtor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a base
object. */ object. */
#define DECL_BASE_DESTRUCTOR_P(NODE) \ #define DECL_BASE_DESTRUCTOR_P(NODE) \
(DECL_DESTRUCTOR_P (NODE) \ (DECL_NAME (NODE) == base_dtor_identifier)
&& DECL_NAME (NODE) == base_dtor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete /* Nonzero if NODE (a FUNCTION_DECL) is a destructor for a complete
object that deletes the object after it has been destroyed. */ object that deletes the object after it has been destroyed. */
#define DECL_DELETING_DESTRUCTOR_P(NODE) \ #define DECL_DELETING_DESTRUCTOR_P(NODE) \
(DECL_DESTRUCTOR_P (NODE) \ (DECL_NAME (NODE) == deleting_dtor_identifier)
&& DECL_NAME (NODE) == deleting_dtor_identifier)
/* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or /* Nonzero if NODE (a FUNCTION_DECL) is a cloned constructor or
destructor. */ destructor. */
...@@ -2836,9 +2834,7 @@ struct GTY(()) lang_decl { ...@@ -2836,9 +2834,7 @@ struct GTY(()) lang_decl {
(LANG_DECL_FN_CHECK (NODE)->operator_code = (CODE)) (LANG_DECL_FN_CHECK (NODE)->operator_code = (CODE))
/* If NODE is an overloaded operator, then this returns the TREE_CODE /* If NODE is an overloaded operator, then this returns the TREE_CODE
associated with the overloaded operator. associated with the overloaded operator. If NODE is not an
DECL_ASSIGNMENT_OPERATOR_P must also be checked to determine
whether or not NODE is an assignment operator. If NODE is not an
overloaded operator, ERROR_MARK is returned. Since the numerical overloaded operator, ERROR_MARK is returned. Since the numerical
value of ERROR_MARK is zero, this macro can be used as a predicate value of ERROR_MARK is zero, this macro can be used as a predicate
to test whether or not NODE is an overloaded operator. */ to test whether or not NODE is an overloaded operator. */
...@@ -2848,7 +2844,7 @@ struct GTY(()) lang_decl { ...@@ -2848,7 +2844,7 @@ struct GTY(()) lang_decl {
/* Nonzero if NODE is an assignment operator (including += and such). */ /* Nonzero if NODE is an assignment operator (including += and such). */
#define DECL_ASSIGNMENT_OPERATOR_P(NODE) \ #define DECL_ASSIGNMENT_OPERATOR_P(NODE) \
(LANG_DECL_FN_CHECK (NODE)->assignment_operator_p) IDENTIFIER_ASSIGN_OP_P (DECL_NAME (NODE))
/* For FUNCTION_DECLs: nonzero means that this function is a /* For FUNCTION_DECLs: nonzero means that this function is a
constructor or a destructor with an extra in-charge parameter to constructor or a destructor with an extra in-charge parameter to
......
...@@ -12925,14 +12925,15 @@ grok_op_properties (tree decl, bool complain) ...@@ -12925,14 +12925,15 @@ grok_op_properties (tree decl, bool complain)
{ {
/* It'd be nice to hang something else of the identifier to /* It'd be nice to hang something else of the identifier to
find CODE more directly. */ find CODE more directly. */
bool assign_op = IDENTIFIER_ASSIGN_OP_P (name);
const operator_name_info_t *oni const operator_name_info_t *oni
= (IDENTIFIER_ASSIGN_OP_P (name) = (assign_op ? assignment_operator_name_info : operator_name_info);
? assignment_operator_name_info : operator_name_info);
DECL_ASSIGNMENT_OPERATOR_P (decl) = IDENTIFIER_ASSIGN_OP_P (name);
if (false) if (false)
; ;
#define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, KIND) \ #define DEF_OPERATOR(NAME, CODE, MANGLING, ARITY, KIND) \
else if (oni[int (CODE)].identifier == name) \ else if (assign_op == (KIND == cik_assign_op) \
&& oni[int (CODE)].identifier == name) \
operator_code = (CODE); operator_code = (CODE);
#include "operators.def" #include "operators.def"
#undef DEF_OPERATOR #undef DEF_OPERATOR
......
...@@ -1718,7 +1718,6 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, ...@@ -1718,7 +1718,6 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
tsubst_flags_t complain) tsubst_flags_t complain)
{ {
tree type = TREE_TYPE (exp); tree type = TREE_TYPE (exp);
tree ctor_name;
/* It fails because there may not be a constructor which takes /* It fails because there may not be a constructor which takes
its own type as the first (or only parameter), but which does its own type as the first (or only parameter), but which does
...@@ -1846,10 +1845,9 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags, ...@@ -1846,10 +1845,9 @@ expand_default_init (tree binfo, tree true_exp, tree exp, tree init, int flags,
} }
else else
{ {
if (true_exp == exp) tree ctor_name = (true_exp == exp
ctor_name = complete_ctor_identifier; ? complete_ctor_identifier : base_ctor_identifier);
else
ctor_name = base_ctor_identifier;
rval = build_special_member_call (exp, ctor_name, &parms, binfo, flags, rval = build_special_member_call (exp, ctor_name, &parms, binfo, flags,
complain); complain);
} }
......
...@@ -2060,10 +2060,7 @@ implicitly_declare_fn (special_function_kind kind, tree type, ...@@ -2060,10 +2060,7 @@ implicitly_declare_fn (special_function_kind kind, tree type,
else if (kind == sfk_destructor) else if (kind == sfk_destructor)
DECL_DESTRUCTOR_P (fn) = 1; DECL_DESTRUCTOR_P (fn) = 1;
else else
{ SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR);
DECL_ASSIGNMENT_OPERATOR_P (fn) = 1;
SET_OVERLOADED_OPERATOR_CODE (fn, NOP_EXPR);
}
SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY); SET_DECL_ALIGN (fn, MINIMUM_METHOD_BOUNDARY);
......
...@@ -1653,9 +1653,7 @@ lookup_fnfields_1 (tree type, tree name) ...@@ -1653,9 +1653,7 @@ lookup_fnfields_1 (tree type, tree name)
if (COMPLETE_TYPE_P (type)) if (COMPLETE_TYPE_P (type))
{ {
if ((name == ctor_identifier if (IDENTIFIER_CTOR_P (name))
|| name == base_ctor_identifier
|| name == complete_ctor_identifier))
{ {
if (CLASSTYPE_LAZY_DEFAULT_CTOR (type)) if (CLASSTYPE_LAZY_DEFAULT_CTOR (type))
lazily_declare_fn (sfk_constructor, type); lazily_declare_fn (sfk_constructor, type);
...@@ -1671,12 +1669,11 @@ lookup_fnfields_1 (tree type, tree name) ...@@ -1671,12 +1669,11 @@ lookup_fnfields_1 (tree type, tree name)
if (CLASSTYPE_LAZY_MOVE_ASSIGN (type)) if (CLASSTYPE_LAZY_MOVE_ASSIGN (type))
lazily_declare_fn (sfk_move_assignment, type); lazily_declare_fn (sfk_move_assignment, type);
} }
else if ((name == dtor_identifier else if (IDENTIFIER_DTOR_P (name))
|| name == base_dtor_identifier {
|| name == complete_dtor_identifier if (CLASSTYPE_LAZY_DESTRUCTOR (type))
|| name == deleting_dtor_identifier) lazily_declare_fn (sfk_destructor, type);
&& CLASSTYPE_LAZY_DESTRUCTOR (type)) }
lazily_declare_fn (sfk_destructor, type);
} }
return lookup_fnfields_idx_nolazy (type, name); return lookup_fnfields_idx_nolazy (type, name);
......
2017-06-26 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_build_decl): Don't set
DECL_ASSIGNMENT_OPERATOR_P.
2017-06-16 Nathan Sidwell <nathan@acm.org> 2017-06-16 Nathan Sidwell <nathan@acm.org>
* libcp1plugin.cc (plugin_build_decl): Adjust parm building. * libcp1plugin.cc (plugin_build_decl): Adjust parm building.
......
...@@ -1428,8 +1428,6 @@ plugin_build_decl (cc1_plugin::connection *self, ...@@ -1428,8 +1428,6 @@ plugin_build_decl (cc1_plugin::connection *self,
if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION) if ((sym_flags & GCC_CP_FLAG_SPECIAL_FUNCTION)
&& opcode != ERROR_MARK) && opcode != ERROR_MARK)
SET_OVERLOADED_OPERATOR_CODE (decl, opcode); SET_OVERLOADED_OPERATOR_CODE (decl, opcode);
if (assop)
DECL_ASSIGNMENT_OPERATOR_P (decl) = true;
} }
} }
else if (RECORD_OR_UNION_CODE_P (code)) else if (RECORD_OR_UNION_CODE_P (code))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment