From patchwork Sat Feb 18 20:30:45 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: 9581209 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 A8A7F60586 for ; Sat, 18 Feb 2017 20:30:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A3D926E97 for ; Sat, 18 Feb 2017 20:30:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8F5C2286B1; Sat, 18 Feb 2017 20:30:59 +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 302EC28618 for ; Sat, 18 Feb 2017 20:30:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753607AbdBRUa6 (ORCPT ); Sat, 18 Feb 2017 15:30:58 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:33760 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753461AbdBRUa5 (ORCPT ); Sat, 18 Feb 2017 15:30:57 -0500 Received: by mail-wr0-f196.google.com with SMTP id g51so1268345wrg.0 for ; Sat, 18 Feb 2017 12:30:57 -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:in-reply-to:references; bh=dF2VARcmdPtLuwvYrJWLzCl7ayYvNxqSPPKrGe9DDl0=; b=kgfwNef2fvtnkqYcbZ8houmyO7eCH/yFZACCYGrOw0KhYT6HHFO+csqfG0+Tt4widt hI5jg/pQoN+dDO5k0FI8YsjyGyIDLDkdWTyOSZlPg7GHTut9AhaxZeebyMR3mE/LJqYu Iz6/ZL6EshRr4f1Mbuai3uvWCzTQVViwTllMgrTKBWNrA36EZQNeA2LEPFwkGuhmVAcm TZvbI5Q8SbZf81Az8Tm+JHd7xtOTashqZdebW3fo0Ruj/puV851L1ffl/2gjftBZZu+d R0f9v/q593jVg8V21EmQdqvMbblvbcr6JdpbdbVGdMqowZ8474et5P5lAqJunhmH20u0 ghMg== 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=dF2VARcmdPtLuwvYrJWLzCl7ayYvNxqSPPKrGe9DDl0=; b=dCD7Kyp4qjEtgPejiH/joxLgcuDz7DjCAZn5EqKshtU7ieySsI0WixR/rAg0TgnvX6 ZqqAS9wrzikxkgY8OMiri2ZW++UdgH2RJKZjMZU4afytphm1RC0CNN6acNfZbkj8kncw izfcY4NLKvVYUwYjWPE42Qednkff1oLqDsfv+PyPLDZi+02aMd2hgOXCJ8qtKMhtwShF LFeiWf75lDCho26yH3T4Hdpu7tHVHGjH0uePFk9ySLIpT3rC5wdlRpf1CbS0VHN0K4k0 Npc/Sbuue4LjXd5ZETUSC0eus9OsjoZWN952cmyQ3j5ETv/qMqlARsDRXX5MVayXpfEm LbuA== X-Gm-Message-State: AMke39kXvg8Qwk84AM8YO/J2cpJx2G89zKf2BkMZ+AOX6jAyofcPkMIBMBM5GJlUDoc+Uw== X-Received: by 10.223.179.15 with SMTP id j15mr10051775wrd.159.1487449855903; Sat, 18 Feb 2017 12:30:55 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:8c2:3900:48ac:d537:1a61:c3e1]) by smtp.gmail.com with ESMTPSA id a14sm4888854wrc.66.2017.02.18.12.30.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Feb 2017 12:30:55 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Christopher Li , Luc Van Oostenryck Subject: [PATCH 2/5] add test case for scope of C99 for-loop declarations Date: Sat, 18 Feb 2017 21:30:45 +0100 Message-Id: <20170218203048.22276-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170218203048.22276-1-luc.vanoostenryck@gmail.com> References: <20170218203048.22276-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 Insure that variable declared inside a C99 for-loop have their scope restricted to this loop. Signed-off-by: Luc Van Oostenryck --- validation/c99-for-loop-decl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 validation/c99-for-loop-decl.c diff --git a/validation/c99-for-loop-decl.c b/validation/c99-for-loop-decl.c new file mode 100644 index 000000000..c2ceaab99 --- /dev/null +++ b/validation/c99-for-loop-decl.c @@ -0,0 +1,18 @@ +static int bad_scope(void) +{ + int r = 0; + + for (int i = 0; i < 10; i++) { + r = i; + } + + return i; /* check-should-fail */ +} + +/* + * check-name: C99 for-loop declarations + * + * check-error-start +c99-for-loop-decl.c:9:16: error: undefined identifier 'i' + * check-error-end + */