[LLVMbugs] [Bug 11257] New: "Unused parameter" warnings when compiling headers with gcc 4.5.3 and -Wall

Duncan Sands baldrick at free.fr
Fri Oct 28 12:32:11 PDT 2011

Hi Kevin,

> Just this week, I decided to try the latest LLVM – the current trunk version
> (3.1svn) and I also tried the tags/RELEASE_30 version.  I was surprised and
> disappointed to see that, combined with the new gcc, and the changes to the
> headers in the intervening time, our code no longer compiles cleanly.   In
> particular, we are suffering several "Unused parameter" warnings.  These
> warnings only appear when including headers for which functions are DEFINED -
> rather than just declared.
> It isn't obvious why these functions take these unused parameters, perhaps to
> provide future functionality. I was able to suppress the warnings by adding a
> harmless use of the offending variables in the bodies of the functions that
> appear in the headers.

I cleaned up a bunch of these a week or so ago - so it used to be worse!  C++
allows the following trick: if a parameter is unused, don't give it a name.
For example, in
   void foo(int x) {
if x is unused then you can write
   void foo(int) {
and the warning goes away.

> Our project doesn't use all the headers in LLVM by any means, so I obviously
> don't have a complete list of all instances of this problem.  But I will list
> all the instances that we're seeing in our builds, with associated line numbers
> and names for each warning:

One curiosity I noticed is that you don't see this while compiling LLVM itself,
only when compiling projects that use LLVM.  I don't know why.  Probably that's
the reason they haven't been fixed: they don't show up in LLVM builds.

> I'd be glad to attach my edited versions of these files upon request.

Feel free to send a patch.  It probably won't be fixed otherwise since this
presumably doesn't impact anyone else.

Ciao, Duncan.

More information about the llvm-bugs mailing list