diff options
| author | Peter Eisentraut | 2024-08-03 09:42:37 +0000 |
|---|---|---|
| committer | Peter Eisentraut | 2024-08-03 09:51:02 +0000 |
| commit | 66188912566b5614dff095ae86f4b1e06d58e875 (patch) | |
| tree | 3c86ba7c2b967437b29f83eb49231f43577ac023 /src | |
| parent | 7926a9a80f6daf0fcc1feb1bee5c51fd001bc173 (diff) | |
Add -Wmissing-variable-declarations to the standard compilation flags
This warning flag detects global variables not declared in header
files. This is similar to what -Wmissing-prototypes does for
functions. (More correctly, it is similar to what
-Wmissing-declarations does for functions, but -Wmissing-prototypes is
a superset of that in C.)
This flag is new in GCC 14. Clang has supported it for a while.
Several recent commits have cleaned up warnings triggered by this, so
it should now be clean.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/flat/e0a62134-83da-4ba4-8cdb-ceb0111c95ce@eisentraut.org
Diffstat (limited to 'src')
| -rw-r--r-- | src/Makefile.global.in | 1 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/Makefile.regress | 2 | ||||
| -rw-r--r-- | src/interfaces/ecpg/test/meson.build | 1 | ||||
| -rw-r--r-- | src/makefiles/meson.build | 2 | ||||
| -rw-r--r-- | src/tools/pg_bsd_indent/Makefile | 2 | ||||
| -rw-r--r-- | src/tools/pg_bsd_indent/meson.build | 1 |
6 files changed, 8 insertions, 1 deletions
diff --git a/src/Makefile.global.in b/src/Makefile.global.in index 83b91fe9167..42f50b49761 100644 --- a/src/Makefile.global.in +++ b/src/Makefile.global.in @@ -266,6 +266,7 @@ CFLAGS_POPCNT = @CFLAGS_POPCNT@ CFLAGS_CRC = @CFLAGS_CRC@ CFLAGS_XSAVE = @CFLAGS_XSAVE@ PERMIT_DECLARATION_AFTER_STATEMENT = @PERMIT_DECLARATION_AFTER_STATEMENT@ +PERMIT_MISSING_VARIABLE_DECLARATIONS = @PERMIT_MISSING_VARIABLE_DECLARATIONS@ CXXFLAGS = @CXXFLAGS@ LLVM_CPPFLAGS = @LLVM_CPPFLAGS@ diff --git a/src/interfaces/ecpg/test/Makefile.regress b/src/interfaces/ecpg/test/Makefile.regress index b0647cd2c5f..9bf0efa40b9 100644 --- a/src/interfaces/ecpg/test/Makefile.regress +++ b/src/interfaces/ecpg/test/Makefile.regress @@ -3,7 +3,7 @@ override CPPFLAGS := -I../../include -I$(top_srcdir)/src/interfaces/ecpg/include \ -I$(libpq_srcdir) $(CPPFLAGS) -override CFLAGS += $(PTHREAD_CFLAGS) +override CFLAGS += $(PTHREAD_CFLAGS) $(PERMIT_MISSING_VARIABLE_DECLARATIONS) LDFLAGS_INTERNAL += -L../../ecpglib -lecpg -L../../pgtypeslib -lpgtypes $(libpq) diff --git a/src/interfaces/ecpg/test/meson.build b/src/interfaces/ecpg/test/meson.build index c1e508ccc82..8fd284071f2 100644 --- a/src/interfaces/ecpg/test/meson.build +++ b/src/interfaces/ecpg/test/meson.build @@ -27,6 +27,7 @@ testprep_targets += pg_regress_ecpg # create .c files and executables from .pgc files ecpg_test_exec_kw = { + 'c_args': cflags_no_missing_var_decls, 'dependencies': [frontend_code, libpq], 'include_directories': [ecpg_inc], 'link_with': [ecpglib_so, ecpg_compat_so, ecpg_pgtypes_so], diff --git a/src/makefiles/meson.build b/src/makefiles/meson.build index 5618050b306..850e9275845 100644 --- a/src/makefiles/meson.build +++ b/src/makefiles/meson.build @@ -98,6 +98,8 @@ pgxs_kv = { 'CXXFLAGS_SL_MODULE': ' '.join(cxxflags_mod), 'PERMIT_DECLARATION_AFTER_STATEMENT': ' '.join(cflags_no_decl_after_statement), + 'PERMIT_MISSING_VARIABLE_DECLARATIONS': + ' '.join(cflags_no_missing_var_decls), 'CFLAGS_CRC': ' '.join(cflags_crc), 'CFLAGS_POPCNT': ' '.join(cflags_popcnt), diff --git a/src/tools/pg_bsd_indent/Makefile b/src/tools/pg_bsd_indent/Makefile index d922013e40b..f721dfb0d19 100644 --- a/src/tools/pg_bsd_indent/Makefile +++ b/src/tools/pg_bsd_indent/Makefile @@ -25,6 +25,8 @@ OBJS = \ parse.o \ pr_comment.o +$(OBJS): CFLAGS += $(PERMIT_MISSING_VARIABLE_DECLARATIONS) + all: pg_bsd_indent pg_bsd_indent: $(OBJS) | submake-libpgport diff --git a/src/tools/pg_bsd_indent/meson.build b/src/tools/pg_bsd_indent/meson.build index 4387c47740e..87ed4292975 100644 --- a/src/tools/pg_bsd_indent/meson.build +++ b/src/tools/pg_bsd_indent/meson.build @@ -18,6 +18,7 @@ endif pg_bsd_indent = executable('pg_bsd_indent', pg_bsd_indent_sources, + c_args: cflags_no_missing_var_decls, dependencies: [frontend_code], include_directories: include_directories('.'), kwargs: default_bin_args + { |
