From patchwork Fri Mar 31 01:44:44 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: 9655383 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 8B97D60113 for ; Fri, 31 Mar 2017 01:46:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7658B28688 for ; Fri, 31 Mar 2017 01:46:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B69B28698; Fri, 31 Mar 2017 01:46:42 +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 09BF628688 for ; Fri, 31 Mar 2017 01:46:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935012AbdCaBqm (ORCPT ); Thu, 30 Mar 2017 21:46:42 -0400 Received: from mail-wr0-f195.google.com ([209.85.128.195]:36013 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934847AbdCaBqj (ORCPT ); Thu, 30 Mar 2017 21:46:39 -0400 Received: by mail-wr0-f195.google.com with SMTP id k6so15309803wre.3 for ; Thu, 30 Mar 2017 18:46:38 -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=t1RZ5c7hHHKIkqTk7tK80N5r/NARxfP+OnbQoyC9fzc=; b=ToN0VL6GaFfSas+nDGbeYSS4Em9FzuXUMh2fI34pMJ66TXYfnNl+B96IvUCOAgF4YR +WWkjy0tG5+eGfIdxgt1Lwn744L+lu065wkIr1s6OBpv6VG1FWw5LGyHxRzw2kIwRLYx Q4R0xnCIbrDtthTymWLFG2NFeYmrb4r5sadPRCoxiZhs74GlfAcTzRZ89AbGYZU3Wx6F /s0S1tEkm8sT/p5ByUmYppvN1/ehY63/o1c3vS4Rn5stcjDOi1tP+CXBbQnSkoHCwBJA DzzToupOJDgPGPR7g8lIxKMxZJEBaI8YqyVeAZNQqprfN8wN8tFTgIeBJtP75GCnfc2y 4Yog== 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=t1RZ5c7hHHKIkqTk7tK80N5r/NARxfP+OnbQoyC9fzc=; b=aCYsJ9VjUAMlzgfMuGOBwCDB7/F/navn0TkUCa+NVoT4aXtb/CIPQVUW5ytY6ZMS7d q9uf+T5qWzw4kchjwTkIOYj4yrnqaflDICwrfiK6RbGZVnBtGmPQZDkrTbYNDDGY0Ox1 FI+fKIKiI+16TSRz2cVDi5Rmm80n2vVQE3MBwAPg0HXccJKuy/xCOGqfKeyYEf3PC5M6 bk0zDMDRNFzUqR9Doom+G8nbuN5Ad5/mEtCby7Qq3V+nuV+lHrZCLuQ75XzyteOlz1gT /EfyH2rrifmBeaTVCwbWeqUtPHfqlS+YwmjUbrVv5WFngqtJgYamVc4+T5EYPZlU2cHc 5D5Q== X-Gm-Message-State: AFeK/H33Lqa+vmRHW/sl7CII/OSNnfXWLaERTlS+7I4FXvJqeRM9am3cvH4ZMwRhrG7IvQ== X-Received: by 10.28.47.205 with SMTP id v196mr905217wmv.20.1490924797376; Thu, 30 Mar 2017 18:46:37 -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.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 30 Mar 2017 18:46:36 -0700 (PDT) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Nicolai Stange , Luc Van Oostenryck Subject: [PATCH v4 10/25] constexpr: collect storage modifiers of initializers Date: Fri, 31 Mar 2017 03:44:44 +0200 Message-Id: <20170331014459.9351-11-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 This is a preparatory step for checking the constness of initializers of static storage duration objects; Signed-off-by: Luc Van Oostenryck --- evaluate.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/evaluate.c b/evaluate.c index 07edda41b..138ee1dd6 100644 --- a/evaluate.c +++ b/evaluate.c @@ -2451,13 +2451,13 @@ static struct expression *next_designators(struct expression *old, } static int handle_initializer(struct expression **ep, int nested, - int class, struct symbol *ctype); + int class, struct symbol *ctype, unsigned long mods); /* * deal with traversing subobjects [6.7.8(17,18,20)] */ static void handle_list_initializer(struct expression *expr, - int class, struct symbol *ctype) + int class, struct symbol *ctype, unsigned long mods) { struct expression *e, *last = NULL, *top = NULL, *next; int jumped = 0; @@ -2515,7 +2515,8 @@ found: else v = &top->ident_expression; - if (handle_initializer(v, 1, lclass, top->ctype)) + mods |= ctype->ctype.modifiers & MOD_STORAGE; + if (handle_initializer(v, 1, lclass, top->ctype, mods)) continue; if (!(lclass & TYPE_COMPOUND)) { @@ -2608,7 +2609,7 @@ static struct expression *handle_scalar(struct expression *e, int nested) * until we dig into the inner struct. */ static int handle_initializer(struct expression **ep, int nested, - int class, struct symbol *ctype) + int class, struct symbol *ctype, unsigned long mods) { int is_string = is_string_type(ctype); struct expression *e = *ep, *p; @@ -2648,7 +2649,7 @@ static int handle_initializer(struct expression **ep, int nested, goto String; } } - handle_list_initializer(e, class, ctype); + handle_list_initializer(e, class, ctype, mods); return 1; } @@ -2696,7 +2697,7 @@ static void evaluate_initializer(struct symbol *ctype, struct expression **ep) { struct symbol *type; int class = classify_type(ctype, &type); - if (!handle_initializer(ep, 0, class, ctype)) + if (!handle_initializer(ep, 0, class, ctype, 0)) expression_error(*ep, "invalid initializer"); }