This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[C PATCH] Don't warn about gnu_inline functions without definitions (PR c/63453)

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.

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);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]