From patchwork Wed Jul 19 20:05:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramsay Jones X-Patchwork-Id: 9853181 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 D572B602C8 for ; Wed, 19 Jul 2017 20:05:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C789A2855E for ; Wed, 19 Jul 2017 20:05:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B872E28675; Wed, 19 Jul 2017 20:05:23 +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.9 required=2.0 tests=BAYES_00,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 87D852855E for ; Wed, 19 Jul 2017 20:05:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753913AbdGSUFW (ORCPT ); Wed, 19 Jul 2017 16:05:22 -0400 Received: from avasout05.plus.net ([84.93.230.250]:35219 "EHLO avasout05.plus.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753346AbdGSUFV (ORCPT ); Wed, 19 Jul 2017 16:05:21 -0400 Received: from [10.0.2.15] ([143.159.212.52]) by avasout05 with smtp id mk5J1v00418PUFB01k5Ktt; Wed, 19 Jul 2017 21:05:20 +0100 X-CM-Score: 0.00 X-CNFS-Analysis: v=2.2 cv=Iav3YSia c=1 sm=1 tr=0 a=CKmocqUIrzA4K3l9YJ19NQ==:117 a=CKmocqUIrzA4K3l9YJ19NQ==:17 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=_R96hyLk8TejAcdPHkkA:9 a=QEXdDO2ut3YA:10 a=yJM6EZoI5SlJf8ks9Ge_:22 X-AUTH: ramsayjones@:2500 From: Ramsay Jones Subject: [PATCH 1/2] lib: workaround the 'redeclared with different type' errors To: Christopher Li Cc: Luc Van Oostenryck , Sparse Mailing-list Message-ID: <74a1852c-a9ef-ec91-d9da-925c7e8def94@ramsayjones.plus.com> Date: Wed, 19 Jul 2017 21:05:18 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-GB 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 The 'selfcheck' make target issues sparse errors for function symbols 'error_die' and 'die', like so: CHECK lib.c lib.c:194:6: error: symbol 'error_die' redeclared with different type \ (originally declared at lib.h:98) - different modifiers lib.c:203:6: error: symbol 'die' redeclared with different type \ (originally declared at lib.h:94) - different modifiers This is caused by the 'noreturn' attribute being treated similar to a type qualifier and insisting that, not only the declaration and the definition of the function have the 'noreturn', but that they have the attribute in the same position. In order to suppress the error, move the attribute(s) to the beginning of the declaration, in the header file, and add an 'noreturn' attribute at the beginning of the definition (in lib.c). Signed-off-by: Ramsay Jones --- Hi Chris, I meant to send this yesterday, but I got busy with something else. :( This is the 'workaround' that I have used on git to suppress these errors (except for the regex example, which is in _imported_ code). As I said, this also happens with the 'pure' attribute. ATB, Ramsay Jones lib.c | 2 ++ lib.h | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/lib.c b/lib.c index ce66a81..73e9a2f 100644 --- a/lib.c +++ b/lib.c @@ -191,6 +191,7 @@ void expression_error(struct expression *expr, const char *fmt, ...) expr->ctype = &bad_ctype; } +NORETURN_ATTR void error_die(struct position pos, const char * fmt, ...) { va_list args; @@ -200,6 +201,7 @@ void error_die(struct position pos, const char * fmt, ...) exit(1); } +NORETURN_ATTR void die(const char *fmt, ...) { va_list args; diff --git a/lib.h b/lib.h index c90e0e3..307ccae 100644 --- a/lib.h +++ b/lib.h @@ -91,11 +91,16 @@ struct token *expect(struct token *, int, const char *); #define NORETURN_ATTR #define SENTINEL_ATTR #endif -extern void die(const char *, ...) FORMAT_ATTR(1) NORETURN_ATTR; + +FORMAT_ATTR(1) NORETURN_ATTR +extern void die(const char *, ...); + +FORMAT_ATTR(2) NORETURN_ATTR +extern void error_die(struct position, const char *, ...); + extern void info(struct position, const char *, ...) FORMAT_ATTR(2); extern void warning(struct position, const char *, ...) FORMAT_ATTR(2); extern void sparse_error(struct position, const char *, ...) FORMAT_ATTR(2); -extern void error_die(struct position, const char *, ...) FORMAT_ATTR(2) NORETURN_ATTR; extern void expression_error(struct expression *, const char *, ...) FORMAT_ATTR(2); #define ERROR_CURR_PHASE (1 << 0)