From e4e1a0160977be5dc13281f803f1c9a2132b197b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 20 Jan 2026 11:35:16 +0100 Subject: [PATCH 2/5] 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. --- 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 +- .../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 | 12 +- 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, 281 insertions(+), 268 deletions(-) diff --git a/configure b/configure index fb6a4914b06..4f41b1ba007 100755 --- a/configure +++ b/configure @@ -5524,15 +5524,15 @@ fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wimplicit-fallthrough=3, for CFLAGS" >&5 -$as_echo_n "checking whether ${CC} supports -Wimplicit-fallthrough=3, for CFLAGS... " >&6; } -if ${pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3+:} false; then : +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CC} supports -Wimplicit-fallthrough=5, for CFLAGS" >&5 +$as_echo_n "checking whether ${CC} supports -Wimplicit-fallthrough=5, for CFLAGS... " >&6; } +if ${pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5+:} false; then : $as_echo_n "(cached) " >&6 else pgac_save_CFLAGS=$CFLAGS pgac_save_CC=$CC CC=${CC} -CFLAGS="${CFLAGS} -Wimplicit-fallthrough=3" +CFLAGS="${CFLAGS} -Wimplicit-fallthrough=5" ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5547,31 +5547,31 @@ main () } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : - pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3=yes + pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5=yes else - pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3=no + pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="$pgac_save_CFLAGS" CC="$pgac_save_CC" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3" >&5 -$as_echo "$pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3" >&6; } -if test x"$pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_3" = x"yes"; then - CFLAGS="${CFLAGS} -Wimplicit-fallthrough=3" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5" >&5 +$as_echo "$pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5" >&6; } +if test x"$pgac_cv_prog_CC_cflags__Wimplicit_fallthrough_5" = x"yes"; then + CFLAGS="${CFLAGS} -Wimplicit-fallthrough=5" fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports -Wimplicit-fallthrough=3, for CXXFLAGS" >&5 -$as_echo_n "checking whether ${CXX} supports -Wimplicit-fallthrough=3, for CXXFLAGS... " >&6; } -if ${pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${CXX} supports -Wimplicit-fallthrough=5, for CXXFLAGS" >&5 +$as_echo_n "checking whether ${CXX} supports -Wimplicit-fallthrough=5, for CXXFLAGS... " >&6; } +if ${pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5+:} false; then : $as_echo_n "(cached) " >&6 else pgac_save_CXXFLAGS=$CXXFLAGS pgac_save_CXX=$CXX CXX=${CXX} -CXXFLAGS="${CXXFLAGS} -Wimplicit-fallthrough=3" +CXXFLAGS="${CXXFLAGS} -Wimplicit-fallthrough=5" ac_save_cxx_werror_flag=$ac_cxx_werror_flag ac_cxx_werror_flag=yes ac_ext=cpp @@ -5592,9 +5592,9 @@ main () } _ACEOF if ac_fn_cxx_try_compile "$LINENO"; then : - pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3=yes + pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5=yes else - pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3=no + pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5=no fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_ext=c @@ -5607,10 +5607,10 @@ ac_cxx_werror_flag=$ac_save_cxx_werror_flag CXXFLAGS="$pgac_save_CXXFLAGS" CXX="$pgac_save_CXX" fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3" >&5 -$as_echo "$pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3" >&6; } -if test x"$pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_3" = x"yes"; then - CXXFLAGS="${CXXFLAGS} -Wimplicit-fallthrough=3" +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5" >&5 +$as_echo "$pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5" >&6; } +if test x"$pgac_cv_prog_CXX_cxxflags__Wimplicit_fallthrough_5" = x"yes"; then + CXXFLAGS="${CXXFLAGS} -Wimplicit-fallthrough=5" fi diff --git a/configure.ac b/configure.ac index d3febfe58f1..93503753971 100644 --- a/configure.ac +++ b/configure.ac @@ -516,8 +516,8 @@ if test "$GCC" = yes -a "$ICC" = no; then PGAC_PROG_CXX_CFLAGS_OPT([-Wendif-labels]) PGAC_PROG_CC_CFLAGS_OPT([-Wmissing-format-attribute]) PGAC_PROG_CXX_CFLAGS_OPT([-Wmissing-format-attribute]) - PGAC_PROG_CC_CFLAGS_OPT([-Wimplicit-fallthrough=3]) - PGAC_PROG_CXX_CFLAGS_OPT([-Wimplicit-fallthrough=3]) + PGAC_PROG_CC_CFLAGS_OPT([-Wimplicit-fallthrough=5]) + PGAC_PROG_CXX_CFLAGS_OPT([-Wimplicit-fallthrough=5]) PGAC_PROG_CC_CFLAGS_OPT([-Wcast-function-type]) PGAC_PROG_CXX_CFLAGS_OPT([-Wcast-function-type]) PGAC_PROG_CC_CFLAGS_OPT([-Wshadow=compatible-local]) diff --git a/contrib/btree_gin/btree_gin.c b/contrib/btree_gin/btree_gin.c index afb8b3820af..8dfbaa4781d 100644 --- a/contrib/btree_gin/btree_gin.c +++ b/contrib/btree_gin/btree_gin.c @@ -120,7 +120,7 @@ gin_btree_extract_query(FunctionCallInfo fcinfo, case BTGreaterEqualStrategyNumber: case BTGreaterStrategyNumber: *ptr_partialmatch = true; - /* FALLTHROUGH */ + pg_fallthrough; case BTEqualStrategyNumber: /* If we have a conversion function, apply it */ if (cvt_fns && cvt_fns[rhs_code]) diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c index 91a2222eaa9..c8a0b673f1c 100644 --- a/contrib/ltree/ltxtquery_io.c +++ b/contrib/ltree/ltxtquery_io.c @@ -277,7 +277,7 @@ makepol(QPRS_STATE *state) case ERR: if (SOFT_ERROR_OCCURRED(state->escontext)) return ERR; - /* fall through */ + pg_fallthrough; default: ereturn(state->escontext, ERR, (errcode(ERRCODE_SYNTAX_ERROR), diff --git a/contrib/pg_trgm/trgm_gin.c b/contrib/pg_trgm/trgm_gin.c index 66ff6adde99..91de91b7c7f 100644 --- a/contrib/pg_trgm/trgm_gin.c +++ b/contrib/pg_trgm/trgm_gin.c @@ -97,7 +97,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case LikeStrategyNumber: /* @@ -111,7 +111,7 @@ gin_extract_query_trgm(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case RegExpStrategyNumber: trg = createTrgmNFA(val, PG_GET_COLLATION(), &graph, CurrentMemoryContext); @@ -221,7 +221,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case LikeStrategyNumber: case EqualStrategyNumber: /* Check if all extracted trigrams are presented. */ @@ -239,7 +239,7 @@ gin_trgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case RegExpStrategyNumber: if (nkeys < 1) { @@ -306,7 +306,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case LikeStrategyNumber: case EqualStrategyNumber: /* Check if all extracted trigrams are presented. */ @@ -324,7 +324,7 @@ gin_trgm_triconsistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case RegExpStrategyNumber: if (nkeys < 1) { diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c index 5c7deb103a6..c514e405739 100644 --- a/contrib/pg_trgm/trgm_gist.c +++ b/contrib/pg_trgm/trgm_gist.c @@ -247,7 +247,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case LikeStrategyNumber: qtrg = generate_wildcard_trgm(VARDATA(query), querysize - VARHDRSZ); @@ -256,7 +256,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case RegExpStrategyNumber: qtrg = createTrgmNFA(query, PG_GET_COLLATION(), &graph, fcinfo->flinfo->fn_mcxt); @@ -344,7 +344,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case LikeStrategyNumber: case EqualStrategyNumber: /* Wildcard and equal search are inexact */ @@ -386,7 +386,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS) #ifndef IGNORECASE elog(ERROR, "cannot handle ~* with case-sensitive trigrams"); #endif - /* FALL THRU */ + pg_fallthrough; case RegExpStrategyNumber: /* Regexp search is inexact */ *recheck = true; diff --git a/contrib/pgcrypto/pgp-info.c b/contrib/pgcrypto/pgp-info.c index 83dc60486bd..6c2be4713ab 100644 --- a/contrib/pgcrypto/pgp-info.c +++ b/contrib/pgcrypto/pgp-info.c @@ -169,7 +169,7 @@ pgp_get_keyid(MBuf *pgp_data, char *dst) break; case PGP_PKT_SYMENCRYPTED_SESSKEY: got_symenc_key++; - /* fall through */ + pg_fallthrough; case PGP_PKT_SIGNATURE: case PGP_PKT_MARKER: case PGP_PKT_TRUST: diff --git a/meson.build b/meson.build index 6d304f32fb0..f428371a4c4 100644 --- a/meson.build +++ b/meson.build @@ -2125,7 +2125,7 @@ common_warning_flags = [ '-Werror=unguarded-availability-new', '-Wendif-labels', '-Wmissing-format-attribute', - '-Wimplicit-fallthrough=3', + '-Wimplicit-fallthrough=5', '-Wcast-function-type', '-Wshadow=compatible-local', # This was included in -Wall/-Wformat in older GCC versions diff --git a/src/backend/access/heap/heapam_handler.c b/src/backend/access/heap/heapam_handler.c index cbef73e5d4b..b83e2013d50 100644 --- a/src/backend/access/heap/heapam_handler.c +++ b/src/backend/access/heap/heapam_handler.c @@ -861,7 +861,7 @@ heapam_relation_copy_for_cluster(Relation OldHeap, Relation NewHeap, break; case HEAPTUPLE_RECENTLY_DEAD: *tups_recently_dead += 1; - /* fall through */ + pg_fallthrough; case HEAPTUPLE_LIVE: /* Live or recently dead, must copy it */ isdead = false; diff --git a/src/backend/access/nbtree/nbtpreprocesskeys.c b/src/backend/access/nbtree/nbtpreprocesskeys.c index b028b0c3e88..39c0a5d610f 100644 --- a/src/backend/access/nbtree/nbtpreprocesskeys.c +++ b/src/backend/access/nbtree/nbtpreprocesskeys.c @@ -1198,7 +1198,7 @@ _bt_saoparray_shrink(IndexScanDesc scan, ScanKey arraysk, ScanKey skey, { case BTLessStrategyNumber: cmpexact = 1; /* exclude exact match, if any */ - /* FALL THRU */ + pg_fallthrough; case BTLessEqualStrategyNumber: if (cmpresult >= cmpexact) matchelem++; @@ -1220,7 +1220,7 @@ _bt_saoparray_shrink(IndexScanDesc scan, ScanKey arraysk, ScanKey skey, break; case BTGreaterEqualStrategyNumber: cmpexact = 1; /* include exact match, if any */ - /* FALL THRU */ + pg_fallthrough; case BTGreaterStrategyNumber: if (cmpresult >= cmpexact) matchelem++; diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index dd57624b4f9..1c5238414b1 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -242,7 +242,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only) (errcode(ERRCODE_SYNTAX_ERROR), errmsg("--%s must be first argument", optarg))); - /* FALLTHROUGH */ + pg_fallthrough; case 'c': { char *name, diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index f89267f0342..7d8804b6fb9 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -641,7 +641,7 @@ findDependentObjects(const ObjectAddress *object, break; /* Otherwise, treat this like an internal dependency */ - /* FALL THRU */ + pg_fallthrough; case DEPENDENCY_INTERNAL: diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c index 02af64b82c6..542767d2da8 100644 --- a/src/backend/catalog/objectaddress.c +++ b/src/backend/catalog/objectaddress.c @@ -2231,7 +2231,7 @@ pg_get_object_address(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("name list length must be exactly %d", 1))); /* fall through to check args length */ - /* FALLTHROUGH */ + pg_fallthrough; case OBJECT_DOMCONSTRAINT: case OBJECT_CAST: case OBJECT_PUBLICATION_REL: @@ -2256,7 +2256,7 @@ pg_get_object_address(PG_FUNCTION_ARGS) (errcode(ERRCODE_INVALID_PARAMETER_VALUE), errmsg("name list length must be at least %d", 3))); /* fall through to check args length */ - /* FALLTHROUGH */ + pg_fallthrough; case OBJECT_OPERATOR: if (list_length(args) != 2) ereport(ERROR, diff --git a/src/backend/catalog/pg_shdepend.c b/src/backend/catalog/pg_shdepend.c index 3db41ecd74f..c9998531b2f 100644 --- a/src/backend/catalog/pg_shdepend.c +++ b/src/backend/catalog/pg_shdepend.c @@ -1458,7 +1458,7 @@ shdepDropOwned(List *roleids, DropBehavior behavior) sdepForm->objid); break; } - /* FALLTHROUGH */ + pg_fallthrough; case SHARED_DEPENDENCY_OWNER: diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index b7bb111688c..2e03d1a3c66 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -2012,7 +2012,7 @@ ExplainNode(PlanState *planstate, List *ancestors, show_tablesample(((SampleScan *) plan)->tablesample, planstate, ancestors, es); /* fall through to print additional fields the same as SeqScan */ - /* FALLTHROUGH */ + pg_fallthrough; case T_SeqScan: case T_ValuesScan: case T_CteScan: diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index f976c0e5c7e..2f5b7007ff9 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -16192,7 +16192,7 @@ ATExecChangeOwner(Oid relationOid, Oid newOwnerId, bool recursing, LOCKMODE lock case RELKIND_TOASTVALUE: if (recursing) break; - /* FALL THRU */ + pg_fallthrough; default: ereport(ERROR, (errcode(ERRCODE_WRONG_OBJECT_TYPE), diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index d30fda660eb..5e69391b343 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -4402,7 +4402,7 @@ AfterTriggerExecute(EState *estate, trig_tuple_slot2)) elog(ERROR, "failed to fetch tuple2 for AFTER trigger"); } - /* fall through */ + pg_fallthrough; case AFTER_TRIGGER_FDW_REUSE: /* diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index baa76596ac2..7d487a165fa 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -2257,7 +2257,7 @@ ExecAgg(PlanState *pstate) case AGG_HASHED: if (!node->table_filled) agg_fill_hash_table(node); - /* FALLTHROUGH */ + pg_fallthrough; case AGG_MIXED: result = agg_retrieve_hash_table(node); break; diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index f5d3edb90e2..c0eb5a1f0c5 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -258,7 +258,7 @@ MultiExecParallelHash(HashState *node) * way, wait for everyone to arrive here so we can proceed. */ BarrierArriveAndWait(build_barrier, WAIT_EVENT_HASH_BUILD_ALLOCATE); - /* Fall through. */ + pg_fallthrough; case PHJ_BUILD_HASH_INNER: @@ -1330,13 +1330,13 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) /* All other participants just flush their tuples to disk. */ ExecParallelHashCloseBatchAccessors(hashtable); } - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BATCHES_REALLOCATE: /* Wait for the above to be finished. */ BarrierArriveAndWait(&pstate->grow_batches_barrier, WAIT_EVENT_HASH_GROW_BATCHES_REALLOCATE); - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BATCHES_REPARTITION: /* Make sure that we have the current dimensions and buckets. */ @@ -1349,7 +1349,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) /* Wait for the above to be finished. */ BarrierArriveAndWait(&pstate->grow_batches_barrier, WAIT_EVENT_HASH_GROW_BATCHES_REPARTITION); - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BATCHES_DECIDE: @@ -1411,7 +1411,7 @@ ExecParallelHashIncreaseNumBatches(HashJoinTable hashtable) dsa_free(hashtable->area, pstate->old_batches); pstate->old_batches = InvalidDsaPointer; } - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BATCHES_FINISH: /* Wait for the above to complete. */ @@ -1689,13 +1689,13 @@ ExecParallelHashIncreaseNumBuckets(HashJoinTable hashtable) /* Clear the flag. */ pstate->growth = PHJ_GROWTH_OK; } - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BUCKETS_REALLOCATE: /* Wait for the above to complete. */ BarrierArriveAndWait(&pstate->grow_buckets_barrier, WAIT_EVENT_HASH_GROW_BUCKETS_REALLOCATE); - /* Fall through. */ + pg_fallthrough; case PHJ_GROW_BUCKETS_REINSERT: /* Reinsert all tuples into the hash table. */ diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 114620a8137..5aa8a09b265 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -416,7 +416,7 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel) else node->hj_JoinState = HJ_NEED_NEW_OUTER; - /* FALL THRU */ + pg_fallthrough; case HJ_NEED_NEW_OUTER: @@ -505,7 +505,7 @@ ExecHashJoinImpl(PlanState *pstate, bool parallel) /* OK, let's scan the bucket for matches */ node->hj_JoinState = HJ_SCAN_BUCKET; - /* FALL THRU */ + pg_fallthrough; case HJ_SCAN_BUCKET: @@ -1313,13 +1313,13 @@ ExecParallelHashJoinNewBatch(HashJoinState *hjstate) if (BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_ELECT)) ExecParallelHashTableAlloc(hashtable, batchno); - /* Fall through. */ + pg_fallthrough; case PHJ_BATCH_ALLOCATE: /* Wait for allocation to complete. */ BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_ALLOCATE); - /* Fall through. */ + pg_fallthrough; case PHJ_BATCH_LOAD: /* Start (or join in) loading tuples. */ @@ -1339,7 +1339,7 @@ ExecParallelHashJoinNewBatch(HashJoinState *hjstate) sts_end_parallel_scan(inner_tuples); BarrierArriveAndWait(batch_barrier, WAIT_EVENT_HASH_BATCH_LOAD); - /* Fall through. */ + pg_fallthrough; case PHJ_BATCH_PROBE: diff --git a/src/backend/executor/nodeLimit.c b/src/backend/executor/nodeLimit.c index c40a73dcf17..8f75cbbead2 100644 --- a/src/backend/executor/nodeLimit.c +++ b/src/backend/executor/nodeLimit.c @@ -68,7 +68,7 @@ ExecLimit(PlanState *pstate) */ recompute_limits(node); - /* FALL THRU */ + pg_fallthrough; case LIMIT_RESCAN: @@ -215,7 +215,7 @@ ExecLimit(PlanState *pstate) } Assert(node->lstate == LIMIT_WINDOWEND_TIES); - /* FALL THRU */ + pg_fallthrough; case LIMIT_WINDOWEND_TIES: if (ScanDirectionIsForward(direction)) diff --git a/src/backend/executor/nodeTidrangescan.c b/src/backend/executor/nodeTidrangescan.c index 4aa28918e90..503817da65b 100644 --- a/src/backend/executor/nodeTidrangescan.c +++ b/src/backend/executor/nodeTidrangescan.c @@ -79,13 +79,13 @@ MakeTidOpExpr(OpExpr *expr, TidRangeScanState *tidstate) { case TIDLessEqOperator: tidopexpr->inclusive = true; - /* fall through */ + pg_fallthrough; case TIDLessOperator: tidopexpr->exprtype = invert ? TIDEXPR_LOWER_BOUND : TIDEXPR_UPPER_BOUND; break; case TIDGreaterEqOperator: tidopexpr->inclusive = true; - /* fall through */ + pg_fallthrough; case TIDGreaterOperator: tidopexpr->exprtype = invert ? TIDEXPR_UPPER_BOUND : TIDEXPR_LOWER_BOUND; break; diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 795bfed8d19..e04aa2e68ed 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -2002,7 +2002,7 @@ pam_passwd_conv_proc(int num_msg, PG_PAM_CONST struct pam_message **msg, ereport(LOG, (errmsg("error from underlying PAM layer: %s", msg[i]->msg))); - /* FALL THROUGH */ + pg_fallthrough; case PAM_TEXT_INFO: /* we don't bother to log TEXT_INFO messages */ if ((reply[i].resp = strdup("")) == NULL) diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 7a6b8b749f2..39c207f4d84 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -3414,11 +3414,11 @@ adjust_group_pathkeys_for_groupagg(PlannerInfo *root) case PATHKEYS_BETTER2: /* 'pathkeys' are stronger, use these ones instead */ currpathkeys = pathkeys; - /* FALLTHROUGH */ + pg_fallthrough; case PATHKEYS_BETTER1: /* 'pathkeys' are less strict */ - /* FALLTHROUGH */ + pg_fallthrough; case PATHKEYS_EQUAL: /* mark this aggregate as covered by 'currpathkeys' */ diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 39d35827c35..3582250156a 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -1550,7 +1550,7 @@ find_nonnullable_rels_walker(Node *node, bool top_level) * the intersection of the sets of nonnullable rels, just as * for OR. Fall through to share code. */ - /* FALL THRU */ + pg_fallthrough; case OR_EXPR: /* @@ -1808,7 +1808,7 @@ find_nonnullable_vars_walker(Node *node, bool top_level) * the intersection of the sets of nonnullable vars, just as * for OR. Fall through to share code. */ - /* FALL THRU */ + pg_fallthrough; case OR_EXPR: /* diff --git a/src/backend/parser/parse_jsontable.c b/src/backend/parser/parse_jsontable.c index c28ae99dee8..32a1e8629b2 100644 --- a/src/backend/parser/parse_jsontable.c +++ b/src/backend/parser/parse_jsontable.c @@ -312,7 +312,7 @@ transformJsonTableColumns(JsonTableParseContext *cxt, List *columns, rawc->wrapper != JSW_UNSPEC) rawc->coltype = JTC_FORMATTED; - /* FALLTHROUGH */ + pg_fallthrough; case JTC_FORMATTED: case JTC_EXISTS: { diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index b5f4c72459d..cc244c49e9e 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -918,7 +918,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) errmsg("primary key constraints are not supported on foreign tables"), parser_errposition(cxt->pstate, constraint->location))); - /* FALL THRU */ + pg_fallthrough; case CONSTR_UNIQUE: if (cxt->isforeign) diff --git a/src/backend/partitioning/partprune.c b/src/backend/partitioning/partprune.c index a4bbb10a3b7..6d979a08fd3 100644 --- a/src/backend/partitioning/partprune.c +++ b/src/backend/partitioning/partprune.c @@ -2880,7 +2880,7 @@ get_matching_list_bounds(PartitionPruneContext *context, case BTGreaterEqualStrategyNumber: inclusive = true; - /* fall through */ + pg_fallthrough; case BTGreaterStrategyNumber: off = partition_list_bsearch(partsupfunc, partcollation, @@ -2915,7 +2915,7 @@ get_matching_list_bounds(PartitionPruneContext *context, case BTLessEqualStrategyNumber: inclusive = true; - /* fall through */ + pg_fallthrough; case BTLessStrategyNumber: off = partition_list_bsearch(partsupfunc, partcollation, @@ -3162,7 +3162,7 @@ get_matching_range_bounds(PartitionPruneContext *context, case BTGreaterEqualStrategyNumber: inclusive = true; - /* fall through */ + pg_fallthrough; case BTGreaterStrategyNumber: /* @@ -3243,7 +3243,7 @@ get_matching_range_bounds(PartitionPruneContext *context, case BTLessEqualStrategyNumber: inclusive = true; - /* fall through */ + pg_fallthrough; case BTLessStrategyNumber: /* @@ -3726,19 +3726,19 @@ match_boolean_partition_clause(Oid partopfamily, Expr *clause, Expr *partkey, { case IS_NOT_TRUE: *notclause = true; - /* fall through */ + pg_fallthrough; case IS_TRUE: *outconst = (Expr *) makeBoolConst(true, false); return PARTCLAUSE_MATCH_CLAUSE; case IS_NOT_FALSE: *notclause = true; - /* fall through */ + pg_fallthrough; case IS_FALSE: *outconst = (Expr *) makeBoolConst(false, false); return PARTCLAUSE_MATCH_CLAUSE; case IS_NOT_UNKNOWN: *notclause = true; - /* fall through */ + pg_fallthrough; case IS_UNKNOWN: return PARTCLAUSE_MATCH_NULLNESS; default: diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 70c7645582e..3fac46c402b 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -625,7 +625,7 @@ PostmasterMain(int argc, char *argv[]) (errcode(ERRCODE_SYNTAX_ERROR), errmsg("--%s must be first argument", optarg))); - /* FALLTHROUGH */ + pg_fallthrough; case 'c': { char *name, @@ -4217,12 +4217,12 @@ bgworker_should_start_now(BgWorkerStartTime start_time) case PM_RUN: if (start_time == BgWorkerStart_RecoveryFinished) return true; - /* fall through */ + pg_fallthrough; case PM_HOT_STANDBY: if (start_time == BgWorkerStart_ConsistentState) return true; - /* fall through */ + pg_fallthrough; case PM_RECOVERY: case PM_STARTUP: diff --git a/src/backend/regex/regc_lex.c b/src/backend/regex/regc_lex.c index 9087ef95af3..55df64f9ade 100644 --- a/src/backend/regex/regc_lex.c +++ b/src/backend/regex/regc_lex.c @@ -743,7 +743,7 @@ lexescape(struct vars *v) /* oops, doesn't look like it's a backref after all... */ v->now = save; /* and fall through into octal number */ - /* FALLTHROUGH */ + pg_fallthrough; case CHR('0'): NOTE(REG_UUNPORT); v->now--; /* put first digit back */ diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 3e18e4a78a2..820995332ba 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -975,7 +975,7 @@ parseqatom(struct vars *v, /* legal in EREs due to specification botch */ NOTE(REG_UPBOTCH); /* fall through into case PLAIN */ - /* FALLTHROUGH */ + pg_fallthrough; case PLAIN: onechr(v, v->nextvalue, lp, rp); okcolors(v->nfa, v->cm); diff --git a/src/backend/replication/logical/reorderbuffer.c b/src/backend/replication/logical/reorderbuffer.c index a0293f6ec7c..1d2fbbb000e 100644 --- a/src/backend/replication/logical/reorderbuffer.c +++ b/src/backend/replication/logical/reorderbuffer.c @@ -2322,6 +2322,7 @@ ReorderBufferProcessTXN(ReorderBuffer *rb, ReorderBufferTXN *txn, change->action = REORDER_BUFFER_CHANGE_INSERT; /* intentionally fall through */ + pg_fallthrough; case REORDER_BUFFER_CHANGE_INSERT: case REORDER_BUFFER_CHANGE_UPDATE: case REORDER_BUFFER_CHANGE_DELETE: diff --git a/src/backend/replication/logical/worker.c b/src/backend/replication/logical/worker.c index ad281e7069b..dcf8004c1c1 100644 --- a/src/backend/replication/logical/worker.c +++ b/src/backend/replication/logical/worker.c @@ -839,7 +839,7 @@ handle_streamed_transaction(LogicalRepMsgType action, StringInfo s) */ pa_switch_to_partial_serialize(winfo, false); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: stream_write_change(action, &original_msg); @@ -1586,7 +1586,7 @@ apply_handle_stream_prepare(StringInfo s) */ pa_switch_to_partial_serialize(winfo, true); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: Assert(winfo); @@ -1808,7 +1808,7 @@ apply_handle_stream_start(StringInfo s) */ pa_switch_to_partial_serialize(winfo, !first_segment); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: Assert(winfo); @@ -1923,7 +1923,7 @@ apply_handle_stream_stop(StringInfo s) */ pa_switch_to_partial_serialize(winfo, true); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: stream_write_change(LOGICAL_REP_MSG_STREAM_STOP, s); stream_stop_internal(stream_xid); @@ -2169,7 +2169,7 @@ apply_handle_stream_abort(StringInfo s) */ pa_switch_to_partial_serialize(winfo, true); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: Assert(winfo); @@ -2442,7 +2442,7 @@ apply_handle_stream_commit(StringInfo s) */ pa_switch_to_partial_serialize(winfo, true); - /* fall through */ + pg_fallthrough; case TRANS_LEADER_PARTIAL_SERIALIZE: Assert(winfo); diff --git a/src/backend/replication/walreceiver.c b/src/backend/replication/walreceiver.c index a41453530a1..dcbbb7691af 100644 --- a/src/backend/replication/walreceiver.c +++ b/src/backend/replication/walreceiver.c @@ -193,7 +193,7 @@ WalReceiverMain(const void *startup_data, size_t startup_data_len) case WALRCV_STOPPING: /* If we've already been requested to stop, don't start up. */ walrcv->walRcvState = WALRCV_STOPPED; - /* fall through */ + pg_fallthrough; case WALRCV_STOPPED: SpinLockRelease(&walrcv->mutex); diff --git a/src/backend/replication/walreceiverfuncs.c b/src/backend/replication/walreceiverfuncs.c index da8794cba7c..690a7b49c5b 100644 --- a/src/backend/replication/walreceiverfuncs.c +++ b/src/backend/replication/walreceiverfuncs.c @@ -215,7 +215,7 @@ ShutdownWalRcv(void) case WALRCV_WAITING: case WALRCV_RESTARTING: walrcv->walRcvState = WALRCV_STOPPING; - /* fall through */ + pg_fallthrough; case WALRCV_STOPPING: walrcvpid = walrcv->pid; break; diff --git a/src/backend/storage/aio/aio.c b/src/backend/storage/aio/aio.c index d2c9cd6f20a..e4ae3031fef 100644 --- a/src/backend/storage/aio/aio.c +++ b/src/backend/storage/aio/aio.c @@ -622,7 +622,7 @@ pgaio_io_wait(PgAioHandle *ioh, uint64 ref_generation) pgaio_method_ops->wait_one(ioh, ref_generation); continue; } - /* fallthrough */ + pg_fallthrough; /* waiting for owner to submit */ case PGAIO_HS_DEFINED: diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index e54bf1e760f..01cf76d56ab 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3117,7 +3117,7 @@ ProcessRecoveryConflictInterrupt(ProcSignalReason reason) return; /* Intentional fall through to check wait for pin */ - /* FALLTHROUGH */ + pg_fallthrough; case PROCSIG_RECOVERY_CONFLICT_BUFFERPIN: @@ -3142,7 +3142,7 @@ ProcessRecoveryConflictInterrupt(ProcSignalReason reason) MyProc->recoveryConflictPending = true; /* Intentional fall through to error handling */ - /* FALLTHROUGH */ + pg_fallthrough; case PROCSIG_RECOVERY_CONFLICT_LOCK: case PROCSIG_RECOVERY_CONFLICT_TABLESPACE: @@ -3154,7 +3154,7 @@ ProcessRecoveryConflictInterrupt(ProcSignalReason reason) if (!IsTransactionOrTransactionBlock()) return; - /* FALLTHROUGH */ + pg_fallthrough; case PROCSIG_RECOVERY_CONFLICT_LOGICALSLOT: @@ -3233,7 +3233,7 @@ ProcessRecoveryConflictInterrupt(ProcSignalReason reason) } /* Intentional fall through to session cancel */ - /* FALLTHROUGH */ + pg_fallthrough; case PROCSIG_RECOVERY_CONFLICT_DATABASE: @@ -3866,7 +3866,7 @@ process_postgres_switches(int argc, char *argv[], GucContext ctx, (errcode(ERRCODE_SYNTAX_ERROR), errmsg("--%s must be first argument", optarg))); - /* FALLTHROUGH */ + pg_fallthrough; case 'c': { char *name, @@ -4990,7 +4990,7 @@ PostgresMain(const char *dbname, const char *username) /* for the cumulative statistics system */ pgStatSessionEndCause = DISCONNECT_CLIENT_EOF; - /* FALLTHROUGH */ + pg_fallthrough; case PqMsg_Terminate: diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 34dd6e18df5..bf707f2d57f 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -2001,7 +2001,7 @@ ExecDropStmt(DropStmt *stmt, bool isTopLevel) if (stmt->concurrent) PreventInTransactionBlock(isTopLevel, "DROP INDEX CONCURRENTLY"); - /* fall through */ + pg_fallthrough; case OBJECT_TABLE: case OBJECT_SEQUENCE: diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 8dc0ac50625..90946db72ff 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -3594,7 +3594,7 @@ DecodeInterval(char **field, int *ftype, int nf, int range, * handle signed float numbers and signed year-month values. */ - /* FALLTHROUGH */ + pg_fallthrough; case DTK_DATE: case DTK_NUMBER: @@ -4028,7 +4028,7 @@ DecodeISO8601Interval(char *str, continue; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + pg_fallthrough; case '-': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -4111,7 +4111,7 @@ DecodeISO8601Interval(char *str, return 0; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + pg_fallthrough; case ':': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index cf580c63c78..a5a80a0bcbf 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1236,7 +1236,7 @@ NUMDesc_prepare(NUMDesc *num, FormatNode *n) case NUM_D: num->flag |= NUM_F_LDECIMAL; num->need_locale = true; - /* FALLTHROUGH */ + pg_fallthrough; case NUM_DEC: if (IS_DECIMAL(num)) ereport(ERROR, @@ -3022,7 +3022,7 @@ DCH_to_char(FormatNode *node, bool is_interval, TmToChar *in, char *out, Oid col s += strlen(s); break; case DCH_RM: - /* FALLTHROUGH */ + pg_fallthrough; case DCH_rm: /* @@ -3300,7 +3300,7 @@ DCH_from_char(FormatNode *node, const char *in, TmFromChar *out, case DCH_FF5: case DCH_FF6: out->ff = n->key->id - DCH_FF1 + 1; - /* FALLTHROUGH */ + pg_fallthrough; case DCH_US: /* microsecond */ len = from_char_parse_int_len(&out->us, &s, n->key->id == DCH_US ? 6 : @@ -3354,7 +3354,7 @@ DCH_from_char(FormatNode *node, const char *in, TmFromChar *out, } /* otherwise parse it like OF */ } - /* FALLTHROUGH */ + pg_fallthrough; case DCH_OF: /* OF is equivalent to TZH or TZH:TZM */ /* see TZH comments below */ diff --git a/src/backend/utils/adt/jsonb.c b/src/backend/utils/adt/jsonb.c index 28e7f80d77f..0a3a77ee786 100644 --- a/src/backend/utils/adt/jsonb.c +++ b/src/backend/utils/adt/jsonb.c @@ -772,7 +772,7 @@ datum_to_jsonb_internal(Datum val, bool is_null, JsonbInState *result, case JSONTYPE_CAST: /* cast to JSON, and then process as JSON */ val = OidFunctionCall1(outfuncoid, val); - /* FALL THROUGH */ + pg_fallthrough; case JSONTYPE_JSON: { /* parse the json right into the existing result object */ diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c index e085042f912..91fb9ea09bf 100644 --- a/src/backend/utils/adt/jsonb_util.c +++ b/src/backend/utils/adt/jsonb_util.c @@ -721,7 +721,7 @@ pushJsonbValueScalar(JsonbInState *pstate, JsonbIteratorToken seq, uniqueifyJsonbObject(&ppstate->contVal, ppstate->unique_keys, ppstate->skip_nulls); - /* fall through! */ + pg_fallthrough; case WJB_END_ARRAY: /* Steps here common to WJB_END_OBJECT case */ Assert(!scalarVal); diff --git a/src/backend/utils/adt/jsonpath.c b/src/backend/utils/adt/jsonpath.c index 18a8046d6cf..d70ff1eaa54 100644 --- a/src/backend/utils/adt/jsonpath.c +++ b/src/backend/utils/adt/jsonpath.c @@ -351,7 +351,7 @@ flattenJsonPathParseItem(StringInfo buf, int *result, struct Node *escontext, break; case jpiFilter: argNestingLevel++; - /* FALLTHROUGH */ + pg_fallthrough; case jpiIsUnknown: case jpiNot: case jpiPlus: @@ -487,13 +487,13 @@ alignStringInfoInt(StringInfo buf) { case 3: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ + pg_fallthrough; case 2: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ + pg_fallthrough; case 1: appendStringInfoCharMacro(buf, 0); - /* FALLTHROUGH */ + pg_fallthrough; default: break; } @@ -1021,7 +1021,7 @@ jspInitByBuffer(JsonPathItem *v, char *base, int32 pos) case jpiKey: case jpiVariable: read_int32(v->content.value.datalen, base, pos); - /* FALLTHROUGH */ + pg_fallthrough; case jpiNumeric: case jpiBool: v->content.value.data = base + pos; @@ -1433,7 +1433,7 @@ jspIsMutableWalker(JsonPathItem *jpi, struct JsonPathMutableContext *cxt) jspIsMutableWalker(&from, cxt); } - /* FALLTHROUGH */ + pg_fallthrough; case jpiAnyArray: if (!cxt->lax) diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index 891ae6ba7fe..068ae3db15d 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -2378,13 +2378,13 @@ numeric_abbrev_convert_var(const NumericVar *var, NumericSortSupport *nss) { default: result |= ((int64) var->digits[3]); - /* FALLTHROUGH */ + pg_fallthrough; case 3: result |= ((int64) var->digits[2]) << 14; - /* FALLTHROUGH */ + pg_fallthrough; case 2: result |= ((int64) var->digits[1]) << 28; - /* FALLTHROUGH */ + pg_fallthrough; case 1: result |= ((int64) var->digits[0]) << 42; break; @@ -8818,22 +8818,22 @@ mul_var_short(const NumericVar *var1, const NumericVar *var2, term = PRODSUM5(var1digits, 0, var2digits, 4) + carry; res_digits[5] = (NumericDigit) (term % NBASE); carry = term / NBASE; - /* FALLTHROUGH */ + pg_fallthrough; case 5: term = PRODSUM4(var1digits, 0, var2digits, 3) + carry; res_digits[4] = (NumericDigit) (term % NBASE); carry = term / NBASE; - /* FALLTHROUGH */ + pg_fallthrough; case 4: term = PRODSUM3(var1digits, 0, var2digits, 2) + carry; res_digits[3] = (NumericDigit) (term % NBASE); carry = term / NBASE; - /* FALLTHROUGH */ + pg_fallthrough; case 3: term = PRODSUM2(var1digits, 0, var2digits, 1) + carry; res_digits[2] = (NumericDigit) (term % NBASE); carry = term / NBASE; - /* FALLTHROUGH */ + pg_fallthrough; case 2: term = PRODSUM1(var1digits, 0, var2digits, 0) + carry; res_digits[1] = (NumericDigit) (term % NBASE); diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index 033b625f3fc..9963304e013 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -8982,7 +8982,7 @@ isSimpleNode(Node *node, Node *parentNode, int prettyFlags) } /* else do the same stuff as for T_SubLink et al. */ } - /* FALLTHROUGH */ + pg_fallthrough; case T_SubLink: case T_NullTest: diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index 8deb2369471..e2603183f1c 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -4744,14 +4744,14 @@ timestamp_trunc(PG_FUNCTION_ARGS) tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; else tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_CENTURY: /* see comments in timestamptz_trunc */ if (tm->tm_year > 0) tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99; else tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_DECADE: /* see comments in timestamptz_trunc */ if (val != DTK_MILLENNIUM && val != DTK_CENTURY) @@ -4761,25 +4761,25 @@ timestamp_trunc(PG_FUNCTION_ARGS) else tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10; } - /* FALL THRU */ + pg_fallthrough; case DTK_YEAR: tm->tm_mon = 1; - /* FALL THRU */ + pg_fallthrough; case DTK_QUARTER: tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_MONTH: tm->tm_mday = 1; - /* FALL THRU */ + pg_fallthrough; case DTK_DAY: tm->tm_hour = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_SECOND: fsec = 0; break; @@ -4990,14 +4990,14 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp) tm->tm_year = ((tm->tm_year + 999) / 1000) * 1000 - 999; else tm->tm_year = -((999 - (tm->tm_year - 1)) / 1000) * 1000 + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_CENTURY: /* truncating to the century? as above: -100, 1, 101... */ if (tm->tm_year > 0) tm->tm_year = ((tm->tm_year + 99) / 100) * 100 - 99; else tm->tm_year = -((99 - (tm->tm_year - 1)) / 100) * 100 + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_DECADE: /* @@ -5011,26 +5011,26 @@ timestamptz_trunc_internal(text *units, TimestampTz timestamp, pg_tz *tzp) else tm->tm_year = -((8 - (tm->tm_year - 1)) / 10) * 10; } - /* FALL THRU */ + pg_fallthrough; case DTK_YEAR: tm->tm_mon = 1; - /* FALL THRU */ + pg_fallthrough; case DTK_QUARTER: tm->tm_mon = (3 * ((tm->tm_mon - 1) / 3)) + 1; - /* FALL THRU */ + pg_fallthrough; case DTK_MONTH: tm->tm_mday = 1; - /* FALL THRU */ + pg_fallthrough; case DTK_DAY: tm->tm_hour = 0; redotz = true; /* for all cases >= DAY */ - /* FALL THRU */ + pg_fallthrough; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_SECOND: fsec = 0; break; @@ -5171,33 +5171,33 @@ interval_trunc(PG_FUNCTION_ARGS) case DTK_MILLENNIUM: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 1000) * 1000; - /* FALL THRU */ + pg_fallthrough; case DTK_CENTURY: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 100) * 100; - /* FALL THRU */ + pg_fallthrough; case DTK_DECADE: /* caution: C division may have negative remainder */ tm->tm_year = (tm->tm_year / 10) * 10; - /* FALL THRU */ + pg_fallthrough; case DTK_YEAR: tm->tm_mon = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_QUARTER: tm->tm_mon = 3 * (tm->tm_mon / 3); - /* FALL THRU */ + pg_fallthrough; case DTK_MONTH: tm->tm_mday = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_DAY: tm->tm_hour = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_HOUR: tm->tm_min = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_MINUTE: tm->tm_sec = 0; - /* FALL THRU */ + pg_fallthrough; case DTK_SECOND: tm->tm_usec = 0; break; diff --git a/src/backend/utils/adt/xml.c b/src/backend/utils/adt/xml.c index f69dc68286c..d641abde268 100644 --- a/src/backend/utils/adt/xml.c +++ b/src/backend/utils/adt/xml.c @@ -2186,7 +2186,7 @@ xml_errorHandler(void *data, PgXmlErrorPtr error) if (error->code == XML_ERR_NOT_WELL_BALANCED && xmlerrcxt->err_occurred) return; - /* fall through */ + pg_fallthrough; case XML_FROM_NONE: case XML_FROM_MEMORY: diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 681aa923403..519089322f4 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -357,15 +357,15 @@ CatalogCacheComputeHashValue(CatCache *cache, int nkeys, case 4: oneHash = (cc_hashfunc[3]) (v4); hashValue ^= pg_rotate_left32(oneHash, 24); - /* FALLTHROUGH */ + pg_fallthrough; case 3: oneHash = (cc_hashfunc[2]) (v3); hashValue ^= pg_rotate_left32(oneHash, 16); - /* FALLTHROUGH */ + pg_fallthrough; case 2: oneHash = (cc_hashfunc[1]) (v2); hashValue ^= pg_rotate_left32(oneHash, 8); - /* FALLTHROUGH */ + pg_fallthrough; case 1: oneHash = (cc_hashfunc[0]) (v1); hashValue ^= oneHash; @@ -403,21 +403,21 @@ CatalogCacheComputeTupleHashValue(CatCache *cache, int nkeys, HeapTuple tuple) cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + pg_fallthrough; case 3: v3 = fastgetattr(tuple, cc_keyno[2], cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + pg_fallthrough; case 2: v2 = fastgetattr(tuple, cc_keyno[1], cc_tupdesc, &isNull); Assert(!isNull); - /* FALLTHROUGH */ + pg_fallthrough; case 1: v1 = fastgetattr(tuple, cc_keyno[0], diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 6950e743d03..1a3a1072225 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -1376,7 +1376,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[3]++; break; } - /* FALL THRU */ + pg_fallthrough; case 3: a = charptr[2]; if (a < 0xBF) @@ -1384,7 +1384,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[2]++; break; } - /* FALL THRU */ + pg_fallthrough; case 2: a = charptr[1]; switch (*charptr) @@ -1404,7 +1404,7 @@ pg_utf8_increment(unsigned char *charptr, int length) charptr[1]++; break; } - /* FALL THRU */ + pg_fallthrough; case 1: a = *charptr; if (a == 0x7F || a == 0xDF || a == 0xEF || a == 0xF4) diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index ae9d5f3fb70..d77502838c4 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -3415,7 +3415,7 @@ set_config_with_handle(const char *name, config_handle *handle, } } /* fall through to process the same as PGC_BACKEND */ - /* FALLTHROUGH */ + pg_fallthrough; case PGC_BACKEND: if (context == PGC_SIGHUP) { diff --git a/src/backend/utils/misc/guc_funcs.c b/src/backend/utils/misc/guc_funcs.c index 4f3e40bf470..8524dd3a981 100644 --- a/src/backend/utils/misc/guc_funcs.c +++ b/src/backend/utils/misc/guc_funcs.c @@ -139,7 +139,7 @@ ExecSetVariableStmt(VariableSetStmt *stmt, bool isTopLevel) case VAR_SET_DEFAULT: if (stmt->is_local) WarnNoTransactionBlock(isTopLevel, "SET LOCAL"); - /* fall through */ + pg_fallthrough; case VAR_RESET: (void) set_config_option(stmt->name, NULL, diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index e57fa5bca64..afba82f28a2 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -1024,7 +1024,7 @@ tuplestore_gettuple(Tuplestorestate *state, bool forward, (errcode_for_file_access(), errmsg("could not seek in tuplestore temporary file"))); state->status = TSS_READFILE; - /* FALLTHROUGH */ + pg_fallthrough; case TSS_READFILE: *should_free = true; diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c index 58735871c17..cb4e986092e 100644 --- a/src/bin/pgbench/pgbench.c +++ b/src/bin/pgbench/pgbench.c @@ -3394,7 +3394,7 @@ readCommandResponse(CState *st, MetaCommand meta, char *varprefix) commandError(st, PQresultErrorMessage(res)); goto error; } - /* fall through */ + pg_fallthrough; default: /* anything else is unexpected */ @@ -3607,7 +3607,7 @@ getTransactionStatus(PGconn *con) /* PQTRANS_UNKNOWN is expected given a broken connection */ if (PQstatus(con) == CONNECTION_BAD) return TSTATUS_CONN_ERROR; - /* fall through */ + pg_fallthrough; case PQTRANS_ACTIVE: default: @@ -5720,7 +5720,7 @@ postprocess_sql_command(Command *my_command) break; case QUERY_PREPARED: my_command->prepname = psprintf("P_%d", prepnum++); - /* fall through */ + pg_fallthrough; case QUERY_EXTENDED: if (!parseQuery(my_command)) exit(1); diff --git a/src/common/hashfn.c b/src/common/hashfn.c index 0efe95568c0..c7a0626f96f 100644 --- a/src/common/hashfn.c +++ b/src/common/hashfn.c @@ -178,13 +178,13 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -192,22 +192,22 @@ hash_bytes(const unsigned char *k, int keylen) break; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + pg_fallthrough; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + pg_fallthrough; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + pg_fallthrough; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -217,13 +217,13 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -231,22 +231,22 @@ hash_bytes(const unsigned char *k, int keylen) break; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + pg_fallthrough; case 5: b += k[4]; - /* fall through */ + pg_fallthrough; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + pg_fallthrough; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -280,35 +280,35 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += k[7]; - /* fall through */ + pg_fallthrough; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + pg_fallthrough; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + pg_fallthrough; case 4: a += k[3]; - /* fall through */ + pg_fallthrough; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + pg_fallthrough; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -318,35 +318,35 @@ hash_bytes(const unsigned char *k, int keylen) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ((uint32) k[7] << 24); - /* fall through */ + pg_fallthrough; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + pg_fallthrough; case 5: b += k[4]; - /* fall through */ + pg_fallthrough; case 4: a += ((uint32) k[3] << 24); - /* fall through */ + pg_fallthrough; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + pg_fallthrough; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -417,13 +417,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -431,22 +431,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) break; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + pg_fallthrough; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + pg_fallthrough; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + pg_fallthrough; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -456,13 +456,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ka[1]; @@ -470,22 +470,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) break; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + pg_fallthrough; case 5: b += k[4]; - /* fall through */ + pg_fallthrough; case 4: a += ka[0]; break; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + pg_fallthrough; case 1: a += k[0]; /* case 0: nothing left to add */ @@ -519,35 +519,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 8); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 24); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += k[7]; - /* fall through */ + pg_fallthrough; case 7: b += ((uint32) k[6] << 8); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 16); - /* fall through */ + pg_fallthrough; case 5: b += ((uint32) k[4] << 24); - /* fall through */ + pg_fallthrough; case 4: a += k[3]; - /* fall through */ + pg_fallthrough; case 3: a += ((uint32) k[2] << 8); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 16); - /* fall through */ + pg_fallthrough; case 1: a += ((uint32) k[0] << 24); /* case 0: nothing left to add */ @@ -557,35 +557,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed) { case 11: c += ((uint32) k[10] << 24); - /* fall through */ + pg_fallthrough; case 10: c += ((uint32) k[9] << 16); - /* fall through */ + pg_fallthrough; case 9: c += ((uint32) k[8] << 8); - /* fall through */ + pg_fallthrough; case 8: /* the lowest byte of c is reserved for the length */ b += ((uint32) k[7] << 24); - /* fall through */ + pg_fallthrough; case 7: b += ((uint32) k[6] << 16); - /* fall through */ + pg_fallthrough; case 6: b += ((uint32) k[5] << 8); - /* fall through */ + pg_fallthrough; case 5: b += k[4]; - /* fall through */ + pg_fallthrough; case 4: a += ((uint32) k[3] << 24); - /* fall through */ + pg_fallthrough; case 3: a += ((uint32) k[2] << 16); - /* fall through */ + pg_fallthrough; case 2: a += ((uint32) k[1] << 8); - /* fall through */ + pg_fallthrough; case 1: a += k[0]; /* case 0: nothing left to add */ diff --git a/src/common/wchar.c b/src/common/wchar.c index 5631e2c9363..8b47dcd674a 100644 --- a/src/common/wchar.c +++ b/src/common/wchar.c @@ -1999,12 +1999,12 @@ pg_utf8_islegal(const unsigned char *source, int length) a = source[3]; if (a < 0x80 || a > 0xBF) return false; - /* FALL THRU */ + pg_fallthrough; case 3: a = source[2]; if (a < 0x80 || a > 0xBF) return false; - /* FALL THRU */ + pg_fallthrough; case 2: a = source[1]; switch (*source) @@ -2030,7 +2030,7 @@ pg_utf8_islegal(const unsigned char *source, int length) return false; break; } - /* FALL THRU */ + pg_fallthrough; case 1: a = *source; if (a >= 0x80 && a < 0xC2) diff --git a/src/include/c.h b/src/include/c.h index 7136102e5ff..11ef71e0b27 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -132,6 +132,18 @@ #define pg_attribute_unused() #endif +/* + * pg_fallthrough indicates that the fall through from the previous case is + * intentional. + */ +#if (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L) || defined(__cpp_attributes) +#define pg_fallthrough [[fallthrough]] +#elif __has_attribute(fallthrough) +#define pg_fallthrough __attribute__((fallthrough)) +#else +#define pg_fallthrough +#endif + /* * pg_nodiscard means the compiler should warn if the result of a function * call is ignored. The name "nodiscard" is chosen in alignment with the C23 diff --git a/src/include/common/hashfn_unstable.h b/src/include/common/hashfn_unstable.h index 428936b8b64..4631ade7260 100644 --- a/src/include/common/hashfn_unstable.h +++ b/src/include/common/hashfn_unstable.h @@ -151,23 +151,23 @@ fasthash_accum(fasthash_state *hs, const char *k, size_t len) break; case 7: hs->accum |= (uint64) k[6] << 8; - /* FALLTHROUGH */ + pg_fallthrough; case 6: hs->accum |= (uint64) k[5] << 16; - /* FALLTHROUGH */ + pg_fallthrough; case 5: hs->accum |= (uint64) k[4] << 24; - /* FALLTHROUGH */ + pg_fallthrough; case 4: memcpy(&lower_four, k, sizeof(lower_four)); hs->accum |= (uint64) lower_four << 32; break; case 3: hs->accum |= (uint64) k[2] << 40; - /* FALLTHROUGH */ + pg_fallthrough; case 2: hs->accum |= (uint64) k[1] << 48; - /* FALLTHROUGH */ + pg_fallthrough; case 1: hs->accum |= (uint64) k[0] << 56; break; @@ -182,23 +182,23 @@ fasthash_accum(fasthash_state *hs, const char *k, size_t len) break; case 7: hs->accum |= (uint64) k[6] << 48; - /* FALLTHROUGH */ + pg_fallthrough; case 6: hs->accum |= (uint64) k[5] << 40; - /* FALLTHROUGH */ + pg_fallthrough; case 5: hs->accum |= (uint64) k[4] << 32; - /* FALLTHROUGH */ + pg_fallthrough; case 4: memcpy(&lower_four, k, sizeof(lower_four)); hs->accum |= lower_four; break; case 3: hs->accum |= (uint64) k[2] << 16; - /* FALLTHROUGH */ + pg_fallthrough; case 2: hs->accum |= (uint64) k[1] << 8; - /* FALLTHROUGH */ + pg_fallthrough; case 1: hs->accum |= (uint64) k[0]; break; diff --git a/src/interfaces/ecpg/pgtypeslib/interval.c b/src/interfaces/ecpg/pgtypeslib/interval.c index 936a6883816..e452a088f9e 100644 --- a/src/interfaces/ecpg/pgtypeslib/interval.c +++ b/src/interfaces/ecpg/pgtypeslib/interval.c @@ -184,7 +184,7 @@ DecodeISO8601Interval(char *str, continue; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + pg_fallthrough; case '-': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -263,7 +263,7 @@ DecodeISO8601Interval(char *str, return 0; } /* Else fall through to extended alternative format */ - /* FALLTHROUGH */ + pg_fallthrough; case ':': /* ISO 8601 4.4.3.3 Alternative Format, * Extended */ if (havefield) @@ -391,7 +391,7 @@ DecodeInterval(char **field, int *ftype, int nf, /* int range, */ tmask = DTK_M(TZ); break; } - /* FALL THROUGH */ + pg_fallthrough; case DTK_DATE: case DTK_NUMBER: diff --git a/src/interfaces/libpq/fe-secure.c b/src/interfaces/libpq/fe-secure.c index 399fe7adf62..31d5b48d3f9 100644 --- a/src/interfaces/libpq/fe-secure.c +++ b/src/interfaces/libpq/fe-secure.c @@ -379,7 +379,7 @@ pqsecure_raw_write(PGconn *conn, const void *ptr, size_t len) /* Set flag for EPIPE */ REMEMBER_EPIPE(spinfo, true); - /* FALL THRU */ + pg_fallthrough; case ECONNRESET: conn->write_failed = true; diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c index 75325117ec9..ec7c347d626 100644 --- a/src/pl/plpgsql/src/pl_exec.c +++ b/src/pl/plpgsql/src/pl_exec.c @@ -3230,7 +3230,7 @@ exec_stmt_return(PLpgSQL_execstate *estate, PLpgSQL_stmt_return *stmt) /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) retvar); - /* FALL THRU */ + pg_fallthrough; case PLPGSQL_DTYPE_VAR: { @@ -3376,7 +3376,7 @@ exec_stmt_return_next(PLpgSQL_execstate *estate, /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) retvar); - /* FALL THRU */ + pg_fallthrough; case PLPGSQL_DTYPE_VAR: { @@ -5313,7 +5313,7 @@ exec_eval_datum(PLpgSQL_execstate *estate, /* fulfill promise if needed, then handle like regular var */ plpgsql_fulfill_promise(estate, (PLpgSQL_var *) datum); - /* FALL THRU */ + pg_fallthrough; case PLPGSQL_DTYPE_VAR: { diff --git a/src/pl/tcl/pltcl.c b/src/pl/tcl/pltcl.c index 187698ccdd2..b7318f7261e 100644 --- a/src/pl/tcl/pltcl.c +++ b/src/pl/tcl/pltcl.c @@ -2545,7 +2545,7 @@ pltcl_process_SPI_result(Tcl_Interp *interp, break; } /* fall through for utility returning tuples */ - /* FALLTHROUGH */ + pg_fallthrough; case SPI_OK_SELECT: case SPI_OK_INSERT_RETURNING: diff --git a/src/port/snprintf.c b/src/port/snprintf.c index 56c7036753c..5deee44d3a2 100644 --- a/src/port/snprintf.c +++ b/src/port/snprintf.c @@ -462,7 +462,7 @@ dopr(PrintfTarget *target, const char *format, va_list args) /* set zero padding if no nonzero digits yet */ if (accum == 0 && !pointflag) zpad = '0'; - /* FALL THRU */ + pg_fallthrough; case '1': case '2': case '3': diff --git a/src/test/modules/test_json_parser/test_json_parser_incremental.c b/src/test/modules/test_json_parser/test_json_parser_incremental.c index 6bc559f7bf8..8fbd180c861 100644 --- a/src/test/modules/test_json_parser/test_json_parser_incremental.c +++ b/src/test/modules/test_json_parser/test_json_parser_incremental.c @@ -113,7 +113,7 @@ main(int argc, char **argv) { case 'r': /* chunk range */ run_chunk_ranges = true; - /* fall through */ + pg_fallthrough; case 'c': /* chunk size */ chunk_size = strtou64(optarg, NULL, 10); if (chunk_size > BUFSIZE) diff --git a/src/timezone/zic.c b/src/timezone/zic.c index 8dcc7b337a7..2f36486a350 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -1395,19 +1395,19 @@ gethms(char const *string, char const *errstring) break; case 8: ok = '0' <= xr && xr <= '9'; - /* fallthrough */ + pg_fallthrough; case 7: ok &= ssx == '.'; if (ok && noise) warning(_("fractional seconds rejected by" " pre-2018 versions of zic")); - /* fallthrough */ + pg_fallthrough; case 5: ok &= mmx == ':'; - /* fallthrough */ + pg_fallthrough; case 3: ok &= hhx == ':'; - /* fallthrough */ + pg_fallthrough; case 1: break; } diff --git a/src/tools/pg_bsd_indent/indent.c b/src/tools/pg_bsd_indent/indent.c index 2622cc6227a..6e550ff310f 100644 --- a/src/tools/pg_bsd_indent/indent.c +++ b/src/tools/pg_bsd_indent/indent.c @@ -352,7 +352,7 @@ main(int argc, char **argv) } goto sw_buffer; } - /* FALLTHROUGH */ + pg_fallthrough; default: /* it is the start of a normal statement */ { int remove_newlines; @@ -922,7 +922,7 @@ main(int argc, char **argv) case structure: if (ps.p_l_follow > 0) goto copy_id; - /* FALLTHROUGH */ + pg_fallthrough; case decl: /* we have a declaration type (int, etc.) */ parse(decl); /* let parser worry about indentation */ if (ps.last_token == rparen && ps.tos <= 1) { diff --git a/src/tools/pg_bsd_indent/parse.c b/src/tools/pg_bsd_indent/parse.c index e707da639c7..94cea724393 100644 --- a/src/tools/pg_bsd_indent/parse.c +++ b/src/tools/pg_bsd_indent/parse.c @@ -96,7 +96,7 @@ parse(int tk) /* tk: the code for the construct scanned */ */ ps.i_l_follow = ps.il[ps.tos--]; /* the rest is the same as for dolit and forstmt */ - /* FALLTHROUGH */ + pg_fallthrough; case dolit: /* 'do' */ case forstmt: /* for (...) */ ps.p_stack[++ps.tos] = tk; @@ -303,7 +303,7 @@ reduce(void) case swstmt: /* */ case_ind = ps.cstk[ps.tos - 1]; - /* FALLTHROUGH */ + pg_fallthrough; case decl: /* finish of a declaration */ case elsehead: /* < else> */ -- 2.52.0