From patchwork Mon Jan 21 21:58:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 10774561 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D590E13BF for ; Mon, 21 Jan 2019 22:00:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C7B5D2AD74 for ; Mon, 21 Jan 2019 22:00:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C632A2ADFE; Mon, 21 Jan 2019 22:00:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E1AE2AD74 for ; Mon, 21 Jan 2019 22:00:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbfAUWAj (ORCPT ); Mon, 21 Jan 2019 17:00:39 -0500 Received: from mail-ed1-f66.google.com ([209.85.208.66]:43728 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726694AbfAUWAi (ORCPT ); Mon, 21 Jan 2019 17:00:38 -0500 Received: by mail-ed1-f66.google.com with SMTP id f9so17704204eds.10 for ; Mon, 21 Jan 2019 14:00:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SjkFsFY/G1UGgYM8b0tqBgTwumOrzHGA+1ONEx+jm1Y=; b=hCwpL9DUxl4KQ9YX/rog1f9TFv2rNZlJHuY4LYYYY6v9OJ17/5md2AIGU0JqcZ5k8H Z72FHOawsTQuJDXkK6w3Ly6/mQiGMI/4OPPuc5dG0O/OYjG1zMs9niu+c4qZm2TQu2U+ dLbbbdIJVj/f6hhxMUc2eJKxUTADhfEu0TvjoYjEml/wsZtA62jIfqmWH+mmdTR6v0HG TAZA0mConmVNNC6nXKe2ztNFso1VL3xUm6pH6AAdXGbMwaB6YwCYqHJhLNDq/q0hoxkJ nosZVb8/tNxx/iKWpcNsNDf5Ge3gE72lgk3JDbNxaxQoOqYUibl+QRxirgDt3ZqjuA9F aryg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SjkFsFY/G1UGgYM8b0tqBgTwumOrzHGA+1ONEx+jm1Y=; b=syL4uVvWKGMic8rIZxJSjYE7EXdHIOHeBkVaH4OPV4gApd0DxMEiDfeOpn79z8Z1j3 GSCX10mvjS7fBkfL/kKRi6DdXiIEmSv8fuAC38gZzmvWyzpAP3mUb+6dyovgDg6advkh VNJAUHYCkENdN399nexqgGQTbJzRQNNVweTZTRbFKEyydiId96VeIEI10Ets+exE9aGW I0h0amzRoeg+wuF/PeMKgtP3f7oATiufYd6RmfFY2JO0s714rnMEvuq+1R8a3C5NwiTW Rzle8KPh7kwyxaK5p/hua5wRWk502UQ/7+NB40nHYL9hb6t/rfEEcUyG9S8eZYoY+MMs tqCA== X-Gm-Message-State: AJcUukfPANfGkZdEZGIJ4+txLIxN04UE71FFdFNCuhSNxRfUa33yoAs9 k6l4Vq7FDs+LXgaFQl1ezdNbQlAq X-Google-Smtp-Source: ALg8bN7vfymAeHP748TjE0IbAJUQfozsY3ZCbCEZK3fh7bH4AYdf4tTP6Nib1ZxkKWGFAL76V+OFwg== X-Received: by 2002:a17:906:5394:: with SMTP id g20-v6mr26024340ejo.174.1548108036484; Mon, 21 Jan 2019 14:00:36 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:40eb:400:581c:5faa:4760:b9c0]) by smtp.gmail.com with ESMTPSA id l41sm9729268eda.83.2019.01.21.14.00.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 14:00:35 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH] explain cause of 'incorrect type in conditional' Date: Mon, 21 Jan 2019 22:58:32 +0100 Message-Id: <20190121215832.28172-1-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.20.0 MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP A conditional only makes sense on a scalar type. If not, an error is issued. However, the error message doesn't explain this. Fix this by adding the explanation to the error message. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 2 +- validation/bad-type-twice0.c | 2 +- validation/conditional-type.c | 16 ++++++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/evaluate.c b/evaluate.c index 4d5748562..d316a3f79 100644 --- a/evaluate.c +++ b/evaluate.c @@ -910,7 +910,7 @@ static struct symbol *evaluate_conditional(struct expression *expr, int iterator if (Waddress) warning(expr->pos, "the address of %s will always evaluate as true", "an array"); } else if (!is_scalar_type(ctype)) { - sparse_error(expr->pos, "incorrect type in conditional:"); + sparse_error(expr->pos, "non-scalar type in conditional:"); info(expr->pos, " %s", show_typename(ctype)); return NULL; } diff --git a/validation/bad-type-twice0.c b/validation/bad-type-twice0.c index 84e0f25a4..9e834d47d 100644 --- a/validation/bad-type-twice0.c +++ b/validation/bad-type-twice0.c @@ -7,7 +7,7 @@ static int foo(a) * check-name: bad-type-twice0 * * check-error-start -bad-type-twice0.c:3:16: error: incorrect type in conditional: +bad-type-twice0.c:3:16: error: non-scalar type in conditional: bad-type-twice0.c:3:16: incomplete type a * check-error-end */ diff --git a/validation/conditional-type.c b/validation/conditional-type.c index 7cd5672dc..6e2da9b52 100644 --- a/validation/conditional-type.c +++ b/validation/conditional-type.c @@ -79,21 +79,21 @@ static int good_if_ptr(void *ptr) * check-name: conditional-type * * check-error-start -conditional-type.c:18:18: error: incorrect type in conditional: +conditional-type.c:18:18: error: non-scalar type in conditional: conditional-type.c:18:18: void -conditional-type.c:19:13: error: incorrect type in conditional: +conditional-type.c:19:13: error: non-scalar type in conditional: conditional-type.c:19:13: struct state s -conditional-type.c:24:18: error: incorrect type in conditional: +conditional-type.c:24:18: error: non-scalar type in conditional: conditional-type.c:24:18: void -conditional-type.c:29:21: error: incorrect type in conditional: +conditional-type.c:29:21: error: non-scalar type in conditional: conditional-type.c:29:21: void -conditional-type.c:30:16: error: incorrect type in conditional: +conditional-type.c:30:16: error: non-scalar type in conditional: conditional-type.c:30:16: struct state s -conditional-type.c:34:21: error: incorrect type in conditional: +conditional-type.c:34:21: error: non-scalar type in conditional: conditional-type.c:34:21: void -conditional-type.c:36:20: error: incorrect type in conditional: +conditional-type.c:36:20: error: non-scalar type in conditional: conditional-type.c:36:20: void -conditional-type.c:40:21: error: incorrect type in conditional: +conditional-type.c:40:21: error: non-scalar type in conditional: conditional-type.c:40:21: void * check-error-end */