From patchwork Fri Jun 19 15:02:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11614357 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 02C9E1731 for ; Fri, 19 Jun 2020 15:04:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D7A8421BE5 for ; Fri, 19 Jun 2020 15:04:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rK90Oo36" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391101AbgFSPEH (ORCPT ); Fri, 19 Jun 2020 11:04:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56196 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390621AbgFSPEG (ORCPT ); Fri, 19 Jun 2020 11:04:06 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B49C2C0613EE for ; Fri, 19 Jun 2020 08:04:05 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id y13so10552741eju.2 for ; Fri, 19 Jun 2020 08:04:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=lV6OqpCcdFW1iNc4Mmd1dUSVfQ/k1JX9QKPvgvI0AAo=; b=rK90Oo36aE2/zMwrVszzlDVjv/S2FqrFg2kG/TQGfTb6XBj9O19QomD9W6Pls3CcfW VyIbX8YlEVIxeTeL69BGttvIv/rFp01m2G1kbXWu0BWu/g+QwnyZM0MpXpoYVV4qRztf F009pSA9eqqQI6mDClfGVsaC+uidRpr8IDto2dAPi6DrKC97l+wQSMrxEtJ8CY06d7ix arO0EZSH9kp3tUdXvqEbCTbikh4TCxmhIJQpMPEEsWxM3ZePKO0Kwi/A7EIUrgkjcAs0 DHsIbYzqT7ptF22lR3QmXNSsToxQt0gQOEXlMmkJh08nrF8A+6xO2+JeO8rRfe6eqAKu zdQA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=lV6OqpCcdFW1iNc4Mmd1dUSVfQ/k1JX9QKPvgvI0AAo=; b=U3DyMekLmcLh8kTCJ39eKRJyTLAY0yIs5G7iLOB35vqEMQmk74ic7+XS5a/ykW7Kd/ wLFcHzIwUkziDLI3XWmebktcWVs+Df0Er1JCHXEYns1c6XoFDLHurjhYKWj0/SOxJqk6 PJ0Z9z61/p4hs1oB+j4BMkVgKE9raDc36kT/DJ4bjcyuduFG/4VWiG4fJjATENM2l0oL 7tBKx8RLTTQAcQoxW0rIcn/pyudsxv8mbol9ZVV8Mnbdpxg2pqk2Z4KUm/eiGmwd/1ih ntxIt/PmTQPXFM59Ofjo5PxXfAwyJPrhKubAQ3Bd1goR2gudWcHFJ+d3LInFI//eiz/+ fziQ== X-Gm-Message-State: AOAM530ZzM+/PIHImSbqew6SLPxImatHxbV1rHwvvw+xNfy2tQqaeUPi 25DNAxrjWhJBpPosPv/ypXgF+FdO X-Google-Smtp-Source: ABdhPJyv7QXEiksCjyYNxjxrrqSQhHg0k5ZpdKiN63yhCz5EK1++pDB/0wf3D5wKaqjCwg/ub8J1UA== X-Received: by 2002:a17:906:f74a:: with SMTP id jp10mr4049752ejb.43.1592579044018; Fri, 19 Jun 2020 08:04:04 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7f9:7600:5db0:70:8732:dad2]) by smtp.gmail.com with ESMTPSA id k22sm4852307edr.93.2020.06.19.08.04.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:04:03 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/5] gensel: add testcases from DR481 Date: Fri, 19 Jun 2020 17:02:56 +0200 Message-Id: <20200619150300.63695-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> References: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Following the resolution of DR481, the controlling expression is subject to a few different rules. Add the testcases from this defect report. Signed-off-by: Luc Van Oostenryck --- validation/generic-dr481.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 validation/generic-dr481.c diff --git a/validation/generic-dr481.c b/validation/generic-dr481.c new file mode 100644 index 000000000000..2ed15c9bc6d3 --- /dev/null +++ b/validation/generic-dr481.c @@ -0,0 +1,17 @@ +static char const* a = _Generic("bla", char*: "blu"); +static char const* b = _Generic("bla", char[4]: "blu"); +static char const* c = _Generic((int const){ 0 }, int: "blu"); +static char const* d = _Generic((int const){ 0 }, int const: "blu"); +static char const* e = _Generic(+(int const){ 0 }, int: "blu"); +static char const* f = _Generic(+(int const){ 0 }, int const: "blu"); + +/* + * check-name: generic-dr481 + * check-known-to-fail + * + * check-error-start +generic-dr481.c:2:32: error: no generic selection for 'char *' +generic-dr481.c:4:32: error: no generic selection for 'int const [toplevel]' +generic-dr481.c:6:32: error: no generic selection for 'int' + * check-error-end + */ From patchwork Fri Jun 19 15:02:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11614359 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 050D714DD for ; Fri, 19 Jun 2020 15:04:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E04CB21D90 for ; Fri, 19 Jun 2020 15:04:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OO9PUKxo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391108AbgFSPEQ (ORCPT ); Fri, 19 Jun 2020 11:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391070AbgFSPEH (ORCPT ); Fri, 19 Jun 2020 11:04:07 -0400 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C89F0C06174E for ; Fri, 19 Jun 2020 08:04:06 -0700 (PDT) Received: by mail-ed1-x542.google.com with SMTP id s28so7825448edw.11 for ; Fri, 19 Jun 2020 08:04:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MPWCkyHwWQ53a4azwa7BX5F7K9HADZqogDZFLLqWvVI=; b=OO9PUKxo1P8kaK+1PCXVUrx4vZG0xHaYgW518mwSWbdo+8OnA50dbYk6ahKTl0WFMF 4SsEHegenpWm3VD67ThwtB0lXbprE89icSn++Mf2kI49uBKPbLlknfD1KZTOxOqpHM/W 2yXIIgZpTqksS0gOwK5F50BARFx4PVgWN71wIpz/sv8CzSHmnqNobCoMcx4MmF3KM4PS rOznnM6dwKPAYxEEG7f8JQRde4f94JPRa5uaFy2WO1emwm84jcKsSrRx/fzPYml8MfBT wk9xPVwYe/EDwZb1+hiQA20adIfMK3kZa8s6wn71fSsmrpq5or8hNwXTxsLzLfB2Lqcz 86YA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=MPWCkyHwWQ53a4azwa7BX5F7K9HADZqogDZFLLqWvVI=; b=YPNnuDRKYVhed4Sk3kiPXVo+Dpk1HUgb1RmUGKSurr4tji61e5tIxV5e8AZcMj/I1I cXJCyYgQ4MV9I5J04EubeQNW3PDcslQP2Mk7J3dBmSi7oiNW5mqQ0YmF9tBbD3nRKh6a ZtsraHlYBSCz0V2x9HWC2InOE6XN/bE5LlqwYS+hI9ZmEMBIckruj0fIQ0mao8Q1/4tI NHe+bkAH3SSGhFpAU5lllXPrbwJPNBGvnmiOamFxRrDO9n1SwrlirFryoN2Wpkehet37 TRd9BjzhEB6JBSw8LxKz/nvtrEKhMXpwguXZq6nLUClg2t+AylOYF2zpPo5xCzLP0uP+ X8gg== X-Gm-Message-State: AOAM533v1s6BjEYJmZfytHdpzlWpSjWxHmi+o077uSBwp75G5aUftcG5 dBZk6euPVS6XipDgaZ9RB6rrUCrw X-Google-Smtp-Source: ABdhPJxEvW28HR0tvI/yOQQ3YNQJU3xoYRZZ9Y90vYfXSsqkzEsPzU4TTzWUr9tQJQ58SuMc4JvEsA== X-Received: by 2002:aa7:d7cc:: with SMTP id e12mr3704531eds.70.1592579045271; Fri, 19 Jun 2020 08:04:05 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7f9:7600:5db0:70:8732:dad2]) by smtp.gmail.com with ESMTPSA id k22sm4852307edr.93.2020.06.19.08.04.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:04:04 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/5] gensel: use temporary variable in generic selection Date: Fri, 19 Jun 2020 17:02:57 +0200 Message-Id: <20200619150300.63695-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> References: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Use a temporary variable for 'map->type' to make the expressions in the following patches more readable. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/evaluate.c b/evaluate.c index 95aef4dc0758..cf40eed418b4 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3293,9 +3293,11 @@ static struct symbol *evaluate_generic_selection(struct expression *expr) return NULL; for (map = expr->map; map; map = map->next) { - if (!evaluate_symbol(map->type)) + struct symbol *stype = map->type; + + if (!evaluate_symbol(stype)) continue; - if (!type_selection(ctrl, map->type)) + if (!type_selection(ctrl, stype)) continue; res = map->expr; From patchwork Fri Jun 19 15:02:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11614355 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6251390 for ; Fri, 19 Jun 2020 15:04:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 42A7321BE5 for ; Fri, 19 Jun 2020 15:04:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f+hrRz0g" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389003AbgFSPEO (ORCPT ); Fri, 19 Jun 2020 11:04:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391104AbgFSPEJ (ORCPT ); Fri, 19 Jun 2020 11:04:09 -0400 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D08FFC0613EE for ; Fri, 19 Jun 2020 08:04:07 -0700 (PDT) Received: by mail-ej1-x643.google.com with SMTP id w16so10536550ejj.5 for ; Fri, 19 Jun 2020 08:04:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f1tDaOPhLIPBbrMpWLxA+LoTZXoERFEHqSmTsj+iGTE=; b=f+hrRz0gkRpshBZFvN3rgqYVsvEnN7ke9DnHMXE31SVSJUk0ksXlLK7phzr5TqctMY Bb0cCT7FiUn3a476OpKeZDi8bHgQe/zasQX0jxemdOZiOGZYwoagw5msroXony6SBl85 XT4YRRVkR66z5mUG69asVYAbHJ/8ngMefO1Q89YeUGKKWy8CjVWRTmThngiccfkvFSvx /cgV2/tqblTSafJaWq7gzG+mbzHrIqG8HlekzIzLO+U3SukRhKSGmzxB8AC5XtkWAtoD 775neWAsLVHCQdFGeDHhAwo6nJhNSwX5jI8A6HfT2fUBzsV256w3rJuaTV6wTrPZkquc NpFA== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=f1tDaOPhLIPBbrMpWLxA+LoTZXoERFEHqSmTsj+iGTE=; b=tPg3TpdJaUcf+hoMGNCdhqo7ZrTlmso4O1Hntoy5vlSR4E97tGvrQQWsJPYgHYrqW+ VnOKFf8KSfvlTa9sW2lk1z5e0+VoFU3SZp6uoeDyc4bNVgU1en7v3/Aqmv52OH678YlR kF5irmFHA3fx/dA1klPGgrDA+FwaTLJuuEPi+9liKbnZgaVCwu/OiBzrl73Zr955Ht2I O2ci/dQ0aiebEaFad1Fu+KctH1ik2Thdz4ZcC/6DuwghFkksMmz6NiUf2UcWvTMJ1URy Gp4wIJs1kQiOL6fcsnB1PWyJjDIArs1/3IB4+dQ+y8ByrXObmG/W4NSi9mNkh3UacCTL jq1A== X-Gm-Message-State: AOAM5339RWaGc7KE7uay3prOKtpqST9uosiJ45EK5O7g2NGrH5KT2Qs8 6EJEhfwJF/95ums/8SeJ4XhGNhq9 X-Google-Smtp-Source: ABdhPJzop0Js4Nsr9jc2BOGSDWQWX8EUUWUKInX/IXPcCNmvXIutR/sqwK8a1g7/qG+85JdaTRmKVA== X-Received: by 2002:a17:906:4e0a:: with SMTP id z10mr3937508eju.57.1592579046372; Fri, 19 Jun 2020 08:04:06 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7f9:7600:5db0:70:8732:dad2]) by smtp.gmail.com with ESMTPSA id k22sm4852307edr.93.2020.06.19.08.04.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:04:05 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck , Marco Elver Subject: [PATCH 3/5] gensel: controlling expression must be lvalue converted Date: Fri, 19 Jun 2020 17:02:58 +0200 Message-Id: <20200619150300.63695-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> References: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Following the resolution of DR481, the controlling expression of a generic selection must be lvalue converted. In other words, the qualifiers must be ignored. Reported-by: Marco Elver Signed-off-by: Luc Van Oostenryck --- evaluate.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/evaluate.c b/evaluate.c index cf40eed418b4..d8615a894c0d 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3287,17 +3287,20 @@ static struct symbol *evaluate_generic_selection(struct expression *expr) { struct type_expression *map; struct expression *res; + struct symbol source; struct symbol *ctrl; if (!(ctrl = evaluate_expression(expr->control))) return NULL; + source = *ctrl; + source.ctype.modifiers &= ~(MOD_QUALIFIER|MOD_ATOMIC); for (map = expr->map; map; map = map->next) { struct symbol *stype = map->type; if (!evaluate_symbol(stype)) continue; - if (!type_selection(ctrl, stype)) + if (!type_selection(&source, stype)) continue; res = map->expr; From patchwork Fri Jun 19 15:02:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11614531 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0221A912 for ; Fri, 19 Jun 2020 16:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8E7721707 for ; Fri, 19 Jun 2020 16:13:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y4jZIP6E" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726321AbgFSPEQ (ORCPT ); Fri, 19 Jun 2020 11:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391106AbgFSPEK (ORCPT ); Fri, 19 Jun 2020 11:04:10 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 298F2C0613EF for ; Fri, 19 Jun 2020 08:04:09 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id gl26so10525852ejb.11 for ; Fri, 19 Jun 2020 08:04:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VPZTqo+mX5wZ3qcnzZnYgh66qqvLplWLA5vXy1evwAI=; b=Y4jZIP6EOoSo/A155xJy4/Brf3YeWPj0O+/Fg0fuZKfJD+zjeG7P+AOIY+eC7Ev0r/ oQCKLr+mvqiAB17TDdaOcwUzjH6D3fviWzGS/WTXECDJsH+PfQVcHhHXbKBOxtKlr9zC 4tffZ+mQJevRTk6zGt3vPJ84ouvrWoqojbWOHNfIbUNOG8lXtq5CHAzvI4TurTcXlj4y IdgV1I9GoCRUAmnfeosNQdBjirstabJp2j+FNShr+txipg1tkplBKFp68OmOWFoYtzZg MCddF87zMSdGdfyhRAAZLWBSJyoL8jtf0pd7iTEBCGqAxQggVBTodHDqX+kjteSolPmn VeSg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=VPZTqo+mX5wZ3qcnzZnYgh66qqvLplWLA5vXy1evwAI=; b=dmSvyjaS0eFibgCrAmUuJUsSQGCUC/NPonbXTb5WXQp43yTAZ2AOO1slemYT5h0U9O +8tlZAw1DaNJWGRXECWVtkAeKmLATheTe5qrsQ1eR69oTxI5uw2QRBgZwNG+6n8kNiFz FteA9K0YLFfdikg0U7HeLtA9mMTTrsKgrdGKbFzSJ4wuFnsalCtdqXFg91LqosufRHeQ ayaVNQnl6sT6NSQRe9OFqQSE0CEkE2wiqavJU6X1LG2gNvzpdg/ptv2OHSFfgbgEVo3W GVfLfNGiTy+LikIRAPExgYGNApkiyZc6CKWjg42v+0mpuqDkkR9jGmi4Xs0ZyLkWCOk8 lOyw== X-Gm-Message-State: AOAM531F2vusLmd/nglFR4W4kYk4Lw7OawmxOPtb2EUWSkC08KeLqDmB uavkWBmZF0Eh8qBmqced4CfjOkGF X-Google-Smtp-Source: ABdhPJxC3xW1PgIi3ZOW7QUoI4njP83FsWTfXnqdWNYeIqBSfH4pUI47kHkPaEIT73pbbCfUxWgxgQ== X-Received: by 2002:a17:906:6403:: with SMTP id d3mr3942060ejm.386.1592579047706; Fri, 19 Jun 2020 08:04:07 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7f9:7600:5db0:70:8732:dad2]) by smtp.gmail.com with ESMTPSA id k22sm4852307edr.93.2020.06.19.08.04.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:04:07 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck , Marco Elver Subject: [PATCH 4/5] gensel: controlling expression must be pointer-converted Date: Fri, 19 Jun 2020 17:02:59 +0200 Message-Id: <20200619150300.63695-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> References: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Following the resolution of DR481, the controlling expression of a generic selection must be array-to-pointer converted and function-to-pointer converted. Do this by adding a call to degenerate(). Reported-by: Marco Elver Signed-off-by: Luc Van Oostenryck --- evaluate.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/evaluate.c b/evaluate.c index d8615a894c0d..491dfa3c6b89 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3290,7 +3290,9 @@ static struct symbol *evaluate_generic_selection(struct expression *expr) struct symbol source; struct symbol *ctrl; - if (!(ctrl = evaluate_expression(expr->control))) + if (!evaluate_expression(expr->control)) + return NULL; + if (!(ctrl = degenerate(expr->control))) return NULL; source = *ctrl; From patchwork Fri Jun 19 15:03:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 11614533 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1F03214B7 for ; Fri, 19 Jun 2020 16:13:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 068BB21707 for ; Fri, 19 Jun 2020 16:13:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="blkWU5aj" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390458AbgFSPEQ (ORCPT ); Fri, 19 Jun 2020 11:04:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391108AbgFSPEK (ORCPT ); Fri, 19 Jun 2020 11:04:10 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1E483C0613F0 for ; Fri, 19 Jun 2020 08:04:10 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id p20so10485720ejd.13 for ; Fri, 19 Jun 2020 08:04:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1PWnvqF7eagSXt/GJ1aE68oblIr3ILD869FOXO3TdxQ=; b=blkWU5ajHxvJdBZYODKTsH90AC6j5oLdXnSDjJS7PrdKWzDmhMXuaEUBOmr/nSh+GW wcFjZOXYq2E+G9olumZWVhQbYXgZDuQp/BGLTxN96/TY5LJnyxB6IM5jpmfRdgwKIlpR lFqsqZjkc4hpkdU40gWpW7DNiAwRyE6l5WjiQIlR9Y4ZIaWwIJ6ITFa4Zvm/Xv0/p4Ba F0ToN9L7opXndsNqFf4zxEySM+dVgADLvA+hTjUNbSm6RJQCJtJNbyye6h9y41EOVPkQ +seMdXOH1Elfqs+4EGvtI4LQ7boLSdEd+4d6G7mFFXVeNaLGnhn1RPCWBLhdXeB3VOwM xMBw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=1PWnvqF7eagSXt/GJ1aE68oblIr3ILD869FOXO3TdxQ=; b=riXAjOGhAsNoTpxP6b7crSTh41xvnm0PvreOGHgCCja/52cukUvEJOsAAcOh9vUyEd qZFUDC807K13BExX9tan5q2szEnmqozNYWg/MQezbbyk79Da5aJ5jkLZRixp3mT0jlCM WTl1X/e0ZXalNSGgyQDmSUyR/hL/7Lib0k9KtAGoTm2r1HUfXdVJ8JgNjXBWyv+xqLjT 7qOo/X62UBd7803/Azld3WVHPoceXWr4L221q2NCSLAitcjRKaEYCtmSOUgkbrcPE7uH 5y8h71kfetCkGjmWIBXq+JcPQETkLaQ+OkXQx+e6j5CxHGs0MJ3kkA2HWsCg4a+MqeSs pZ8A== X-Gm-Message-State: AOAM531MtyTJKADT6V9GRZDeXi1iM+Utg6ZOINsHIAhi6lE4fFYOUVdt CpOm6xD8F3Zb+VYIq9QxKzKleiNC X-Google-Smtp-Source: ABdhPJygTT6pdkQzV6wigwYlaZq0sDJDRtAlr5JTXV1xt3jOJ/n6gkWwJsiAPTJwr+Diu///1aB8Cg== X-Received: by 2002:a17:906:aec5:: with SMTP id me5mr4298812ejb.54.1592579048607; Fri, 19 Jun 2020 08:04:08 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:b7f9:7600:5db0:70:8732:dad2]) by smtp.gmail.com with ESMTPSA id k22sm4852307edr.93.2020.06.19.08.04.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Jun 2020 08:04:08 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/5] gensel: validate the type of the associations Date: Fri, 19 Jun 2020 17:03:00 +0200 Message-Id: <20200619150300.63695-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> References: <20200619150300.63695-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The type in a generic association must correspond to a complete type and not a variably modified type. Add validation for this. Signed-off-by: Luc Van Oostenryck --- evaluate.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/evaluate.c b/evaluate.c index 491dfa3c6b89..aa0f208006bb 100644 --- a/evaluate.c +++ b/evaluate.c @@ -3299,9 +3299,29 @@ static struct symbol *evaluate_generic_selection(struct expression *expr) source.ctype.modifiers &= ~(MOD_QUALIFIER|MOD_ATOMIC); for (map = expr->map; map; map = map->next) { struct symbol *stype = map->type; + struct symbol *base; if (!evaluate_symbol(stype)) continue; + + if (stype->type == SYM_NODE) + base = stype->ctype.base_type; + + if (base->type == SYM_ARRAY && base->array_size) { + get_expression_value_silent(base->array_size); + if (base->array_size->type == EXPR_VALUE) + continue; + sparse_error(stype->pos, "variable length array type in generic selection"); + continue; + } + if (is_func_type(stype)) { + sparse_error(stype->pos, "function type in generic selection"); + continue; + } + if (stype->bit_size <= 0 || is_void_type(stype)) { + sparse_error(stype->pos, "incomplete type in generic selection"); + continue; + } if (!type_selection(&source, stype)) continue;