[cfe-dev] -Wmissing-variable-declaration

Tobias Grosser tobias at grosser.es
Fri Oct 28 12:53:52 PDT 2011


On 10/28/2011 08:15 PM, Ed Schouten wrote:
> Hi all,
>
> Before I start, IANACH (I Am Not A Compiler Hacker), so don't blame me
> if my code is horrible.
>
> Something I've noticed in large code bases (e.g. FreeBSD), is that even
> though people use compiler flags like -Wmissing-prototypes and fix their
> code accordingly, the same type of problem exists for global variables.
> This could in theory cause certain optimisations to be missed, but it
> also causes namespace issues.
>
> So my idea would be to have a compiler flag that would cause Clang to
> generate a warning for this. So for example:
>
> Good:
>
> 	static int i;
> 	extern int j;
> 	int j;
>
> Bad:
>
> 	int k;
>
> Attached is a patch that adds a new warning flag called
> -Wmissing-variable-declaration that implements this behaviour. Any
> comments?

Hi Ed,

I cannot comment on the code or if this is regarded useful, but you 
should definitely include a test case in your patch.

Tobi



More information about the cfe-dev mailing list