[cfe-dev] Overly zealous warning from -Wmissing-prototypes

Abigail via cfe-dev cfe-dev at lists.llvm.org
Tue May 23 07:18:20 PDT 2017


Hi cfe-dev. I believe I've found a bug in Clang's -Wmissing-prototypes warning.
Consider the following C++ code:

void global() {}
namespace { void anonymous() {} }
namespace detail { void detail() {} }
namespace detail { namespace { void detail_anonymous() {} } }
namespace { namespace detail { void anonymous_detail() {} } }

When compiled with GCC -Wmissing-declarations, the functions global() and
detail() give warnings. However, when compiled with Clang -Wmissing-prototypes,
global(), detail() and anonymous_detail() all give warnings. Despite this,
Clang is unable to optimize out anonymous_detail() when it's unused

As an aside: GCC uses '-Wmissing-declarations' to warn if a global function is
defined without a previous declaration and '-Wmissing-prototypes' only to warn
in C/Obj-C cases where a function has a previous declaration that's not a
prototype. Clang uses '-Wmissing-prototypes' for both of these, and the flag
'-Wmissing-declarations' is enabled by default and applies to miscellaneous
other cases.

I've filed a Bugzilla bug at https://bugs.llvm.org/show_bug.cgi?id=33141 .

Thanks,
Abigail
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170523/392d6d45/attachment.html>


More information about the cfe-dev mailing list