From patchwork Wed Dec 4 17:47:09 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 296599 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 81C0C2C00A6 for ; Thu, 5 Dec 2013 04:47:37 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=PHokNJybUpJZ5gPnAjDvVm1WnU5YaBSb3shLfIsWwFl1GzslW90fg B/Z1PkJYIigv/HADGM/vRgsVHFbzL6GmZ8mQ3svU42cD7wH6mzWZJsVfkeIMcHWN TTAhDcSg9vII/Tcjzux/aU6D1ut1U2G2MMxoIQIniMTtajhso02LHM= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=G84k1eYmPp99pNeE9TEpKGjKMw8=; b=AL1I3Gx0OTD7qhpoPBUA gEOZ3WJStM//v/vsWBlxwhQubaZKx8vK3PX8kLMnSlgzDEKtngdPeJcyqFJeiLvV fuGrlyddKymvnOgTWVZBFTgDQaEwlJw1nv7i/OWEq42f6uJ3jBx73Ge6Ny6HMOgc /TpTHzOksUL/pHfUHz+Adl0= Received: (qmail 26291 invoked by alias); 4 Dec 2013 17:47:28 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 26279 invoked by uid 89); 4 Dec 2013 17:47:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=AWL, BAYES_00, RDNS_NONE, SPF_HELO_PASS, SPF_PASS autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from Unknown (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 04 Dec 2013 17:47:24 +0000 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id rB4HlEEL022359 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 4 Dec 2013 12:47:14 -0500 Received: from redhat.com (ovpn-116-42.ams2.redhat.com [10.36.116.42]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id rB4HlADY007204 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Wed, 4 Dec 2013 12:47:13 -0500 Date: Wed, 4 Dec 2013 18:47:09 +0100 From: Marek Polacek To: GCC Patches , "Joseph S. Myers" Subject: [PATCH] Don't warn for missing prototypes on inline fns (PR c/54113) Message-ID: <20131204174709.GH32420@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) In C99, one way how to deal with inline functions is to put definition of the function into header: inline void foo (void) { /* ... */ } and put the declaration into exactly one .c file, with extern keyword (it can also have inline keyword): extern void foo (void); But in this case, we shouldn't issue the "missing prototype" warning. So the following should suppress that warning in C99 mode, when -fgnu89-inline is not in effect. (But the function could still have the gnu_inline attribute, so it might be better to disable that warning for all inline functions?) Regtested/bootstrapped on x86_64-unknown-linux-gnu. Ok for trunk? 2013-12-04 Marek Polacek PR c/54113 c/ * c-decl.c (start_function): Don't warn for missing prototype for inline functions in C99+. testsuite/ * gcc.dg/pr54113.c: New test. Marek --- gcc/c/c-decl.c.mp3 2013-12-04 17:11:43.063878926 +0100 +++ gcc/c/c-decl.c 2013-12-04 18:32:17.567008028 +0100 @@ -7974,7 +7974,10 @@ start_function (struct c_declspecs *decl && old_decl != error_mark_node && TREE_PUBLIC (decl1) && !MAIN_NAME_P (DECL_NAME (decl1)) - && C_DECL_ISNT_PROTOTYPE (old_decl)) + && C_DECL_ISNT_PROTOTYPE (old_decl) + && !(DECL_DECLARED_INLINE_P (decl1) + && flag_isoc99 + && !flag_gnu89_inline)) warning_at (loc, OPT_Wmissing_prototypes, "no previous prototype for %qD", decl1); /* Optionally warn of any def with no previous prototype --- gcc/testsuite/gcc.dg/pr54113.c.mp3 2013-12-04 17:52:45.671288940 +0100 +++ gcc/testsuite/gcc.dg/pr54113.c 2013-12-04 17:36:43.000000000 +0100 @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-std=c99" } */ + +inline int foo (void) { return 42; } /* { dg-bogus "no previous prototype" } */ +extern int foo(void);