2017-11-01 Nathan Sidwell <nathan@acm.org>
+ * cp-tree.h (enum cp_identifier_kind): Delete cik_newdel_op.
+ Renumber and reserve udlit value.
+ (IDENTIFIER_NEWDEL_OP): Delete.
+ (IDENTIFIER_OVL_OP): New.
+ (IDENTIFIER_ASSIGN_OP): Adjust.
+ (IDENTIFIER_CONV_OP): Adjust.
+ (IDENTIFIER_OVL_OP_INFO): Adjust.
+ (IDENTIFIER_OVL_OP_FLAGS): New.
+ * decl.c (grokdeclarator): Use IDENTIFIER_OVL_OP_FLAGS.
+ * lex.c (get_identifier_kind_name): Adjust.
+ (init_operators): Don't special case new/delete ops.
+ * mangle.c (write_unqualified_id): Use IDENTIFIER_OVL_OP.
+ * pt.c (push_template_decl_real): Use IDENTIFIER_OVL_OP_FLAGS.
+ * typeck.c (check_return_expr): Likewise.
+
* cp-tree.h (assign_op_identifier, call_op_identifier): Use
compressed code.
(struct lang_decl_fn): Use compressed operator code.
cik_dtor = 3, /* Destructor (in-chg, deleting, complete or
base). */
cik_simple_op = 4, /* Non-assignment operator name. */
- cik_newdel_op = 5, /* New or delete operator name. */
- cik_assign_op = 6, /* An assignment operator name. */
- cik_conv_op = 7, /* Conversion operator name. */
+ cik_assign_op = 5, /* An assignment operator name. */
+ cik_conv_op = 6, /* Conversion operator name. */
+ cik_reserved_for_udlit = 7, /* Not yet in use */
cik_max
};
#define IDENTIFIER_ANY_OP_P(NODE) \
(IDENTIFIER_KIND_BIT_2 (NODE))
-/* True if this identifier is for new or delete operator. Value 5. */
-#define IDENTIFIER_NEWDEL_OP_P(NODE) \
- (IDENTIFIER_KIND_BIT_2 (NODE) \
- & (!IDENTIFIER_KIND_BIT_1 (NODE)) \
- & IDENTIFIER_KIND_BIT_0 (NODE))
+/* True if this identifier is for an overloaded operator. Values 4, 5. */
+#define IDENTIFIER_OVL_OP_P(NODE) \
+ (IDENTIFIER_ANY_OP_P (NODE) \
+ & (!IDENTIFIER_KIND_BIT_1 (NODE)))
-/* True if this identifier is for any assignment. Values 6. */
+/* True if this identifier is for any assignment. Values 5. */
#define IDENTIFIER_ASSIGN_OP_P(NODE) \
- (IDENTIFIER_KIND_BIT_2 (NODE) \
- & IDENTIFIER_KIND_BIT_1 (NODE) \
- & (!IDENTIFIER_KIND_BIT_0 (NODE)))
+ (IDENTIFIER_OVL_OP_P (NODE) \
+ & IDENTIFIER_KIND_BIT_0 (NODE))
/* True if this identifier is the name of a type-conversion
operator. Value 7. */
#define IDENTIFIER_CONV_OP_P(NODE) \
- (IDENTIFIER_KIND_BIT_2 (NODE) \
+ (IDENTIFIER_ANY_OP_P (NODE) \
& IDENTIFIER_KIND_BIT_1 (NODE) \
- & IDENTIFIER_KIND_BIT_0 (NODE))
+ & (!IDENTIFIER_KIND_BIT_0 (NODE)))
/* Access a C++-specific index for identifier NODE.
Used to optimize operator mappings etc. */
#define OVL_OP_INFO(IS_ASS_P, TREE_CODE) \
(&ovl_op_info[(IS_ASS_P) != 0][ovl_op_mapping[(TREE_CODE)]])
/* Overloaded operator info for an identifier for which
- IDENTIFIER_ANY_OP_P is true. */
+ IDENTIFIER_OVL_OP_P is true. */
#define IDENTIFIER_OVL_OP_INFO(NODE) \
- (&ovl_op_info[IDENTIFIER_ASSIGN_OP_P (NODE)][IDENTIFIER_CP_INDEX (NODE)])
+ (&ovl_op_info[IDENTIFIER_KIND_BIT_0 (NODE)][IDENTIFIER_CP_INDEX (NODE)])
+#define IDENTIFIER_OVL_OP_FLAGS(NODE) \
+ (IDENTIFIER_OVL_OP_INFO (NODE)->flags)
/* A type-qualifier, or bitmask therefore, using the TYPE_QUAL
constants. */
if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2
&& !(identifier_p (unqualified_id)
- && IDENTIFIER_NEWDEL_OP_P (unqualified_id)))
+ && IDENTIFIER_OVL_OP_P (unqualified_id)
+ && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id) & OVL_OP_FLAG_ALLOC)))
{
cp_cv_quals real_quals = memfn_quals;
if (cxx_dialect < cxx14 && constexpr_p
if (virtualp
&& identifier_p (unqualified_id)
- && IDENTIFIER_NEWDEL_OP_P (unqualified_id))
+ && IDENTIFIER_OVL_OP_P (unqualified_id)
+ && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id)
+ & OVL_OP_FLAG_ALLOC))
{
error ("%qD cannot be declared %<virtual%>, since it "
"is always static", unqualified_id);
/* Keep in sync with cp_id_kind enumeration. */
static const char *const names[cik_max] = {
"normal", "keyword", "constructor", "destructor",
- "assign-op", "op-assign-op", "simple-op", "conv-op", };
+ "simple-op", "assign-op", "conv-op", "<reserved>udlit-op"
+ };
unsigned kind = 0;
kind |= IDENTIFIER_KIND_BIT_2 (id) << 2;
else
{
IDENTIFIER_CP_INDEX (ident) = ix;
- set_identifier_kind (ident,
- op_ptr->flags & OVL_OP_FLAG_ALLOC
- ? cik_newdel_op : cik_simple_op);
+ set_identifier_kind (ident, cik_simple_op);
}
}
if (op_ptr->tree_code)
{
if (IDENTIFIER_CONV_OP_P (identifier))
write_conversion_operator_name (TREE_TYPE (identifier));
- else if (IDENTIFIER_ANY_OP_P (identifier))
+ else if (IDENTIFIER_OVL_OP_P (identifier))
{
const ovl_op_info_t *ovl_op = IDENTIFIER_OVL_OP_INFO (identifier);
write_string (ovl_op->mangled_name);
error ("destructor %qD declared as member template", decl);
return error_mark_node;
}
- if (IDENTIFIER_NEWDEL_OP_P (DECL_NAME (decl))
+ if (IDENTIFIER_OVL_OP_P (DECL_NAME (decl))
+ && (IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (decl))
+ & OVL_OP_FLAG_ALLOC)
&& (!prototype_p (TREE_TYPE (decl))
|| TYPE_ARG_TYPES (TREE_TYPE (decl)) == void_list_node
|| !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)))
}
/* Only operator new(...) throw(), can return NULL [expr.new/13]. */
- if (DECL_OVERLOADED_OPERATOR_P (current_function_decl)
- && (DECL_OVERLOADED_OPERATOR_IS (current_function_decl, NEW_EXPR)
- || DECL_OVERLOADED_OPERATOR_IS (current_function_decl, VEC_NEW_EXPR))
+ if (IDENTIFIER_OVL_OP_P (DECL_NAME (current_function_decl))
+ && ((IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (current_function_decl))
+ & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) == OVL_OP_FLAG_ALLOC)
&& !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
&& ! flag_check_new
&& retval && null_ptr_cst_p (retval))