Use fallthrough attribute instead of comment

Instead of using comments to mark fallthrough switch cases, use the
fallthrough attribute.  This will (in the future, not here) allow
supporting other compilers besides gcc.  The commenting convention is
only supported by gcc, the attribute is supported by clang, and in the
fullness of time the C23 standard attribute would allow supporting
other compilers as well.

Right now, we package the attribute into a macro called
pg_fallthrough.  This commit defines that macro and replaces the
existing comments with that macro invocation.

We also raise the level of the gcc -Wimplicit-fallthrough= option from
3 to 5 to enforce the use of the attribute.

Reviewed-by: Jelte Fennema-Nio <[email protected]>
Discussion: 
https://www.postgresql.org/message-id/flat/76a8efcd-925a-4eaf-bdd1-d972cd1a32ff%40eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/8354b9d6b602ea549bc8d85cb404771505662a7b

Modified Files
--------------
configure                                          |  40 +++---
configure.ac                                       |   4 +-
contrib/btree_gin/btree_gin.c                      |   2 +-
contrib/ltree/ltxtquery_io.c                       |   2 +-
contrib/pg_trgm/trgm_gin.c                         |  12 +-
contrib/pg_trgm/trgm_gist.c                        |   8 +-
contrib/pgcrypto/pgp-info.c                        |   2 +-
meson.build                                        |   2 +-
src/backend/access/heap/heapam_handler.c           |   2 +-
src/backend/access/nbtree/nbtpreprocesskeys.c      |   4 +-
src/backend/bootstrap/bootstrap.c                  |   2 +-
src/backend/catalog/dependency.c                   |   2 +-
src/backend/catalog/objectaddress.c                |   4 +-
src/backend/catalog/pg_shdepend.c                  |   2 +-
src/backend/commands/explain.c                     |   2 +-
src/backend/commands/tablecmds.c                   |   2 +-
src/backend/commands/trigger.c                     |   2 +-
src/backend/executor/nodeAgg.c                     |   2 +-
src/backend/executor/nodeHash.c                    |  14 +-
src/backend/executor/nodeHashjoin.c                |  10 +-
src/backend/executor/nodeLimit.c                   |   4 +-
src/backend/executor/nodeTidrangescan.c            |   4 +-
src/backend/libpq/auth.c                           |   2 +-
src/backend/optimizer/plan/planner.c               |   4 +-
src/backend/optimizer/util/clauses.c               |   4 +-
src/backend/parser/parse_jsontable.c               |   2 +-
src/backend/parser/parse_utilcmd.c                 |   2 +-
src/backend/partitioning/partprune.c               |  14 +-
src/backend/postmaster/postmaster.c                |   6 +-
src/backend/regex/regc_lex.c                       |   2 +-
src/backend/regex/regcomp.c                        |   2 +-
src/backend/replication/logical/reorderbuffer.c    |   1 +
src/backend/replication/logical/worker.c           |  12 +-
src/backend/replication/walreceiver.c              |   2 +-
src/backend/replication/walreceiverfuncs.c         |   2 +-
src/backend/storage/aio/aio.c                      |   2 +-
src/backend/tcop/postgres.c                        |   4 +-
src/backend/tcop/utility.c                         |   2 +-
src/backend/utils/adt/datetime.c                   |   6 +-
src/backend/utils/adt/formatting.c                 |   8 +-
src/backend/utils/adt/jsonb.c                      |   2 +-
src/backend/utils/adt/jsonb_util.c                 |   2 +-
src/backend/utils/adt/jsonpath.c                   |  12 +-
src/backend/utils/adt/numeric.c                    |  14 +-
src/backend/utils/adt/ruleutils.c                  |   2 +-
src/backend/utils/adt/timestamp.c                  |  54 ++++----
src/backend/utils/adt/xml.c                        |   2 +-
src/backend/utils/cache/catcache.c                 |  12 +-
src/backend/utils/mb/mbutils.c                     |   6 +-
src/backend/utils/misc/guc.c                       |   2 +-
src/backend/utils/misc/guc_funcs.c                 |   2 +-
src/backend/utils/sort/tuplestore.c                |   2 +-
src/bin/pgbench/pgbench.c                          |   6 +-
src/common/hashfn.c                                | 144 ++++++++++-----------
src/common/wchar.c                                 |   6 +-
src/include/c.h                                    |  12 ++
src/include/common/hashfn_unstable.h               |  20 +--
src/interfaces/ecpg/pgtypeslib/interval.c          |   6 +-
src/interfaces/libpq/fe-secure.c                   |   2 +-
src/pl/plpgsql/src/pl_exec.c                       |   6 +-
src/pl/tcl/pltcl.c                                 |   2 +-
src/port/snprintf.c                                |   2 +-
.../test_json_parser_incremental.c                 |   2 +-
src/timezone/zic.c                                 |   8 +-
src/tools/pg_bsd_indent/indent.c                   |   4 +-
src/tools/pg_bsd_indent/parse.c                    |   4 +-
66 files changed, 277 insertions(+), 264 deletions(-)

Reply via email to