From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 40168 invoked by alias); 2 Nov 2017 14:15:31 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 40072 invoked by uid 89); 2 Nov 2017 14:15:19 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,KAM_ASCII_DIVIDERS,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-spam-relays-external:209.85.161.193, H*RU:209.85.161.193 X-HELO: mail-yw0-f193.google.com Received: from mail-yw0-f193.google.com (HELO mail-yw0-f193.google.com) (209.85.161.193) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 02 Nov 2017 14:15:16 +0000 Received: by mail-yw0-f193.google.com with SMTP id w2so4884288ywa.9 for ; Thu, 02 Nov 2017 07:15:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=fLYZqbSKiUmyXb0gs8InWcVlFdYpwW6KZ3EQ1tKlMvc=; b=n3JhKvcnQ1QJo+12UsRDMIAG1RDEaS7iww8MxHe/JbuVcKiuuarLIrzK54h6poK2DS eSODExsBp1x/q6vuObyoPi887edzBysV7gWccv1Z5sixqoJ/Ws9BowQCU2Hw3gSewJJZ yzBD3U7E9AJVMu9pwqRdsW9P5Ep5rPxBF3eOK9kh2kDyq61+EPcUADEgGyS4c6sgPuJo 1zkyuv1upQsmINyr3qmIDB2D2359TLrONCCtXjKJxaYYQhxdokGoty/6ZsHCUNtRzXuh cxslu95HP83o7v+VqrArKN+PvOx+1QNe/vjiwm69GuJ4F8tRNLzIvWS8g5L6CiXj7HaT Wq0g== X-Gm-Message-State: AMCzsaUNzQlwSS8z1w7dgcGjR0xeYDkFE4Zm2ok2xNV2pyGS3kxWOILC fI9dxJLw8bmLh69IN98d3g4= X-Google-Smtp-Source: ABhQp+QJLmrAizoyyAHrSr69Mawq19ZhJ55sbdw0HOnS6BK2yvf11HU8U9mNL2jj8tOnn9m43VcwTg== X-Received: by 10.37.184.200 with SMTP id g8mr2323337ybm.328.1509632112211; Thu, 02 Nov 2017 07:15:12 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::4fa5]) by smtp.googlemail.com with ESMTPSA id k10sm1416036ywe.72.2017.11.02.07.15.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 02 Nov 2017 07:15:10 -0700 (PDT) Subject: Re: [C++ PATCH] overloaded operator fns [8/N] To: Jason Merrill Cc: GCC Patches References: <40b48778-5335-2398-3dd5-e59f68b8f052@acm.org> <006c8467-dde6-1605-243c-f8d033ab4e49@acm.org> <85d3718d-17f4-42f4-db0b-7c2b3632aa6e@acm.org> From: Nathan Sidwell Message-ID: Date: Thu, 02 Nov 2017 14:15:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/mixed; boundary="------------4A6866D9D66AE4EB54A2D22B" X-SW-Source: 2017-11/txt/msg00095.txt.bz2 This is a multi-part message in MIME format. --------------4A6866D9D66AE4EB54A2D22B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-length: 534 On 11/01/2017 04:08 PM, Jason Merrill wrote: > On Wed, Nov 1, 2017 at 2:29 PM, Nathan Sidwell 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 --------------4A6866D9D66AE4EB54A2D22B Content-Type: text/x-patch; name="op-newdel.diff" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="op-newdel.diff" Content-length: 3517 2017-11-02 Nathan Sidwell * 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 %, 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)) --------------4A6866D9D66AE4EB54A2D22B--