From patchwork Fri Oct 3 17:37:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Polacek X-Patchwork-Id: 396362 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)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BEC3A140174 for ; Sat, 4 Oct 2014 03:37:24 +1000 (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:cc:subject:message-id:mime-version:content-type; q=dns; s=default; b=uSOGjOBKZXxlOmHc70xmICccDGs0ro5shN2utPKWk/ZsIWU8TR Vwx8cradw+tb8XZngZcJtWqnvZrlThN7q1Ok/mt2peI83+xJlekUnzFbFv3b2DcC 8837hdOZ8ALs4S+7GjpA1SCzh56PM6Q81LeVIKr7ANKDL87fMTeluIfOc= 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:cc:subject:message-id:mime-version:content-type; s= default; bh=33sjhkD0+rLXyDyx1e9clPGThW0=; b=CfNDbjESB97cbmUQgaf1 7SCxmzG4GSpaRl4ZeaerzWAr2pnnkKePp8upc0F8t6hPRw2kNm4FWkgUAPaenLdq cgi1ABl6yalOCTH/Qgyo9k44GTN6NHT9ZWzfuL+Fsqsa041dO5URBIyGLUydq3zg ulG8fi1e8OlkAs6p91UeSZw= Received: (qmail 25457 invoked by alias); 3 Oct 2014 17:37:18 -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 25438 invoked by uid 89); 3 Oct 2014 17:37:15 -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, SPF_HELO_PASS, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 03 Oct 2014 17:37:14 +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 s93HbA5B013697 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 3 Oct 2014 13:37:11 -0400 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 s93Hb6bD009698 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=NO); Fri, 3 Oct 2014 13:37:09 -0400 Date: Fri, 3 Oct 2014 19:37:06 +0200 From: Marek Polacek To: "Joseph S. Myers" Cc: GCC Patches Subject: [C PATCH] Don't warn about gnu_inline functions without definitions (PR c/63453) Message-ID: <20141003173706.GF3503@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) While looking into something else I noticed that we produce C99ish "inline function declared but never defined" warning even for functions marked as gnu_inline, if not in GNU89 or if -fgnu89-inline is not in effect, because the warning was guarded only by !flag_gnu89_inline. Bootstrapped/regtested on x86_64-linux, ok for trunk? 2014-10-03 Marek Polacek PR c/63453 * c-decl.c (pop_scope): Don't warn about "inline function declared but never defined" for functions marked with gnu_inline attribute. * gcc.dg/pr63453.c: New test. Marek diff --git gcc/c/c-decl.c gcc/c/c-decl.c index b4995a6..ce5a8de 100644 --- gcc/c/c-decl.c +++ gcc/c/c-decl.c @@ -1177,7 +1177,8 @@ pop_scope (void) /* C99 6.7.4p6: "a function with external linkage... declared with an inline function specifier ... shall also be defined in the same translation unit." */ - if (!flag_gnu89_inline) + if (!flag_gnu89_inline + && !lookup_attribute ("gnu_inline", DECL_ATTRIBUTES (p))) pedwarn (input_location, 0, "inline function %q+D declared but never defined", p); DECL_EXTERNAL (p) = 1; diff --git gcc/testsuite/gcc.dg/pr63453.c gcc/testsuite/gcc.dg/pr63453.c index e69de29..e6337aa 100644 --- gcc/testsuite/gcc.dg/pr63453.c +++ gcc/testsuite/gcc.dg/pr63453.c @@ -0,0 +1,8 @@ +/* PR c/63453 */ +/* { dg-do compile } */ +/* { dg-options "-std=gnu11" } */ + +inline int fn1 (void); /* { dg-warning "declared but never defined" } */ +extern inline int fn2 (void); /* { dg-warning "declared but never defined" } */ +inline int __attribute__ ((gnu_inline)) fn3 (void); +extern inline int __attribute__ ((gnu_inline)) fn4 (void);