On 11/01/2017 04:08 PM, Jason Merrill wrote:
On Wed, Nov 1, 2017 at 2:29 PM, Nathan Sidwell <nat...@acm.org> wrote:

-    && IDENTIFIER_NEWDEL_OP_P (unqualified_id)))
+    && IDENTIFIER_OVL_OP_P (unqualified_id)
+    && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id) & OVL_OP_FLAG_ALLOC)))

Why not keep the name IDENTIFIER_NEWDEL_OP_P, which expands to this?

Hm, I guess that would be better. This patch does that, and introduces IDENTIFIER_NEW_OP_P, for when we just want the new operators.

nathan

--
Nathan Sidwell
2017-11-02  Nathan Sidwell  <nat...@acm.org>

	* cp-tree.h (IDENTIFIER_NEWDEL_OP_P): Restore, adjust.
	(IDENTIFIER_NEW_OP_P): New.
	* decl.c (grokdeclarator): Restore IDENTIFIER_NEWDEL_OP_P use.
	* pt.c (push_template_decl_real): Likewise.
	* typeck.c (check_return_expr): Use IDENTIFIER_NEW_OP_P.

Index: cp/cp-tree.h
===================================================================
--- cp/cp-tree.h	(revision 254344)
+++ cp/cp-tree.h	(working copy)
@@ -1070,6 +1070,17 @@ enum cp_identifier_kind {
    & IDENTIFIER_KIND_BIT_1 (NODE)		\
    & (!IDENTIFIER_KIND_BIT_0 (NODE)))
 
+/* True if this identifier is a new or delete operator.  */
+#define IDENTIFIER_NEWDEL_OP_P(NODE)		\
+  (IDENTIFIER_OVL_OP_P (NODE)			\
+   && IDENTIFIER_OVL_OP_FLAGS (NODE) & OVL_OP_FLAG_ALLOC)
+
+/* True if this identifier is a new operator.  */
+#define IDENTIFIER_NEW_OP_P(NODE)					\
+  (IDENTIFIER_OVL_OP_P (NODE)						\
+   && (IDENTIFIER_OVL_OP_FLAGS (NODE)					\
+       & (OVL_OP_FLAG_ALLOC | OVL_OP_FLAG_DELETE)) == OVL_OP_FLAG_ALLOC)
+
 /* Access a C++-specific index for identifier NODE.
    Used to optimize operator mappings etc.  */
 #define IDENTIFIER_CP_INDEX(NODE)		\
Index: cp/decl.c
===================================================================
--- cp/decl.c	(revision 254344)
+++ cp/decl.c	(working copy)
@@ -11744,8 +11744,7 @@ grokdeclarator (const cp_declarator *dec
 
   if (ctype && TREE_CODE (type) == FUNCTION_TYPE && staticp < 2
       && !(identifier_p (unqualified_id)
-	   && IDENTIFIER_OVL_OP_P (unqualified_id)
-	   && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id) & OVL_OP_FLAG_ALLOC)))
+	   && IDENTIFIER_NEWDEL_OP_P (unqualified_id)))
     {
       cp_cv_quals real_quals = memfn_quals;
       if (cxx_dialect < cxx14 && constexpr_p
@@ -11858,9 +11857,7 @@ grokdeclarator (const cp_declarator *dec
 
 		if (virtualp
 		    && identifier_p (unqualified_id)
-		    && IDENTIFIER_OVL_OP_P (unqualified_id)
-		    && (IDENTIFIER_OVL_OP_FLAGS (unqualified_id)
-			& OVL_OP_FLAG_ALLOC))
+		    && IDENTIFIER_NEWDEL_OP_P (unqualified_id))
 		  {
 		    error ("%qD cannot be declared %<virtual%>, since it "
 			   "is always static", unqualified_id);
Index: cp/pt.c
===================================================================
--- cp/pt.c	(revision 254344)
+++ cp/pt.c	(working copy)
@@ -5329,9 +5329,7 @@ push_template_decl_real (tree decl, bool
 	      error ("destructor %qD declared as member template", decl);
 	      return error_mark_node;
 	    }
-	  if (IDENTIFIER_OVL_OP_P (DECL_NAME (decl))
-	      && (IDENTIFIER_OVL_OP_FLAGS (DECL_NAME (decl))
-		  & OVL_OP_FLAG_ALLOC)
+	  if (IDENTIFIER_NEWDEL_OP_P (DECL_NAME (decl))
 	      && (!prototype_p (TREE_TYPE (decl))
 		  || TYPE_ARG_TYPES (TREE_TYPE (decl)) == void_list_node
 		  || !TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)))
Index: cp/typeck.c
===================================================================
--- cp/typeck.c	(revision 254344)
+++ cp/typeck.c	(working copy)
@@ -9073,9 +9073,7 @@ check_return_expr (tree retval, bool *no
     }
 
   /* Only operator new(...) throw(), can return NULL [expr.new/13].  */
-  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)
+  if (IDENTIFIER_NEW_OP_P (DECL_NAME (current_function_decl))
       && !TYPE_NOTHROW_P (TREE_TYPE (current_function_decl))
       && ! flag_check_new
       && retval && null_ptr_cst_p (retval))

Reply via email to