From patchwork Fri Mar 31 01:44:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 9655377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 93D8760113 for ; Fri, 31 Mar 2017 01:46:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 85BC428617 for ; Fri, 31 Mar 2017 01:46:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AD5628693; Fri, 31 Mar 2017 01:46:38 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 285E728617 for ; Fri, 31 Mar 2017 01:46:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934907AbdCaBqi (ORCPT ); Thu, 30 Mar 2017 21:46:38 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:33272 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934847AbdCaBqg (ORCPT ); Thu, 30 Mar 2017 21:46:36 -0400 Received: by mail-wr0-f195.google.com with SMTP id u18so16611188wrc.0 for ; Thu, 30 Mar 2017 18:46:35 -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; bh=lI6Mlqalk66XxoYVv28qPlBrRufaKyWmJz0G0R1tx8I=; b=TKRMhTg+F4e20y3AIkyPddEOTaJGkEE+3tEyhxulNx9H6/0rK7TFwY/iaMXfSlzTfL fm1ZWrqZGjSV1WFscAJ/7s+s2P3ddUQmcIz2GjVqHQD9BBMn6f7FwYI3Vn8pBL9bpRKY Spho5M9M++ZiVSNDBIeZQLjuHyUg4oE+YGr0FXEWUlBZRw0bi7DSwoXODaBKSiURCjqD ++9JzHA86z0AVgwAVYbReYjEYaR13sS2F5ypBjLNILBnsOhpbZG7F98yulVR38uwbglx tyZPGjyy8YuU03+I0vfxzmfdVGG/By2W+NruW18gniqAErbPlvHudonMsCqn0oowxZ0M UDBA== 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; bh=lI6Mlqalk66XxoYVv28qPlBrRufaKyWmJz0G0R1tx8I=; b=ZkwvoOrheB+QWQHtqWS/ppnzwJYdRdSaRY2zsaJOy2UYu2EzFT8Jd33Dx8d4nvVjFf YILX+SXSzPjV+OzAVNaoN54rrCdCW8psNxMxqhshcploR1hzjE8FsQCF6MUNtU+oNJZY VfcuJktkk4UpK7agW6AH7LY7M8PrJ6JU5RIJmwbvZ7ECQeN4EOPBWHauWzzoQzpqA4Ki dxBLYNBO/1LSiz6qSj+PwkH5FjvX3rP+AtPU6OVwQH/pBiSKGgFPCU8D2bBu7H8kMg+t TQY1zpZSe5DL5gu8/Wfxgpivql9RIedAB8tM291Z6brIINB3wUQW/ak0KyVrZCVX8giN G72w== X-Gm-Message-State: AFeK/H08eBZVM64EDxaiyLuYHg2xPvY45ur+ACT9TuxdXc15xBQrlTZpyriJuY5+q7Km5w== X-Received: by 10.223.135.195 with SMTP id c3mr343004wrc.41.1490924794302; Thu, 30 Mar 2017 18:46:34 -0700 (PDT) Received: from localhost.localdomain ([2a02:a03f:88d:1900:cdad:92b8:5279:ae19]) by smtp.gmail.com with ESMTPSA id 189sm917023wmm.31.2017.03.30.18.46.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 18:46:33 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Nicolai Stange , Luc Van Oostenryck Subject: [PATCH v4 07/25] constexpr: add support for tagging arithmetic constant expressions Date: Fri, 31 Mar 2017 03:44:41 +0200 Message-Id: <20170331014459.9351-8-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.12.0 In-Reply-To: <20170331014459.9351-1-luc.vanoostenryck@gmail.com> References: <20170331014459.9351-1-luc.vanoostenryck@gmail.com> 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 From: Nicolai Stange Arithmetic constant expressions may be either of (6.6(8)): - integer constant expressions - floating point constants or any arithmetic expression build up from them. Furthermore, casts with arithmetic destination types preserve arithmetic constness. Arithmetic constant expressions may be used as initializers for objects of static storage duration. Introduce a new constexpr flag : CEF_ACE. Modify CEF_SET_ICE and CEF_SET_FLOAT to also include that new bit. Thus, whenever an integer constant expression or a floating point constant is recognized, it is automatically tagged as an arithmetic constant expression. Note that everything has already been set up such that the new flag propagates nicely from subexpressions to parent expressions at evaluation. Signed-off-by: Nicolai Stange Signed-off-by: Luc Van Oostenryck --- expression.h | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/expression.h b/expression.h index c084783c8..67b6a83e3 100644 --- a/expression.h +++ b/expression.h @@ -96,16 +96,19 @@ enum constexpr_flag { /* * A constant expression in the sense of [6.6]: * - integer constant expression [6.6(6)] + * - arithmetic constant expression [6.6(8)] */ CEF_ICE = (1 << 4), + CEF_ACE = (1 << 5), - - CEF_SET_ICE = (CEF_ICE), + /* integer constant expression => arithmetic constant expression */ + CEF_SET_ICE = (CEF_ICE | CEF_ACE), /* integer constant => integer constant expression */ CEF_SET_INT = (CEF_INT | CEF_SET_ICE), - CEF_SET_FLOAT = (CEF_FLOAT), + /* floating point constant => arithmetic constant expression */ + CEF_SET_FLOAT = (CEF_FLOAT | CEF_ACE), /* enumeration constant => integer constant expression */ CEF_SET_ENUM = (CEF_ENUM | CEF_SET_ICE), @@ -118,14 +121,13 @@ enum constexpr_flag { * expression" [6.6] flags. */ CEF_CONST_MASK = (CEF_INT | CEF_FLOAT | CEF_CHAR), -}; -/* - * not an integer constant expression => neither of integer, - * enumeration and character constant - */ -#define CEF_CLR_ICE \ - (CEF_ICE | CEF_INT | CEF_ENUM | CEF_CHAR) + /* + * not an integer constant expression => neither of integer, + * enumeration and character constant + */ + CEF_CLR_ICE = (CEF_ICE | CEF_INT | CEF_ENUM | CEF_CHAR), +}; enum { Taint_comma = 1,