From patchwork Wed Feb 6 01:14:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 10798719 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 6A8FA13B4 for ; Wed, 6 Feb 2019 01:14:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4B50D2B560 for ; Wed, 6 Feb 2019 01:14:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C20D2B928; Wed, 6 Feb 2019 01:14:47 +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=-7.9 required=2.0 tests=BAYES_00,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 970302B560 for ; Wed, 6 Feb 2019 01:14:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbfBFBOq (ORCPT ); Tue, 5 Feb 2019 20:14:46 -0500 Received: from avasout05.plus.net ([84.93.230.250]:43649 "EHLO avasout05.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726062AbfBFBOq (ORCPT ); Tue, 5 Feb 2019 20:14:46 -0500 Received: from [10.0.2.15] ([146.198.133.33]) by smtp with ESMTPA id rBnXgOVyOE0CvrBnYgXEqk; Wed, 06 Feb 2019 01:14:44 +0000 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.3 cv=Sse+FsG0 c=1 sm=1 tr=0 a=VCDsReDbrwk4B7AcQzWGLw==:117 a=VCDsReDbrwk4B7AcQzWGLw==:17 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=ACDQRgRqAhCVUwr3ZscA:9 a=QEXdDO2ut3YA:10 a=yJM6EZoI5SlJf8ks9Ge_:22 X-AUTH: ramsayjones@:2500 To: Luc Van Oostenryck Cc: Sparse Mailing-list From: Ramsay Jones Subject: [PATCH] tests: add test to illustrate problem on git codebase Message-ID: <91231fc7-4fe2-33d1-4fd1-a1b0ec3ff63a@ramsayjones.plus.com> Date: Wed, 6 Feb 2019 01:14:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 Content-Language: en-GB X-CMAE-Envelope: MS4wfP2TpQD5nHMoxa0QV7b2tvjeQGGC5QAm6Cql/r5NLNdsNysvJVv3DRh3+v7TfaPmX/U97g5yeBNZC+i34vm4dJYqNPhK3xkPslBIQsd3IClZu/776k0A w07I2tSiRd0C1EkFIQWIeJ8CsyByN/+WmCuML9+A+1IbWMGNXTWK68AkOFFT6urJVLi0dph1kV0EDA== 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 Add a new test file which demonstrates some problems which can be seen on the git codebase. gcc does not complain about this file: $ gcc -Wall -c validation/function-redecl2.c $ ... but sparse does: $ sparse validation/function-redecl2.c validation/function-redecl2.c:6:5: error: symbol 'func0' redeclared with different type (originally declared at validation/function-redecl2.c:3) - different modifiers validation/function-redecl2.c:13:6: error: symbol 'func1' redeclared with different type (originally declared at validation/function-redecl2.c:11) - different modifiers validation/function-redecl2.c:21:6: error: symbol 'func2' redeclared with different type (originally declared at validation/function-redecl2.c:18) - different modifiers $ Note that func0 and func2 are essentially the same example, apart from the attribute used, to demonstrate that the issue isn't caused by the 'pure' attribute. Also, examples like func1 have occurred several times in git and, although they can be worked around (eg. See [1]), it would be preferable if this were not necessary. This test is marked 'check-know-to-fail'. [1] (git) commit 3d7dd2d3b6 ("usage: add NORETURN to BUG() function definitions", 2017-05-21). Signed-off-by: Ramsay Jones --- Hi Luc, As promised, a 'known-to-fail' test case. Thanks! ATB, Ramsay Jones validation/function-redecl2.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 validation/function-redecl2.c diff --git a/validation/function-redecl2.c b/validation/function-redecl2.c new file mode 100644 index 0000000..c7bb93b --- /dev/null +++ b/validation/function-redecl2.c @@ -0,0 +1,32 @@ +extern void exit (int __status) __attribute__ ((__noreturn__)); + +int func0(int a) __attribute__ ((pure)); + +__attribute__ ((pure)) +int func0(int a) +{ + return 0; +} + +__attribute__ ((noreturn)) void func1(int a); + +void func1(int a) +{ + exit(0); +} + +void func2(int a) __attribute__ ((noreturn)); + +__attribute__ ((noreturn)) +void func2(int a) +{ + exit(0); +} + +/* + * check-name: function-redecl2 + * + * check-known-to-fail + * + */ +