From patchwork Fri Jul 21 18:00:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 792244 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-458683-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="l61PkW7Q"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xDdqj4kmyz9sRg for ; Sat, 22 Jul 2017 04:01:21 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=WXJDTYRV5airrIamQQ+HxYTERw3i/FkHrMETtci+0bOT7qqgnV nSV3J5XtnqTxIehk1tTI+NFQLKj0X1g8zlSAqxHlDJYH1zN5iWcRr6uWJvel7kbb PZm9UXGMbKYuz6nZSJkCLEvyHi4UF+q0cVyBUriuCkcLUGJj/5vFrpLNk= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=d7LjmpBtRatbciDVdZZqvbQqBWs=; b=l61PkW7QYghnb6+bcbel 7Nhp6nG1ueGV6JEsie4GNQBHlxHAxiy18lMpAfuJH8vjZ9008I/fj9a0HrUO2pPB 3TjGSUl4iawaJfKb8BACQ6DjB6h0BYxjzPuhoEKzBF/4Ft8dmDPe3oug4vze9s5R lHSSxCWK40RAygnTHOMtW0E= Received: (qmail 106077 invoked by alias); 21 Jul 2017 18:01:04 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 97593 invoked by uid 89); 21 Jul 2017 18:00:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=BAYES_00, FREEMAIL_FROM, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=55016 X-HELO: mail-yb0-f176.google.com Received: from mail-yb0-f176.google.com (HELO mail-yb0-f176.google.com) (209.85.213.176) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Jul 2017 18:00:43 +0000 Received: by mail-yb0-f176.google.com with SMTP id 74so13764597ybf.3 for ; Fri, 21 Jul 2017 11:00:33 -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:to:from:subject:message-id:date :user-agent:mime-version:content-language; bh=0II0ma8HmGzvkbvExShoBfHW6axHduCuoW+vMtvTm/c=; b=IYmmkX2eVL+8E+dL5kPCDLaxQcKzokOT9hKrJOvTgl9xNg/BWOsgYAtaEr1F0812qG o9P5aS2CvnHATsbYouzAhfRsx5BgMIr43dM7oB3s3G4CKapG6Qzj8vEi3E1nxk95YXki VYFiDNk0e1qlyW4WOUSx+JgjbIncm4TQRClvCbMx0EMLAK9g6b9ciiaskmnKvWCVeUo/ IJWVEsVtu2ZOZlE3WZ6fsCPqPVl+mvEU7J4fR23TnJuLDduYf8xKFTdHrc+L4w761/+K bF4w3QkBzqIFOBB0hvTSFli3u/+o8kg8G1LkzNKg4x2u8CzimUgNphDJhGHJRYsoAeCm DNbQ== X-Gm-Message-State: AIVw113aiPT3U14dDr0b15XWO27bs6PuNR0ti3uR64og0HVLILpw609A OJpnFNOg8aLt7g== X-Received: by 10.37.173.223 with SMTP id d31mr6702156ybe.73.1500660031846; Fri, 21 Jul 2017 11:00:31 -0700 (PDT) Received: from ?IPv6:2620:10d:c0a3:20fb:7500:e7fb:4a6f:2254? ([2620:10d:c091:200::3:fb48]) by smtp.googlemail.com with ESMTPSA id s184sm1855014ywe.95.2017.07.21.11.00.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 21 Jul 2017 11:00:31 -0700 (PDT) To: GCC Patches From: Nathan Sidwell Subject: [C++ PACTH] small add_candidates cleanup Message-ID: <8e251676-6e3e-d1a4-566f-f0ed27bf35f5@acm.org> Date: Fri, 21 Jul 2017 14:00:29 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 I wandered into add_candidates and got confused by !!. There were a few opportunities for other cleanup too, so committed the attached. nathan 2017-07-21 Nathan Sidwell * call.c (add_candidates): Move decls to initialization. Don't use !!. Index: call.c =================================================================== --- call.c (revision 250426) +++ call.c (working copy) @@ -5423,8 +5423,8 @@ add_candidates (tree fns, tree first_arg { tree ctype; const vec *non_static_args; - bool check_list_ctor; - bool check_converting; + bool check_list_ctor = false; + bool check_converting = false; unification_kind_t strict; if (!fns) @@ -5435,7 +5435,7 @@ add_candidates (tree fns, tree first_arg if (DECL_CONV_FN_P (fn)) { check_list_ctor = false; - check_converting = !!(flags & LOOKUP_ONLYCONVERTING); + check_converting = (flags & LOOKUP_ONLYCONVERTING) != 0; if (flags & LOOKUP_NO_CONVERSION) /* We're doing return_type(x). */ strict = DEDUCE_CONV; @@ -5452,18 +5452,13 @@ add_candidates (tree fns, tree first_arg { if (DECL_CONSTRUCTOR_P (fn)) { - check_list_ctor = !!(flags & LOOKUP_LIST_ONLY); + check_list_ctor = (flags & LOOKUP_LIST_ONLY) != 0; /* For list-initialization we consider explicit constructors and complain if one is chosen. */ check_converting = ((flags & (LOOKUP_ONLYCONVERTING|LOOKUP_LIST_INIT_CTOR)) == LOOKUP_ONLYCONVERTING); } - else - { - check_list_ctor = false; - check_converting = false; - } strict = DEDUCE_CALL; ctype = conversion_path ? BINFO_TYPE (conversion_path) : NULL_TREE; } @@ -5476,9 +5471,6 @@ add_candidates (tree fns, tree first_arg for (lkp_iterator iter (fns); iter; ++iter) { - tree fn_first_arg; - const vec *fn_args; - fn = *iter; if (check_converting && DECL_NONCONVERTING_P (fn)) @@ -5486,10 +5478,13 @@ add_candidates (tree fns, tree first_arg if (check_list_ctor && !is_list_ctor (fn)) continue; - /* Figure out which set of arguments to use. */ + tree fn_first_arg = NULL_TREE; + const vec *fn_args = args; + if (DECL_NONSTATIC_MEMBER_FUNCTION_P (fn)) { - /* If this function is a non-static member and we didn't get an + /* Figure out where the object arg comes from. If this + function is a non-static member and we didn't get an implicit object argument, move it out of args. */ if (first_arg == NULL_TREE) { @@ -5506,12 +5501,6 @@ add_candidates (tree fns, tree first_arg fn_first_arg = first_arg; fn_args = non_static_args; } - else - { - /* Otherwise, just use the list of arguments provided. */ - fn_first_arg = NULL_TREE; - fn_args = args; - } if (TREE_CODE (fn) == TEMPLATE_DECL) add_template_candidate (candidates,