[cfe-dev] -Wmissing-variable-declaration

Ed Schouten ed at 80386.nl
Fri Oct 28 12:15:18 PDT 2011


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?

-- 
 Ed Schouten <ed at 80386.nl>
 WWW: http://80386.nl/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: missing-variable-declaration.diff
Type: text/x-diff
Size: 1598 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111028/7803f01e/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111028/7803f01e/attachment.sig>


More information about the cfe-dev mailing list