This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[C PATCH] Fix PR63877
- From: Marek Polacek <polacek at redhat dot com>
- To: "Joseph S. Myers" <joseph at codesourcery dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 24 Nov 2014 15:52:54 +0100
- Subject: [C PATCH] Fix PR63877
- Authentication-results: sourceware.org; auth=none
This PR is basically the same as PR54113, except this time it's about
-Wmissing-declarations and not about -Wmissing-prototypes. The problem
here is that we were emitting bogus warning for a correct use of an
inline function. Thus fixed in the same way as PR54113, that is, don't
warn for inline functions.
Bootstrapped/regtested on ppc64-linux, ok for trunk?
2014-11-24 Marek Polacek <polacek@redhat.com>
PR c/63877
* c-decl.c (start_function): Disable -Wmissing-declarations warning
for inline functions.
* gcc.dg/pr63877.c: New test.
diff --git gcc/c/c-decl.c gcc/c/c-decl.c
index 9288e2c..6413e6f 100644
--- gcc/c/c-decl.c
+++ gcc/c/c-decl.c
@@ -8353,7 +8353,8 @@ start_function (struct c_declspecs *declspecs, struct c_declarator *declarator,
else if (warn_missing_declarations
&& TREE_PUBLIC (decl1)
&& old_decl == 0
- && !MAIN_NAME_P (DECL_NAME (decl1)))
+ && !MAIN_NAME_P (DECL_NAME (decl1))
+ && !DECL_DECLARED_INLINE_P (decl1))
warning_at (loc, OPT_Wmissing_declarations,
"no previous declaration for %qD",
decl1);
diff --git gcc/testsuite/gcc.dg/pr63877.c gcc/testsuite/gcc.dg/pr63877.c
index e69de29..5969b39 100644
--- gcc/testsuite/gcc.dg/pr63877.c
+++ gcc/testsuite/gcc.dg/pr63877.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-Wmissing-declarations" } */
+
+inline int foo (void) { return 42; } /* { dg-bogus "no previous declaration" } */
+extern int foo (void);
Marek