From patchwork Wed Feb 27 20:00:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Marchi X-Patchwork-Id: 31641 Received: (qmail 69485 invoked by alias); 27 Feb 2019 20:01:06 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 69220 invoked by uid 89); 27 Feb 2019 20:00:51 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2807 X-HELO: mail.efficios.com Received: from mail.efficios.com (HELO mail.efficios.com) (167.114.142.138) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 27 Feb 2019 20:00:49 +0000 Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id BCB4F8083C for ; Wed, 27 Feb 2019 15:00:38 -0500 (EST) Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10032) with ESMTP id qrHI1uOOefbM; Wed, 27 Feb 2019 15:00:38 -0500 (EST) Received: from localhost (ip6-localhost [IPv6:::1]) by mail.efficios.com (Postfix) with ESMTP id 7CA768080D; Wed, 27 Feb 2019 15:00:38 -0500 (EST) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.efficios.com 7CA768080D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=default; t=1551297638; bh=wyuRWofIXDoD2bR/42EUqZVGPrNRLKtkr+yCdJ1WXKE=; h=From:To:Date:Message-Id:MIME-Version; b=VBN8e7C0mVjQ23g6k6CS0FDaW4NMad51PBRnsungR2gJy1E3ixy5rV6RY2g6To0SA QeHtjdbub7JE7GtzXNVo/egjhPMrW1/MvLdP9yvrl2rGUlnqYb6Ch4y10CijbSejQQ iU4xV923fw9irggfbZ0utfD0we70sO2uSjlzZEV26QPqq5pD2Gb3o421O4NZUSz+o1 ImE6oC54E6C1XFdZ6oQruQtI4UlAsduuPtzd4E2w3ryJ7sDwOCbbPZY0RdPy2kktl4 +EJ6JlZSgC0pLvhTLdYN4P6CNxsjZNu8wcqFYJJ7n7Zcj2SNa7ugKuIZ0/O2WYwgY6 dFq/g6urB8NeQ== Received: from mail.efficios.com ([IPv6:::1]) by localhost (mail02.efficios.com [IPv6:::1]) (amavisd-new, port 10026) with ESMTP id I3-iVMIebOt1; Wed, 27 Feb 2019 15:00:38 -0500 (EST) Received: from smarchi-efficios.internal.efficios.com (192-222-157-41.qc.cable.ebox.net [192.222.157.41]) by mail.efficios.com (Postfix) with ESMTPSA id 5D62F807F3; Wed, 27 Feb 2019 15:00:38 -0500 (EST) From: Simon Marchi To: gdb-patches@sourceware.org Cc: Simon Marchi Subject: [PATCH 08/13] Split rank_one_type_parm_bool from rank_one_type Date: Wed, 27 Feb 2019 15:00:23 -0500 Message-Id: <20190227200028.27360-9-simon.marchi@efficios.com> In-Reply-To: <20190227200028.27360-1-simon.marchi@efficios.com> References: <20190227200028.27360-1-simon.marchi@efficios.com> MIME-Version: 1.0 gdb/ChangeLog: * gdbtypes.c (rank_one_type_parm_bool): New function extracted from... (rank_one_type): ... this. --- gdb/gdbtypes.c | 57 ++++++++++++++++++++++++++++---------------------- 1 file changed, 32 insertions(+), 25 deletions(-) diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c index 9c4c66d44d..1e51d756bc 100644 --- a/gdb/gdbtypes.c +++ b/gdb/gdbtypes.c @@ -4090,6 +4090,37 @@ rank_one_type_parm_range (struct type *parm, struct type *arg, struct value *val } } +/* rank_one_type helper for when PARM's type code is TYPE_CODE_BOOL. */ + +static struct rank +rank_one_type_parm_bool (struct type *parm, struct type *arg, struct value *value) +{ + switch (TYPE_CODE (arg)) + { + /* n3290 draft, section 4.12.1 (conv.bool): + + "A prvalue of arithmetic, unscoped enumeration, pointer, or + pointer to member type can be converted to a prvalue of type + bool. A zero value, null pointer value, or null member pointer + value is converted to false; any other value is converted to + true. A prvalue of type std::nullptr_t can be converted to a + prvalue of type bool; the resulting value is false." */ + case TYPE_CODE_INT: + case TYPE_CODE_CHAR: + case TYPE_CODE_ENUM: + case TYPE_CODE_FLT: + case TYPE_CODE_MEMBERPTR: + case TYPE_CODE_PTR: + return BOOL_CONVERSION_BADNESS; + case TYPE_CODE_RANGE: + return INCOMPATIBLE_TYPE_BADNESS; + case TYPE_CODE_BOOL: + return EXACT_MATCH_BADNESS; + default: + return INCOMPATIBLE_TYPE_BADNESS; + } +} + /* Compare one type (PARM) for compatibility with another (ARG). * PARM is intended to be the parameter type of a function; and * ARG is the supplied argument's type. This function tests if @@ -4194,31 +4225,7 @@ rank_one_type (struct type *parm, struct type *arg, struct value *value) case TYPE_CODE_RANGE: return rank_one_type_parm_range (parm, arg, value); case TYPE_CODE_BOOL: - switch (TYPE_CODE (arg)) - { - /* n3290 draft, section 4.12.1 (conv.bool): - - "A prvalue of arithmetic, unscoped enumeration, pointer, or - pointer to member type can be converted to a prvalue of type - bool. A zero value, null pointer value, or null member pointer - value is converted to false; any other value is converted to - true. A prvalue of type std::nullptr_t can be converted to a - prvalue of type bool; the resulting value is false." */ - case TYPE_CODE_INT: - case TYPE_CODE_CHAR: - case TYPE_CODE_ENUM: - case TYPE_CODE_FLT: - case TYPE_CODE_MEMBERPTR: - case TYPE_CODE_PTR: - return BOOL_CONVERSION_BADNESS; - case TYPE_CODE_RANGE: - return INCOMPATIBLE_TYPE_BADNESS; - case TYPE_CODE_BOOL: - return EXACT_MATCH_BADNESS; - default: - return INCOMPATIBLE_TYPE_BADNESS; - } - break; + return rank_one_type_parm_bool (parm, arg, value); case TYPE_CODE_FLT: switch (TYPE_CODE (arg)) {