consider -Wmissing-variable-declarations
Peter Eisentraut <peter@eisentraut.org>
Attachments
- v1-0001-Add-Wmissing-variable-declarations-to-the-standar.patch (text/plain) patch v1-0001
- v1-0002-Convert-some-extern-variables-to-static.patch (text/plain) patch v1-0002
- v1-0003-Add-missing-includes.patch (text/plain) patch v1-0003
- v1-0004-Fix-Wmissing-variable-declarations-warnings-for-f.patch (text/plain) patch v1-0004
- v1-0005-Fix-Wmissing-variable-declarations-warnings-in-bi.patch (text/plain) patch v1-0005
- v1-0006-XXX-Fix-Wmissing-variable-declarations-warnings-f.patch (text/plain) patch v1-0006
- v1-0007-XXX-other-stuff.patch (text/plain) patch v1-0007
In [0] I had noticed that we have no automated verification that global variables are declared in header files. (For global functions, we have this through -Wmissing-prototypes.) As I mentioned there, I discovered the Clang compiler option -Wmissing-variable-declarations, which does exactly that. Clang has supported this for quite some time, and GCC 14, which was released a few days ago, now also supports it. I went and installed this option into the standard build flags and cleaned up the warnings it found, which revealed a number of interesting things. I think these checks are important. We have been trying to mark global variables as PGDLLIMPORT consistently, but that only catches variables declared in header files. Also, a threading project would surely benefit from global variables (thread-local variables?) having consistent declarations. Attached are patches organized by sub-topic. The most dubious stuff is in patches 0006 and 0007. A bunch of GUC-related variables are not in header files but are pulled in via ad-hoc extern declarations. I can't recognize an intentional scheme there, probably just done for convenience or copied from previous practice. These should be organized into appropriate header files. [0]: https://www.postgresql.org/message-id/c4ac402f-9d7b-45fa-bbc1-4a5bf0a9f206@eisentraut.org
Commits
-
Use CXXFLAGS instead of CFLAGS for linking C++ code
- b9f7ceabd820 16.14 landed
- b6b7e96365eb 17.10 landed
- 41d75b9a4a1c 15.18 landed
- 231570d33581 14.23 landed
- 365b5a345b26 18.0 landed
-
Add -Wmissing-variable-declarations to the standard compilation flags
- 66188912566b 18.0 landed
-
Include bison header files into implementation files
- 9fb855fe1ae0 18.0 landed
-
Fix -Wmissing-variable-declarations warnings for float.c special case
- 37c6923cf3d8 18.0 landed
-
Add extern declarations for Bison global variables
- ab61c40bfa2b 18.0 landed
-
Move all extern declarations for GUC variables to header files
- 774d47b6c01a 18.0 landed
-
Move extern declarations for EXEC_BACKEND to header files
- d3cc5ffe81f6 18.0 landed
-
Get rid of a global variable
- 935e675f3c9e 18.0 landed
-
Add missing includes for some global variables
- 881455e57b12 18.0 landed
-
Convert some extern variables to static
- 720b0eaae9b8 18.0 landed
-
Improve some global variable declarations
- 8f8bcb88833e 18.0 landed
-
Remove useless extern keywords
- 3fb59e789dd9 18.0 landed