diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c index bed2dee3d72..58c1a6221c8 100644 --- a/contrib/dblink/dblink.c +++ b/contrib/dblink/dblink.c @@ -160,8 +160,7 @@ xpstrdup(const char *in) return pstrdup(in); } -static void -pg_attribute_noreturn() +pg_noreturn static void dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2) { char *msg = pchomp(PQerrorMessage(conn)); @@ -170,8 +169,7 @@ dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2) elog(ERROR, "%s: %s", p2, msg); } -static void -pg_attribute_noreturn() +pg_noreturn static void dblink_conn_not_avail(const char *conname) { if (conname) diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h index 37013cd9f82..4b81fceab8e 100644 --- a/contrib/pgcrypto/px.h +++ b/contrib/pgcrypto/px.h @@ -181,7 +181,7 @@ int px_find_hmac(const char *name, PX_HMAC **res); int px_find_cipher(const char *name, PX_Cipher **res); int px_find_combo(const char *name, PX_Combo **res); -void px_THROW_ERROR(int err) pg_attribute_noreturn(); +pg_noreturn void px_THROW_ERROR(int err); const char *px_strerror(int err); const char *px_resolve_alias(const PX_Alias *list, const char *name); diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c index a829a055a97..2c19013c98b 100644 --- a/src/backend/access/transam/xlogrecovery.c +++ b/src/backend/access/transam/xlogrecovery.c @@ -4778,8 +4778,7 @@ check_primary_slot_name(char **newval, void **extra, GucSource source) * that we have odd behaviors such as unexpected GUC ordering dependencies. */ -static void -pg_attribute_noreturn() +pg_noreturn static void error_multiple_recovery_targets(void) { ereport(ERROR, diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c index c2b7a55e347..76a58068665 100644 --- a/src/backend/backup/basebackup_incremental.c +++ b/src/backend/backup/basebackup_incremental.c @@ -139,9 +139,9 @@ static void manifest_process_wal_range(JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn); -static void manifest_report_error(JsonManifestParseContext *context, - const char *fmt,...) - pg_attribute_printf(2, 3) pg_attribute_noreturn(); +pg_noreturn static void manifest_report_error(JsonManifestParseContext *context, + const char *fmt,...) + pg_attribute_printf(2, 3); static int compare_block_numbers(const void *a, const void *b); /* diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 800815dfbcc..71c34027c88 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -317,7 +317,7 @@ int AutovacuumLauncherPid = 0; static Oid do_start_worker(void); static void ProcessAutoVacLauncherInterrupts(void); -static void AutoVacLauncherShutdown(void) pg_attribute_noreturn(); +pg_noreturn static void AutoVacLauncherShutdown(void); static void launcher_determine_sleep(bool canlaunch, bool recursing, struct timeval *nap); static void launch_worker(TimestampTz now); diff --git a/src/backend/postmaster/launch_backend.c b/src/backend/postmaster/launch_backend.c index ecd04655c2a..77fb877dbad 100644 --- a/src/backend/postmaster/launch_backend.c +++ b/src/backend/postmaster/launch_backend.c @@ -171,7 +171,7 @@ static pid_t internal_forkexec(const char *child_kind, int child_slot, typedef struct { const char *name; - void (*main_fn) (const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); + void (*main_fn) (const void *startup_data, size_t startup_data_len); bool shmem_attach; } child_process_kind; diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 57155c00e01..d13846298bd 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -425,7 +425,7 @@ static void LogChildExit(int lev, const char *procname, static void PostmasterStateMachine(void); static void UpdatePMState(PMState newState); -static void ExitPostmaster(int status) pg_attribute_noreturn(); +pg_noreturn static void ExitPostmaster(int status); static int ServerLoop(void); static int BackendStartup(ClientSocket *client_sock); static void report_fork_failure_to_client(ClientSocket *client_sock, int errnum); diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c index 6af5c9fe16c..65b98aa905f 100644 --- a/src/backend/replication/logical/tablesync.c +++ b/src/backend/replication/logical/tablesync.c @@ -139,8 +139,7 @@ static StringInfo copybuf = NULL; /* * Exit routine for synchronization worker. */ -static void -pg_attribute_noreturn() +pg_noreturn static void finish_sync_worker(void) { /* diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c index 446d10c1a7d..d96121b3aad 100644 --- a/src/backend/replication/walsender.c +++ b/src/backend/replication/walsender.c @@ -237,7 +237,7 @@ typedef void (*WalSndSendDataCallback) (void); static void WalSndLoop(WalSndSendDataCallback send_data); static void InitWalSenderSlot(void); static void WalSndKill(int code, Datum arg); -static void WalSndShutdown(void) pg_attribute_noreturn(); +pg_noreturn static void WalSndShutdown(void); static void XLogSendPhysical(void); static void XLogSendLogical(void); static void WalSndDone(WalSndSendDataCallback send_data); diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index 8473448849c..c4ff18ce65e 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -235,10 +235,10 @@ static bool ri_PerformCheck(const RI_ConstraintInfo *riinfo, static void ri_ExtractValues(Relation rel, TupleTableSlot *slot, const RI_ConstraintInfo *riinfo, bool rel_is_pk, Datum *vals, char *nulls); -static void ri_ReportViolation(const RI_ConstraintInfo *riinfo, - Relation pk_rel, Relation fk_rel, - TupleTableSlot *violatorslot, TupleDesc tupdesc, - int queryno, bool is_restrict, bool partgone) pg_attribute_noreturn(); +pg_noreturn static void ri_ReportViolation(const RI_ConstraintInfo *riinfo, + Relation pk_rel, Relation fk_rel, + TupleTableSlot *violatorslot, TupleDesc tupdesc, + int queryno, bool is_restrict, bool partgone); /* diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 87b233cb887..4409e3e6fa8 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -67,8 +67,8 @@ static DynamicFileList *file_tail = NULL; char *Dynamic_library_path; static void *internal_load_library(const char *libname); -static void incompatible_module_error(const char *libname, - const Pg_magic_struct *module_magic_data) pg_attribute_noreturn(); +pg_noreturn static void incompatible_module_error(const char *libname, + const Pg_magic_struct *module_magic_data); static char *expand_dynamic_library_name(const char *name); static void check_restricted_library_name(const char *name); static char *substitute_libpath_macro(const char *name); diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index cd5a00132fc..3f25929f2d8 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -272,7 +272,7 @@ static HASHBUCKET get_hash_entry(HTAB *hashp, int freelist_idx); static void hdefault(HTAB *hashp); static int choose_nelem_alloc(Size entrysize); static bool init_htab(HTAB *hashp, long nelem); -static void hash_corrupted(HTAB *hashp) pg_attribute_noreturn(); +pg_noreturn static void hash_corrupted(HTAB *hashp); static uint32 hash_initial_lookup(HTAB *hashp, uint32 hashvalue, HASHBUCKET **bucketptr); static long next_pow2_long(long num); diff --git a/src/backend/utils/mmgr/slab.c b/src/backend/utils/mmgr/slab.c index ec8eddad863..d32c0d318fb 100644 --- a/src/backend/utils/mmgr/slab.c +++ b/src/backend/utils/mmgr/slab.c @@ -601,8 +601,8 @@ SlabAllocFromNewBlock(MemoryContext context, Size size, int flags) * want to avoid that. */ pg_noinline +pg_noreturn static void -pg_attribute_noreturn() SlabAllocInvalidSize(MemoryContext context, Size size) { SlabContext *slab = (SlabContext *) context; diff --git a/src/bin/pg_combinebackup/load_manifest.c b/src/bin/pg_combinebackup/load_manifest.c index 485fe518e41..8e0d04a26a6 100644 --- a/src/bin/pg_combinebackup/load_manifest.c +++ b/src/bin/pg_combinebackup/load_manifest.c @@ -68,9 +68,9 @@ static void combinebackup_per_wal_range_cb(JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn); -static void report_manifest_error(JsonManifestParseContext *context, - const char *fmt,...) - pg_attribute_printf(2, 3) pg_attribute_noreturn(); +pg_noreturn static void report_manifest_error(JsonManifestParseContext *context, + const char *fmt,...) + pg_attribute_printf(2, 3); /* * Load backup_manifest files from an array of backups and produces an array diff --git a/src/bin/pg_dump/pg_backup_utils.h b/src/bin/pg_dump/pg_backup_utils.h index 38551944513..ba042016879 100644 --- a/src/bin/pg_dump/pg_backup_utils.h +++ b/src/bin/pg_dump/pg_backup_utils.h @@ -29,7 +29,7 @@ extern const char *progname; extern void set_dump_section(const char *arg, int *dumpSections); extern void on_exit_nicely(on_exit_nicely_callback function, void *arg); -extern void exit_nicely(int code) pg_attribute_noreturn(); +pg_noreturn extern void exit_nicely(int code); /* In pg_dump, we modify pg_fatal to call exit_nicely instead of exit */ #undef pg_fatal diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h index f4e375d27c7..4c9d0172149 100644 --- a/src/bin/pg_upgrade/pg_upgrade.h +++ b/src/bin/pg_upgrade/pg_upgrade.h @@ -481,7 +481,7 @@ int get_user_info(char **user_name_p); void check_ok(void); void report_status(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3); void pg_log(eLogType type, const char *fmt,...) pg_attribute_printf(2, 3); -void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2) pg_attribute_noreturn(); +pg_noreturn void pg_fatal(const char *fmt,...) pg_attribute_printf(1, 2); void end_progress_output(void); void cleanup_output_dirs(void); void prep_status(const char *fmt,...) pg_attribute_printf(1, 2); diff --git a/src/bin/pg_verifybackup/pg_verifybackup.c b/src/bin/pg_verifybackup/pg_verifybackup.c index 7c720ab98bd..84edd2cdca5 100644 --- a/src/bin/pg_verifybackup/pg_verifybackup.c +++ b/src/bin/pg_verifybackup/pg_verifybackup.c @@ -69,9 +69,9 @@ static void verifybackup_per_wal_range_cb(JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn); -static void report_manifest_error(JsonManifestParseContext *context, - const char *fmt,...) - pg_attribute_printf(2, 3) pg_attribute_noreturn(); +pg_noreturn static void report_manifest_error(JsonManifestParseContext *context, + const char *fmt,...) + pg_attribute_printf(2, 3); static void verify_tar_backup(verifier_context *context, DIR *dir); static void verify_plain_backup_directory(verifier_context *context, diff --git a/src/bin/pg_verifybackup/pg_verifybackup.h b/src/bin/pg_verifybackup/pg_verifybackup.h index 622c9d82a81..8cb6f9c53ad 100644 --- a/src/bin/pg_verifybackup/pg_verifybackup.h +++ b/src/bin/pg_verifybackup/pg_verifybackup.h @@ -98,8 +98,8 @@ typedef struct verifier_context extern void report_backup_error(verifier_context *context, const char *pg_restrict fmt,...) pg_attribute_printf(2, 3); -extern void report_fatal_error(const char *pg_restrict fmt,...) - pg_attribute_printf(1, 2) pg_attribute_noreturn(); +pg_noreturn extern void report_fatal_error(const char *pg_restrict fmt,...) + pg_attribute_printf(1, 2); extern bool should_ignore_relpath(verifier_context *context, const char *relpath); diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h index 0ba216e5f72..e053c9e2eb6 100644 --- a/src/bin/pgbench/pgbench.h +++ b/src/bin/pgbench/pgbench.h @@ -140,9 +140,9 @@ struct PgBenchExprList extern int expr_yyparse(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner); extern int expr_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner); -extern void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn(); -extern void expr_yyerror_more(yyscan_t yyscanner, const char *message, - const char *more) pg_attribute_noreturn(); +pg_noreturn extern void expr_yyerror(PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner, const char *message); +pg_noreturn extern void expr_yyerror_more(yyscan_t yyscanner, const char *message, + const char *more); extern bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf, int *offset); extern yyscan_t expr_scanner_init(PsqlScanState state, @@ -153,9 +153,9 @@ extern char *expr_scanner_get_substring(PsqlScanState state, int start_offset, bool chomp); -extern void syntax_error(const char *source, int lineno, const char *line, - const char *command, const char *msg, - const char *more, int column) pg_attribute_noreturn(); +pg_noreturn extern void syntax_error(const char *source, int lineno, const char *line, + const char *command, const char *msg, + const char *more, int column); extern bool strtoint64(const char *str, bool errorOK, int64 *result); extern bool strtodouble(const char *str, bool errorOK, double *dv); diff --git a/src/common/parse_manifest.c b/src/common/parse_manifest.c index 05858578207..71973af199b 100644 --- a/src/common/parse_manifest.c +++ b/src/common/parse_manifest.c @@ -114,8 +114,8 @@ static void json_manifest_finalize_wal_range(JsonManifestParseState *parse); static void verify_manifest_checksum(JsonManifestParseState *parse, const char *buffer, size_t size, pg_cryptohash_ctx *incr_ctx); -static void json_manifest_parse_failure(JsonManifestParseContext *context, - char *msg); +pg_noreturn static void json_manifest_parse_failure(JsonManifestParseContext *context, + char *msg); static int hexdecode_char(char c); static bool hexdecode_string(uint8 *result, char *input, int nbytes); @@ -889,6 +889,7 @@ static void json_manifest_parse_failure(JsonManifestParseContext *context, char *msg) { context->error_cb(context, "could not parse backup manifest: %s", msg); + pg_unreachable(); } /* diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h index 69f3d31a4ef..befc4fa1b3d 100644 --- a/src/include/bootstrap/bootstrap.h +++ b/src/include/bootstrap/bootstrap.h @@ -33,7 +33,7 @@ extern PGDLLIMPORT Form_pg_attribute attrtypes[MAXATTR]; extern PGDLLIMPORT int numattr; -extern void BootstrapModeMain(int argc, char *argv[], bool check_only) pg_attribute_noreturn(); +pg_noreturn extern void BootstrapModeMain(int argc, char *argv[], bool check_only); extern void closerel(char *relname); extern void boot_openrel(char *relname); @@ -64,6 +64,6 @@ typedef void *yyscan_t; extern int boot_yyparse(yyscan_t yyscanner); extern int boot_yylex_init(yyscan_t *yyscannerp); extern int boot_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner); -extern void boot_yyerror(yyscan_t yyscanner, const char *message) pg_attribute_noreturn(); +pg_noreturn extern void boot_yyerror(yyscan_t yyscanner, const char *message); #endif /* BOOTSTRAP_H */ diff --git a/src/include/c.h b/src/include/c.h index a14c6315162..94971474154 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -145,6 +145,26 @@ #define pg_nodiscard #endif +/* + * pg_noreturn corresponds to the C11 noreturn/_Noreturn function specifier. + * We can't use the standard name "noreturn" because some third-party code + * uses __attribute__((noreturn)) in headers, which would get confused if + * "noreturn" is defined to "_Noreturn", as is done by . + * + * In a declaration, function specifiers go before the function name. The + * common style is to put them before the return type. (The MSVC fallback has + * the same requirement. The GCC fallback is more flexible.) + */ +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L +#define pg_noreturn _Noreturn +#elif defined(__GNUC__) || defined(__SUNPRO_C) +#define pg_noreturn __attribute__((noreturn)) +#elif defined(_MSC_VER) +#define pg_noreturn __declspec(noreturn) +#else +#define pg_noreturn +#endif + /* * This macro will disable address safety instrumentation for a function * when running with "-fsanitize=address". Think twice before using this! @@ -213,30 +233,24 @@ #define pg_attribute_printf(f,a) #endif -/* GCC and Sunpro support aligned, packed and noreturn */ +/* GCC and Sunpro support aligned and packed */ #if defined(__GNUC__) || defined(__SUNPRO_C) #define pg_attribute_aligned(a) __attribute__((aligned(a))) -#define pg_attribute_noreturn() __attribute__((noreturn)) #define pg_attribute_packed() __attribute__((packed)) -#define HAVE_PG_ATTRIBUTE_NORETURN 1 #elif defined(_MSC_VER) /* - * MSVC supports aligned. noreturn is also possible but in MSVC it is - * declared before the definition while pg_attribute_noreturn() macro - * is currently used after the definition. + * MSVC supports aligned. * * Packing is also possible but only by wrapping the entire struct definition * which doesn't fit into our current macro declarations. */ #define pg_attribute_aligned(a) __declspec(align(a)) -#define pg_attribute_noreturn() #else /* * NB: aligned and packed are not given default definitions because they * affect code functionality; they *must* be implemented by the compiler * if they are to be used. */ -#define pg_attribute_noreturn() #endif /* @@ -858,8 +872,8 @@ typedef NameData *Name; * we should declare it as long as !FRONTEND. */ #ifndef FRONTEND -extern void ExceptionalCondition(const char *conditionName, - const char *fileName, int lineNumber) pg_attribute_noreturn(); +pg_noreturn extern void ExceptionalCondition(const char *conditionName, + const char *fileName, int lineNumber); #endif /* diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 6d9348bac80..dd22b5efdfd 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -160,6 +160,6 @@ extern List *defGetQualifiedName(DefElem *def); extern TypeName *defGetTypeName(DefElem *def); extern int defGetTypeLength(DefElem *def); extern List *defGetStringList(DefElem *def); -extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate) pg_attribute_noreturn(); +pg_noreturn extern void errorConflictingDefElem(DefElem *defel, ParseState *pstate); #endif /* DEFREM_H */ diff --git a/src/include/common/parse_manifest.h b/src/include/common/parse_manifest.h index 255cab5c2a9..6172d1d5224 100644 --- a/src/include/common/parse_manifest.h +++ b/src/include/common/parse_manifest.h @@ -34,8 +34,7 @@ typedef void (*json_manifest_per_wal_range_callback) (JsonManifestParseContext * TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn); typedef void (*json_manifest_error_callback) (JsonManifestParseContext *, - const char *fmt,...) pg_attribute_printf(2, 3) - pg_attribute_noreturn(); + const char *fmt,...) pg_attribute_printf(2, 3); struct JsonManifestParseContext { diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h index ff7983ee90a..bfef95baea2 100644 --- a/src/include/mb/pg_wchar.h +++ b/src/include/mb/pg_wchar.h @@ -768,9 +768,9 @@ extern void check_encoding_conversion_args(int src_encoding, int expected_src_encoding, int expected_dest_encoding); -extern void report_invalid_encoding(int encoding, const char *mbstr, int len) pg_attribute_noreturn(); -extern void report_untranslatable_char(int src_encoding, int dest_encoding, - const char *mbstr, int len) pg_attribute_noreturn(); +pg_noreturn extern void report_invalid_encoding(int encoding, const char *mbstr, int len); +pg_noreturn extern void report_untranslatable_char(int src_encoding, int dest_encoding, + const char *mbstr, int len); extern int local2local(const unsigned char *l, unsigned char *p, int len, int src_encoding, int dest_encoding, diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h index 3ece5cd4eef..d59599cf242 100644 --- a/src/include/parser/parse_relation.h +++ b/src/include/parser/parse_relation.h @@ -110,9 +110,9 @@ extern bool isLockedRefname(ParseState *pstate, const char *refname); extern void addNSItemToQuery(ParseState *pstate, ParseNamespaceItem *nsitem, bool addToJoinList, bool addToRelNameSpace, bool addToVarNameSpace); -extern void errorMissingRTE(ParseState *pstate, RangeVar *relation) pg_attribute_noreturn(); -extern void errorMissingColumn(ParseState *pstate, - const char *relname, const char *colname, int location) pg_attribute_noreturn(); +pg_noreturn extern void errorMissingRTE(ParseState *pstate, RangeVar *relation); +pg_noreturn extern void errorMissingColumn(ParseState *pstate, + const char *relname, const char *colname, int location); extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up, VarReturningType returning_type, int location, bool include_dropped, diff --git a/src/include/parser/scanner.h b/src/include/parser/scanner.h index 74ad86698ac..8d202d5b284 100644 --- a/src/include/parser/scanner.h +++ b/src/include/parser/scanner.h @@ -145,6 +145,6 @@ extern void setup_scanner_errposition_callback(ScannerCallbackState *scbstate, core_yyscan_t yyscanner, int location); extern void cancel_scanner_errposition_callback(ScannerCallbackState *scbstate); -extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) pg_attribute_noreturn(); +pg_noreturn extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner); #endif /* SCANNER_H */ diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h index 6a95e5f55bd..e8135f41a1c 100644 --- a/src/include/postmaster/autovacuum.h +++ b/src/include/postmaster/autovacuum.h @@ -58,8 +58,8 @@ extern void autovac_init(void); /* called from postmaster when a worker could not be forked */ extern void AutoVacWorkerFailed(void); -extern void AutoVacLauncherMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); -extern void AutoVacWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void AutoVacLauncherMain(const void *startup_data, size_t startup_data_len); +pg_noreturn extern void AutoVacWorkerMain(const void *startup_data, size_t startup_data_len); extern bool AutoVacuumRequestWork(AutoVacuumWorkItemType type, Oid relationId, BlockNumber blkno); diff --git a/src/include/postmaster/bgworker_internals.h b/src/include/postmaster/bgworker_internals.h index 29e6f44cf08..26cbc821edf 100644 --- a/src/include/postmaster/bgworker_internals.h +++ b/src/include/postmaster/bgworker_internals.h @@ -52,6 +52,6 @@ extern void ForgetUnstartedBackgroundWorkers(void); extern void ResetBackgroundWorkerCrashTimes(void); /* Entry point for background worker processes */ -extern void BackgroundWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void BackgroundWorkerMain(const void *startup_data, size_t startup_data_len); #endif /* BGWORKER_INTERNALS_H */ diff --git a/src/include/postmaster/bgwriter.h b/src/include/postmaster/bgwriter.h index 4fd717169f0..800ecbfd13b 100644 --- a/src/include/postmaster/bgwriter.h +++ b/src/include/postmaster/bgwriter.h @@ -27,8 +27,8 @@ extern PGDLLIMPORT int CheckPointTimeout; extern PGDLLIMPORT int CheckPointWarning; extern PGDLLIMPORT double CheckPointCompletionTarget; -extern void BackgroundWriterMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); -extern void CheckpointerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void BackgroundWriterMain(const void *startup_data, size_t startup_data_len); +pg_noreturn extern void CheckpointerMain(const void *startup_data, size_t startup_data_len); extern void RequestCheckpoint(int flags); extern void CheckpointWriteDelay(int flags, double progress); diff --git a/src/include/postmaster/pgarch.h b/src/include/postmaster/pgarch.h index a32d78feb27..ef7b1252086 100644 --- a/src/include/postmaster/pgarch.h +++ b/src/include/postmaster/pgarch.h @@ -29,7 +29,7 @@ extern Size PgArchShmemSize(void); extern void PgArchShmemInit(void); extern bool PgArchCanRestart(void); -extern void PgArchiverMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void PgArchiverMain(const void *startup_data, size_t startup_data_len); extern void PgArchWakeup(void); extern void PgArchForceDirScan(void); diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h index aa786bfacf3..39566ee2bd5 100644 --- a/src/include/postmaster/postmaster.h +++ b/src/include/postmaster/postmaster.h @@ -90,7 +90,7 @@ extern PGDLLIMPORT const char *progname; extern PGDLLIMPORT bool redirection_done; extern PGDLLIMPORT bool LoadedSSL; -extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); +pg_noreturn extern void PostmasterMain(int argc, char *argv[]); extern void ClosePostmasterPorts(bool am_syslogger); extern void InitProcessGlobals(void); @@ -113,7 +113,7 @@ extern pid_t postmaster_child_launch(BackendType child_type, struct ClientSocket *client_sock); const char *PostmasterChildName(BackendType child_type); #ifdef EXEC_BACKEND -extern void SubPostmasterMain(int argc, char *argv[]) pg_attribute_noreturn(); +pg_noreturn extern void SubPostmasterMain(int argc, char *argv[]); #endif /* defined in pmchild.c */ diff --git a/src/include/postmaster/startup.h b/src/include/postmaster/startup.h index 158f52255a6..ec2c8d3bff5 100644 --- a/src/include/postmaster/startup.h +++ b/src/include/postmaster/startup.h @@ -26,7 +26,7 @@ extern PGDLLIMPORT int log_startup_progress_interval; extern void ProcessStartupProcInterrupts(void); -extern void StartupProcessMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void StartupProcessMain(const void *startup_data, size_t startup_data_len); extern void PreRestoreCommand(void); extern void PostRestoreCommand(void); extern bool IsPromoteSignaled(void); diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h index 197d8e43fdd..15fca58ff5d 100644 --- a/src/include/postmaster/syslogger.h +++ b/src/include/postmaster/syslogger.h @@ -90,7 +90,7 @@ extern int SysLogger_Start(int child_slot); extern void write_syslogger_file(const char *buffer, int count, int destination); -extern void SysLoggerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void SysLoggerMain(const void *startup_data, size_t startup_data_len); extern bool CheckLogrotateSignal(void); extern void RemoveLogrotateSignalFiles(void); diff --git a/src/include/postmaster/walsummarizer.h b/src/include/postmaster/walsummarizer.h index e1086d02c8b..34dda607c69 100644 --- a/src/include/postmaster/walsummarizer.h +++ b/src/include/postmaster/walsummarizer.h @@ -21,7 +21,7 @@ extern PGDLLIMPORT int wal_summary_keep_time; extern Size WalSummarizerShmemSize(void); extern void WalSummarizerShmemInit(void); -extern void WalSummarizerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void WalSummarizerMain(const void *startup_data, size_t startup_data_len); extern void GetWalSummarizerState(TimeLineID *summarized_tli, XLogRecPtr *summarized_lsn, diff --git a/src/include/postmaster/walwriter.h b/src/include/postmaster/walwriter.h index ea8c22b174f..58e5c913d5a 100644 --- a/src/include/postmaster/walwriter.h +++ b/src/include/postmaster/walwriter.h @@ -18,6 +18,6 @@ extern PGDLLIMPORT int WalWriterDelay; extern PGDLLIMPORT int WalWriterFlushAfter; -extern void WalWriterMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void WalWriterMain(const void *startup_data, size_t startup_data_len); #endif /* _WALWRITER_H */ diff --git a/src/include/replication/slotsync.h b/src/include/replication/slotsync.h index 6cde7f81cec..16b721463dd 100644 --- a/src/include/replication/slotsync.h +++ b/src/include/replication/slotsync.h @@ -26,7 +26,7 @@ extern PGDLLIMPORT char *PrimarySlotName; extern char *CheckAndGetDbnameFromConninfo(void); extern bool ValidateSlotSyncParams(int elevel); -extern void ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void ReplSlotSyncWorkerMain(const void *startup_data, size_t startup_data_len); extern void ShutDownSlotSync(void); extern bool SlotSyncWorkerCanRestart(void); diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h index 992be93cce8..ecca21fecb4 100644 --- a/src/include/replication/walreceiver.h +++ b/src/include/replication/walreceiver.h @@ -486,7 +486,7 @@ walrcv_clear_result(WalRcvExecResult *walres) } /* prototypes for functions in walreceiver.c */ -extern void WalReceiverMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void WalReceiverMain(const void *startup_data, size_t startup_data_len); extern void ProcessWalRcvInterrupts(void); extern void WalRcvForceReply(void); diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h index 814b812432a..0fc77f1b4af 100644 --- a/src/include/replication/walsender_private.h +++ b/src/include/replication/walsender_private.h @@ -132,7 +132,7 @@ typedef void *yyscan_t; #endif extern int replication_yyparse(Node **replication_parse_result_p, yyscan_t yyscanner); extern int replication_yylex(union YYSTYPE *yylval_param, yyscan_t yyscanner); -extern void replication_yyerror(Node **replication_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn(); +pg_noreturn extern void replication_yyerror(Node **replication_parse_result_p, yyscan_t yyscanner, const char *message); extern void replication_scanner_init(const char *str, yyscan_t *yyscannerp); extern void replication_scanner_finish(yyscan_t yyscanner); extern bool replication_scanner_is_replication_command(yyscan_t yyscanner); diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h index e0f5f92e947..3baf418b3d1 100644 --- a/src/include/storage/ipc.h +++ b/src/include/storage/ipc.h @@ -65,7 +65,7 @@ typedef void (*shmem_startup_hook_type) (void); extern PGDLLIMPORT bool proc_exit_inprogress; extern PGDLLIMPORT bool shmem_exit_inprogress; -extern void proc_exit(int code) pg_attribute_noreturn(); +pg_noreturn extern void proc_exit(int code); extern void shmem_exit(int code); extern void on_proc_exit(pg_on_exit_callback function, Datum arg); extern void on_shmem_exit(pg_on_exit_callback function, Datum arg); diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 1076995518f..c0c0b0f7a2d 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -605,7 +605,7 @@ extern void lock_twophase_standby_recover(TransactionId xid, uint16 info, extern DeadLockState DeadLockCheck(PGPROC *proc); extern PGPROC *GetBlockingAutoVacuumPgproc(void); -extern void DeadLockReport(void) pg_attribute_noreturn(); +pg_noreturn extern void DeadLockReport(void); extern void RememberSimpleDeadLock(PGPROC *proc1, LOCKMODE lockmode, LOCK *lock, diff --git a/src/include/tcop/backend_startup.h b/src/include/tcop/backend_startup.h index 2912ef80288..578828c1caf 100644 --- a/src/include/tcop/backend_startup.h +++ b/src/include/tcop/backend_startup.h @@ -117,6 +117,6 @@ typedef struct ConnectionTiming TimestampTz auth_end; } ConnectionTiming; -extern void BackendMain(const void *startup_data, size_t startup_data_len) pg_attribute_noreturn(); +pg_noreturn extern void BackendMain(const void *startup_data, size_t startup_data_len); #endif /* BACKEND_STARTUP_H */ diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index a62367f7793..a83cc4f4850 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -69,19 +69,19 @@ extern List *pg_plan_queries(List *querytrees, const char *query_string, ParamListInfo boundParams); extern void die(SIGNAL_ARGS); -extern void quickdie(SIGNAL_ARGS) pg_attribute_noreturn(); +pg_noreturn extern void quickdie(SIGNAL_ARGS); extern void StatementCancelHandler(SIGNAL_ARGS); -extern void FloatExceptionHandler(SIGNAL_ARGS) pg_attribute_noreturn(); +pg_noreturn extern void FloatExceptionHandler(SIGNAL_ARGS); extern void HandleRecoveryConflictInterrupt(ProcSignalReason reason); extern void ProcessClientReadInterrupt(bool blocked); extern void ProcessClientWriteInterrupt(bool blocked); extern void process_postgres_switches(int argc, char *argv[], GucContext ctx, const char **dbname); -extern void PostgresSingleUserMain(int argc, char *argv[], - const char *username) pg_attribute_noreturn(); -extern void PostgresMain(const char *dbname, - const char *username) pg_attribute_noreturn(); +pg_noreturn extern void PostgresSingleUserMain(int argc, char *argv[], + const char *username); +pg_noreturn extern void PostgresMain(const char *dbname, + const char *username); extern void ResetUsage(void); extern void ShowUsage(const char *title); extern int check_log_duration(char *msec_str, bool was_logged); diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index a0244bff1fc..855c147325b 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -415,17 +415,8 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack; error_context_stack = _save_context_stack##__VA_ARGS__; \ } while (0) -/* - * Some compilers understand pg_attribute_noreturn(); for other compilers, - * insert pg_unreachable() so that the compiler gets the point. - */ -#ifdef HAVE_PG_ATTRIBUTE_NORETURN #define PG_RE_THROW() \ pg_re_throw() -#else -#define PG_RE_THROW() \ - (pg_re_throw(), pg_unreachable()) -#endif extern PGDLLIMPORT sigjmp_buf *PG_exception_stack; @@ -476,9 +467,9 @@ extern void EmitErrorReport(void); extern ErrorData *CopyErrorData(void); extern void FreeErrorData(ErrorData *edata); extern void FlushErrorState(void); -extern void ReThrowError(ErrorData *edata) pg_attribute_noreturn(); +pg_noreturn extern void ReThrowError(ErrorData *edata); extern void ThrowErrorData(ErrorData *edata); -extern void pg_re_throw(void) pg_attribute_noreturn(); +pg_noreturn extern void pg_re_throw(void); extern char *GetErrorContextStack(void); diff --git a/src/include/utils/float.h b/src/include/utils/float.h index 9233fa479c6..0e2e9ec5347 100644 --- a/src/include/utils/float.h +++ b/src/include/utils/float.h @@ -37,9 +37,9 @@ extern PGDLLIMPORT int extra_float_digits; /* * Utility functions in float.c */ -extern void float_overflow_error(void) pg_attribute_noreturn(); -extern void float_underflow_error(void) pg_attribute_noreturn(); -extern void float_zero_divide_error(void) pg_attribute_noreturn(); +pg_noreturn extern void float_overflow_error(void); +pg_noreturn extern void float_underflow_error(void); +pg_noreturn extern void float_zero_divide_error(void); extern int is_infinite(float8 val); extern float8 float8in_internal(char *num, char **endptr_p, const char *type_name, const char *orig_string, diff --git a/src/include/utils/help_config.h b/src/include/utils/help_config.h index d4f26eb49d0..4e58f130054 100644 --- a/src/include/utils/help_config.h +++ b/src/include/utils/help_config.h @@ -12,6 +12,6 @@ #ifndef HELP_CONFIG_H #define HELP_CONFIG_H 1 -extern void GucInfoMain(void) pg_attribute_noreturn(); +pg_noreturn extern void GucInfoMain(void); #endif diff --git a/src/include/utils/memutils_internal.h b/src/include/utils/memutils_internal.h index 693650353c6..a6caa6335e3 100644 --- a/src/include/utils/memutils_internal.h +++ b/src/include/utils/memutils_internal.h @@ -160,8 +160,8 @@ extern void MemoryContextCreate(MemoryContext node, extern void *MemoryContextAllocationFailure(MemoryContext context, Size size, int flags); -extern void MemoryContextSizeFailure(MemoryContext context, Size size, - int flags) pg_attribute_noreturn(); +pg_noreturn extern void MemoryContextSizeFailure(MemoryContext context, Size size, + int flags); static inline void MemoryContextCheckSize(MemoryContext context, Size size, int flags) diff --git a/src/interfaces/ecpg/preproc/preproc_extern.h b/src/interfaces/ecpg/preproc/preproc_extern.h index a60b0381fbb..2c89e30621e 100644 --- a/src/interfaces/ecpg/preproc/preproc_extern.h +++ b/src/interfaces/ecpg/preproc/preproc_extern.h @@ -89,7 +89,7 @@ extern char *cat_str(int count,...); extern char *make2_str(const char *str1, const char *str2); extern char *make3_str(const char *str1, const char *str2, const char *str3); extern void mmerror(int error_code, enum errortype type, const char *error,...) pg_attribute_printf(3, 4); -extern void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn(); +pg_noreturn extern void mmfatal(int error_code, const char *error,...) pg_attribute_printf(2, 3); extern void output_get_descr_header(const char *desc_name); extern void output_get_descr(const char *desc_name, const char *index); extern void output_set_descr_header(const char *desc_name); diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h index d73996e09c0..aea0d0f98b2 100644 --- a/src/pl/plpgsql/src/plpgsql.h +++ b/src/pl/plpgsql/src/plpgsql.h @@ -1354,7 +1354,7 @@ extern int plpgsql_peek(yyscan_t yyscanner); extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc, int *tok2_loc, yyscan_t yyscanner); extern int plpgsql_scanner_errposition(int location, yyscan_t yyscanner); -extern void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message) pg_attribute_noreturn(); +pg_noreturn extern void plpgsql_yyerror(YYLTYPE *yyllocp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner, const char *message); extern int plpgsql_location_to_lineno(int location, yyscan_t yyscanner); extern int plpgsql_latest_lineno(yyscan_t yyscanner); extern yyscan_t plpgsql_scanner_init(const char *str); diff --git a/src/test/modules/libpq_pipeline/libpq_pipeline.c b/src/test/modules/libpq_pipeline/libpq_pipeline.c index 7ff18e91e66..ac9ac95135f 100644 --- a/src/test/modules/libpq_pipeline/libpq_pipeline.c +++ b/src/test/modules/libpq_pipeline/libpq_pipeline.c @@ -24,7 +24,7 @@ static void exit_nicely(PGconn *conn); -static void pg_attribute_noreturn() pg_fatal_impl(int line, const char *fmt,...) +pg_noreturn static void pg_fatal_impl(int line, const char *fmt,...) pg_attribute_printf(2, 3); static bool process_result(PGconn *conn, PGresult *res, int results, int numsent); @@ -71,8 +71,7 @@ exit_nicely(PGconn *conn) * Print an error to stderr and terminate the program. */ #define pg_fatal(...) pg_fatal_impl(__LINE__, __VA_ARGS__) -static void -pg_attribute_noreturn() +pg_noreturn static void pg_fatal_impl(int line, const char *fmt,...) { va_list args; diff --git a/src/test/modules/test_shm_mq/test_shm_mq.h b/src/test/modules/test_shm_mq/test_shm_mq.h index 9ad9f63b44e..5346557d473 100644 --- a/src/test/modules/test_shm_mq/test_shm_mq.h +++ b/src/test/modules/test_shm_mq/test_shm_mq.h @@ -40,6 +40,6 @@ extern void test_shm_mq_setup(int64 queue_size, int32 nworkers, shm_mq_handle **input); /* Main entrypoint for a worker. */ -extern PGDLLEXPORT void test_shm_mq_main(Datum) pg_attribute_noreturn(); +pg_noreturn extern PGDLLEXPORT void test_shm_mq_main(Datum); #endif diff --git a/src/test/modules/worker_spi/worker_spi.c b/src/test/modules/worker_spi/worker_spi.c index 5b87d4f7038..9c53d896b6a 100644 --- a/src/test/modules/worker_spi/worker_spi.c +++ b/src/test/modules/worker_spi/worker_spi.c @@ -44,7 +44,7 @@ PG_MODULE_MAGIC; PG_FUNCTION_INFO_V1(worker_spi_launch); -PGDLLEXPORT void worker_spi_main(Datum main_arg) pg_attribute_noreturn(); +PGDLLEXPORT pg_noreturn void worker_spi_main(Datum main_arg); /* GUC variables */ static int worker_spi_naptime = 10; diff --git a/src/timezone/zic.c b/src/timezone/zic.c index d605c721ecf..3b70b888180 100644 --- a/src/timezone/zic.c +++ b/src/timezone/zic.c @@ -117,11 +117,11 @@ extern int link(const char *target, const char *linkname); (itssymlink(target) ? (errno = ENOTSUP, -1) : link(target, linkname)) #endif -static void memory_exhausted(const char *msg) pg_attribute_noreturn(); +pg_noreturn static void memory_exhausted(const char *msg); static void verror(const char *string, va_list args) pg_attribute_printf(1, 0); static void error(const char *string,...) pg_attribute_printf(1, 2); static void warning(const char *string,...) pg_attribute_printf(1, 2); -static void usage(FILE *stream, int status) pg_attribute_noreturn(); +pg_noreturn static void usage(FILE *stream, int status); static void addtt(zic_t starttime, int type); static int addtype(zic_t utoff, char const *abbr, bool isdst, bool ttisstd, bool ttisut); diff --git a/src/tools/pg_bsd_indent/err.h b/src/tools/pg_bsd_indent/err.h index a3e8f978255..1083462088e 100644 --- a/src/tools/pg_bsd_indent/err.h +++ b/src/tools/pg_bsd_indent/err.h @@ -37,9 +37,9 @@ * This is cut down to just the minimum that we need to build indent. */ -void err(int, const char *, ...) - pg_attribute_noreturn() pg_attribute_printf(2, 3); -void errx(int, const char *, ...) - pg_attribute_noreturn() pg_attribute_printf(2, 3); +pg_noreturn void err(int, const char *, ...) + pg_attribute_printf(2, 3); +pg_noreturn void errx(int, const char *, ...) + pg_attribute_printf(2, 3); #endif /* !_ERR_H_ */