Improve some diagnostics around self-initialization. The uninitialized checker does not warn on self-initialization, but does warn later if the variable is used. GCC also has a -Winit-self which will enable a -Wuninitialized warning for self-initialized. -Winit-self is active in -Wall
There's also the matter of the variable being const. GCC -Wuninitialized will warn on a const self-initialized with or without -Winit-self.
This patch will make it so that const self-initialization is always warned on under -Wuninitialized. Since Clang does not use warning flags to control other warnings, -Winit-self will be a new warning group for non-const self-initialized. -Winit-self will also be in -Wall via -Wmost.
// GCC - warn with -Wuninitialized and -Winit-self // Clang - no warning // Clang with patch - warn with -Winit-self void f1() { int x = x; } // GCC - warn with -Wuninitialized // Clang - no warning // Clang with patch - warn with -Wuninitialized void f2() { const int x = x; }