postgresql/src/include/nodes
Tom Lane 1c27d16e6e Revise tree-walk APIs to improve spec compliance & silence warnings.
expression_tree_walker and allied functions have traditionally
declared their callback functions as, say, "bool (*walker) ()"
to allow for variation in the declared types of the callback
functions' context argument.  This is apparently going to be
forbidden by the next version of the C standard, and the latest
version of clang warns about that.  In any case it's always
been pretty poor for error-detection purposes, so fixing it is
a good thing to do.

What we want to do is change the callback argument declarations to
be like "bool (*walker) (Node *node, void *context)", which is
correct so far as expression_tree_walker and friends are concerned,
but not change the actual callback functions.  Strict compliance with
the C standard would require changing them to declare their arguments
as "void *context" and then cast to the appropriate context struct
type internally.  That'd be very invasive and it would also introduce
a bunch of opportunities for future bugs, since we'd no longer have
any check that the correct sort of context object is passed by outside
callers or internal recursion cases.  Therefore, we're just going
to ignore the standard's position that "void *" isn't necessarily
compatible with struct pointers.  No machine built in the last forty
or so years actually behaves that way, so it's not worth introducing
bug hazards for compatibility with long-dead hardware.

Therefore, to silence these compiler warnings, introduce a layer of
macro wrappers that cast the supplied function name to the official
argument type.  Thanks to our use of -Wcast-function-type, this will
still produce a warning if the supplied function is seriously
incompatible with the required signature, without going as far as
the official spec restriction does.

This method fixes the problem without any need for source code changes
outside nodeFuncs.h/.c.  However, it is an ABI break because the
physically called functions now have names ending in "_impl".  Hence
we can only fix it this way in HEAD.  In the back branches, we'll have
to settle for disabling -Wdeprecated-non-prototype.

Discussion: https://postgr.es/m/CA+hUKGKpHPDTv67Y+s6yiC8KH5OXeDg6a-twWo_xznKTcG0kSA@mail.gmail.com
2022-09-20 18:03:22 -04:00
..
.gitignore Automatically generate node support functions 2022-07-09 08:53:59 +02:00
bitmapset.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
execnodes.h Doc: rearrange high-level commentary about node support coverage. 2022-07-09 15:10:15 -04:00
extensible.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
lockoptions.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
makefuncs.h Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
memnodes.h Improve performance of and reduce overheads of memory management 2022-08-29 17:15:00 +12:00
nodeFuncs.h Revise tree-walk APIs to improve spec compliance & silence warnings. 2022-09-20 18:03:22 -04:00
nodes.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
params.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
parsenodes.h Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
pathnodes.h Improve performance of adjust_appendrel_attrs_multilevel. 2022-08-18 12:36:16 -04:00
pg_list.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00
plannodes.h Mark Scan as an abstract node type, too. 2022-07-09 13:58:06 -04:00
primnodes.h Revert SQL/JSON features 2022-09-01 17:07:14 -04:00
print.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
readfuncs.h Apply PGDLLIMPORT markings broadly. 2022-04-08 08:16:38 -04:00
replnodes.h Fix limitations on what SQL commands can be issued to a walsender. 2022-01-24 15:33:38 -05:00
subscripting.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
supportnodes.h Teach planner and executor about monotonic window funcs 2022-04-08 10:34:36 +12:00
tidbitmap.h Update copyright for 2022 2022-01-07 19:04:57 -05:00
value.h Harmonize more parameter names in bulk. 2022-09-20 13:09:30 -07:00