Subject: [PATCH v1] Change pg_attribute_noreturn() to pg_noreturn, move to before return type.

From: Andres Freund <[email-masked]>
Date: Tue, 12 Nov 2019 13:55:39 -0800

---
 contrib/cube/cubedata.h                      |  2 +-
 contrib/dblink/dblink.c                      |  6 ++----
 contrib/pgcrypto/px.h                        |  2 +-
 contrib/seg/segdata.h                        |  2 +-
 src/backend/postmaster/autovacuum.c          |  4 ++--
 src/backend/postmaster/pgarch.c              |  2 +-
 src/backend/postmaster/pgstat.c              |  2 +-
 src/backend/postmaster/postmaster.c          |  4 ++--
 src/backend/postmaster/syslogger.c           |  2 +-
 src/backend/replication/logical/tablesync.c  |  3 +--
 src/backend/replication/walsender.c          |  2 +-
 src/backend/utils/adt/json.c                 |  4 ++--
 src/backend/utils/adt/ri_triggers.c          |  8 ++++----
 src/backend/utils/fmgr/dfmgr.c               |  4 ++--
 src/backend/utils/misc/guc.c                 |  3 +--
 src/bin/pg_dump/pg_backup_utils.h            |  2 +-
 src/bin/pg_upgrade/pg_upgrade.h              |  2 +-
 src/bin/pgbench/pgbench.h                    | 12 ++++++------
 src/include/bootstrap/bootstrap.h            |  4 ++--
 src/include/c.h                              | 10 +++++-----
 src/include/mb/pg_wchar.h                    |  6 +++---
 src/include/parser/parse_relation.h          |  6 +++---
 src/include/parser/scanner.h                 |  2 +-
 src/include/pgstat.h                         |  2 +-
 src/include/postmaster/autovacuum.h          |  4 ++--
 src/include/postmaster/bgworker_internals.h  |  2 +-
 src/include/postmaster/bgwriter.h            |  4 ++--
 src/include/postmaster/pgarch.h              |  2 +-
 src/include/postmaster/postmaster.h          |  4 ++--
 src/include/postmaster/startup.h             |  2 +-
 src/include/postmaster/syslogger.h           |  2 +-
 src/include/postmaster/walwriter.h           |  2 +-
 src/include/replication/walreceiver.h        |  2 +-
 src/include/replication/walsender_private.h  |  2 +-
 src/include/storage/ipc.h                    |  2 +-
 src/include/storage/lock.h                   |  2 +-
 src/include/tcop/tcopprot.h                  | 10 +++++-----
 src/include/utils/datetime.h                 |  4 ++--
 src/include/utils/elog.h                     |  8 ++++----
 src/include/utils/help_config.h              |  2 +-
 src/interfaces/ecpg/preproc/preproc_extern.h |  2 +-
 src/pl/plpgsql/src/plpgsql.h                 |  2 +-
 src/test/modules/test_shm_mq/test_shm_mq.h   |  2 +-
 src/test/modules/worker_spi/worker_spi.c     |  2 +-
 src/timezone/zic.c                           |  4 ++--
 45 files changed, 79 insertions(+), 83 deletions(-)

diff --git a/contrib/cube/cubedata.h b/contrib/cube/cubedata.h
index dbe7d4f7429..178fb46f217 100644
--- a/contrib/cube/cubedata.h
+++ b/contrib/cube/cubedata.h
@@ -61,7 +61,7 @@ typedef struct NDBOX
 
 /* in cubescan.l */
 extern int	cube_yylex(void);
-extern void cube_yyerror(NDBOX **result, const char *message) pg_attribute_noreturn();
+extern pg_noreturn void cube_yyerror(NDBOX **result, const char *message);
 extern void cube_scanner_init(const char *str);
 extern void cube_scanner_finish(void);
 
diff --git a/contrib/dblink/dblink.c b/contrib/dblink/dblink.c
index 7e225589a9b..371b89383d9 100644
--- a/contrib/dblink/dblink.c
+++ b/contrib/dblink/dblink.c
@@ -152,8 +152,7 @@ xpstrdup(const char *in)
 	return pstrdup(in);
 }
 
-static void
-pg_attribute_noreturn()
+static pg_noreturn void
 dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2)
 {
 	char	   *msg = pchomp(PQerrorMessage(conn));
@@ -163,8 +162,7 @@ dblink_res_internalerror(PGconn *conn, PGresult *res, const char *p2)
 	elog(ERROR, "%s: %s", p2, msg);
 }
 
-static void
-pg_attribute_noreturn()
+static pg_noreturn void
 dblink_conn_not_avail(const char *conname)
 {
 	if (conname)
diff --git a/contrib/pgcrypto/px.h b/contrib/pgcrypto/px.h
index 0d4722a04a0..a3f3a182a66 100644
--- a/contrib/pgcrypto/px.h
+++ b/contrib/pgcrypto/px.h
@@ -184,7 +184,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 *aliases, const char *name);
diff --git a/contrib/seg/segdata.h b/contrib/seg/segdata.h
index 9488bf3a81a..a5d8ac3f591 100644
--- a/contrib/seg/segdata.h
+++ b/contrib/seg/segdata.h
@@ -16,7 +16,7 @@ extern int	significant_digits(const char *str);
 
 /* in segscan.l */
 extern int	seg_yylex(void);
-extern void seg_yyerror(SEG *result, const char *message) pg_attribute_noreturn();
+extern pg_noreturn void seg_yyerror(SEG *result, const char *message);
 extern void seg_scanner_init(const char *str);
 extern void seg_scanner_finish(void);
 
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index c1dd8168caf..a266bdeb1ae 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -307,8 +307,8 @@ int			AutovacuumLauncherPid = 0;
 static pid_t avlauncher_forkexec(void);
 static pid_t avworker_forkexec(void);
 #endif
-NON_EXEC_STATIC void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
-NON_EXEC_STATIC void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
+NON_EXEC_STATIC pg_noreturn void AutoVacWorkerMain(int argc, char *argv[]);
+NON_EXEC_STATIC pg_noreturn void AutoVacLauncherMain(int argc, char *argv[]);
 
 static Oid	do_start_worker(void);
 static void launcher_determine_sleep(bool canlaunch, bool recursing,
diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index f84f882c4cb..5b8460e4d0f 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -96,7 +96,7 @@ static volatile sig_atomic_t ready_to_stop = false;
 static pid_t pgarch_forkexec(void);
 #endif
 
-NON_EXEC_STATIC void PgArchiverMain(int argc, char *argv[]) pg_attribute_noreturn();
+NON_EXEC_STATIC pg_noreturn void PgArchiverMain(int argc, char *argv[]);
 static void pgarch_exit(SIGNAL_ARGS);
 static void ArchSigHupHandler(SIGNAL_ARGS);
 static void ArchSigTermHandler(SIGNAL_ARGS);
diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c
index 011076c3e3e..c0641ce6123 100644
--- a/src/backend/postmaster/pgstat.c
+++ b/src/backend/postmaster/pgstat.c
@@ -284,7 +284,7 @@ static instr_time total_func_time;
 static pid_t pgstat_forkexec(void);
 #endif
 
-NON_EXEC_STATIC void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn();
+NON_EXEC_STATIC pg_noreturn void PgstatCollectorMain(int argc, char *argv[]);
 static void pgstat_exit(SIGNAL_ARGS);
 static void pgstat_beshutdown_hook(int code, Datum arg);
 static void pgstat_sighup_handler(SIGNAL_ARGS);
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c
index 5f303591652..1f5c6ab403e 100644
--- a/src/backend/postmaster/postmaster.c
+++ b/src/backend/postmaster/postmaster.c
@@ -400,8 +400,8 @@ static void LogChildExit(int lev, const char *procname,
 						 int pid, int exitstatus);
 static void PostmasterStateMachine(void);
 static void BackendInitialize(Port *port);
-static void BackendRun(Port *port) pg_attribute_noreturn();
-static void ExitPostmaster(int status) pg_attribute_noreturn();
+static pg_noreturn void BackendRun(Port *port);
+static pg_noreturn void ExitPostmaster(int status);
 static int	ServerLoop(void);
 static int	BackendStartup(Port *port);
 static int	ProcessStartupPacket(Port *port, bool secure_done);
diff --git a/src/backend/postmaster/syslogger.c b/src/backend/postmaster/syslogger.c
index bb2baff7631..cda31f10546 100644
--- a/src/backend/postmaster/syslogger.c
+++ b/src/backend/postmaster/syslogger.c
@@ -137,7 +137,7 @@ static volatile sig_atomic_t rotation_requested = false;
 static pid_t syslogger_forkexec(void);
 static void syslogger_parseArgs(int argc, char *argv[]);
 #endif
-NON_EXEC_STATIC void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn();
+NON_EXEC_STATIC pg_noreturn void SysLoggerMain(int argc, char *argv[]);
 static void process_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
 static void flush_pipe_input(char *logbuffer, int *bytes_in_logbuffer);
 static FILE *logfile_open(const char *filename, const char *mode,
diff --git a/src/backend/replication/logical/tablesync.c b/src/backend/replication/logical/tablesync.c
index 7881079e96b..a3302e12663 100644
--- a/src/backend/replication/logical/tablesync.c
+++ b/src/backend/replication/logical/tablesync.c
@@ -117,8 +117,7 @@ StringInfo	copybuf = NULL;
 /*
  * Exit routine for synchronization worker.
  */
-static void
-pg_attribute_noreturn()
+static pg_noreturn void
 finish_sync_worker(void)
 {
 	/*
diff --git a/src/backend/replication/walsender.c b/src/backend/replication/walsender.c
index 7f5671504f7..6ab7966818f 100644
--- a/src/backend/replication/walsender.c
+++ b/src/backend/replication/walsender.c
@@ -222,7 +222,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();
+static pg_noreturn void WalSndShutdown(void);
 static void XLogSendPhysical(void);
 static void XLogSendLogical(void);
 static void WalSndDone(WalSndSendDataCallback send_data);
diff --git a/src/backend/utils/adt/json.c b/src/backend/utils/adt/json.c
index d4ba3bd87db..fd03c0315c5 100644
--- a/src/backend/utils/adt/json.c
+++ b/src/backend/utils/adt/json.c
@@ -84,8 +84,8 @@ static void parse_object_field(JsonLexContext *lex, JsonSemAction *sem);
 static void parse_object(JsonLexContext *lex, JsonSemAction *sem);
 static void parse_array_element(JsonLexContext *lex, JsonSemAction *sem);
 static void parse_array(JsonLexContext *lex, JsonSemAction *sem);
-static void report_parse_error(JsonParseContext ctx, JsonLexContext *lex) pg_attribute_noreturn();
-static void report_invalid_token(JsonLexContext *lex) pg_attribute_noreturn();
+static pg_noreturn void report_parse_error(JsonParseContext ctx, JsonLexContext *lex);
+static pg_noreturn void report_invalid_token(JsonLexContext *lex);
 static int	report_json_context(JsonLexContext *lex);
 static char *extract_mb_char(char *s);
 static void composite_to_json(Datum composite, StringInfo result,
diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c
index caf27f8bcb4..bd94f22507e 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -218,10 +218,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 partgone) pg_attribute_noreturn();
+static pg_noreturn void ri_ReportViolation(const RI_ConstraintInfo *riinfo,
+										   Relation pk_rel, Relation fk_rel,
+										   TupleTableSlot *violatorslot, TupleDesc tupdesc,
+										   int queryno, bool partgone);

 /*
diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c
index be684786d64..88c4978f348 100644
--- a/src/backend/utils/fmgr/dfmgr.c
+++ b/src/backend/utils/fmgr/dfmgr.c
@@ -77,8 +77,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();
+static pg_noreturn void incompatible_module_error(const char *libname,
+												  const Pg_magic_struct *module_magic_data);
 static void internal_unload_library(const char *libname);
 static bool file_exists(const char *name);
 static char *expand_dynamic_library_name(const char *name);
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 994bf37477a..92e84bda2ba 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -11624,8 +11624,7 @@ assign_recovery_target_timeline(const char *newval, void *extra)
  * string.
  */
 
-static void
-pg_attribute_noreturn()
+static pg_noreturn void
 error_multiple_recovery_targets(void)
 {
 	ereport(ERROR,
diff --git a/src/bin/pg_dump/pg_backup_utils.h b/src/bin/pg_dump/pg_backup_utils.h
index 619c9fe08c8..c5c81b41a49 100644
--- a/src/bin/pg_dump/pg_backup_utils.h
+++ b/src/bin/pg_dump/pg_backup_utils.h
@@ -31,7 +31,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();
+extern pg_noreturn void exit_nicely(int code);
 
 #define fatal(...) do { pg_log_error(__VA_ARGS__); exit_nicely(1); } while(0)
 
diff --git a/src/bin/pg_upgrade/pg_upgrade.h b/src/bin/pg_upgrade/pg_upgrade.h
index 729f86aa32d..6150883a4ed 100644
--- a/src/bin/pg_upgrade/pg_upgrade.h
+++ b/src/bin/pg_upgrade/pg_upgrade.h
@@ -434,7 +434,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		prep_status(const char *fmt,...) pg_attribute_printf(1, 2);
 void		check_ok(void);
diff --git a/src/bin/pgbench/pgbench.h b/src/bin/pgbench/pgbench.h
index c4a1e298e06..3759528e44d 100644
--- a/src/bin/pgbench/pgbench.h
+++ b/src/bin/pgbench/pgbench.h
@@ -141,9 +141,9 @@ extern PgBenchExpr *expr_parse_result;
 
 extern int	expr_yyparse(yyscan_t yyscanner);
 extern int	expr_yylex(union YYSTYPE *lvalp, yyscan_t yyscanner);
-extern void expr_yyerror(yyscan_t yyscanner, const char *str) pg_attribute_noreturn();
-extern void expr_yyerror_more(yyscan_t yyscanner, const char *str,
-							  const char *more) pg_attribute_noreturn();
+extern pg_noreturn void expr_yyerror(yyscan_t yyscanner, const char *str);
+extern pg_noreturn void expr_yyerror_more(yyscan_t yyscanner, const char *str,
+										  const char *more);
 extern bool expr_lex_one_word(PsqlScanState state, PQExpBuffer word_buf,
 							  int *offset);
 extern yyscan_t expr_scanner_init(PsqlScanState state,
@@ -156,9 +156,9 @@ extern char *expr_scanner_get_substring(PsqlScanState state,
 										bool chomp);
 extern int	expr_scanner_get_lineno(PsqlScanState state, int offset);
 
-extern void syntax_error(const char *source, int lineno, const char *line,
-						 const char *cmd, const char *msg,
-						 const char *more, int col) pg_attribute_noreturn();
+extern pg_noreturn void syntax_error(const char *source, int lineno, const char *line,
+									 const char *cmd, const char *msg,
+									 const char *more, int col);
 
 extern bool strtoint64(const char *str, bool errorOK, int64 *pi);
 extern bool strtodouble(const char *str, bool errorOK, double *pd);
diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h
index 85705602cb3..151d0ab3557 100644
--- a/src/include/bootstrap/bootstrap.h
+++ b/src/include/bootstrap/bootstrap.h
@@ -32,7 +32,7 @@ extern Form_pg_attribute attrtypes[MAXATTR];
 extern int	numattr;

-extern void AuxiliaryProcessMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void AuxiliaryProcessMain(int argc, char *argv[]);
 
 extern void closerel(char *name);
 extern void boot_openrel(char *name);
@@ -57,6 +57,6 @@ extern void boot_get_type_io_data(Oid typid,
 extern int	boot_yyparse(void);
 
 extern int	boot_yylex(void);
-extern void boot_yyerror(const char *str) pg_attribute_noreturn();
+extern pg_noreturn void boot_yyerror(const char *str);
 
 #endif							/* BOOTSTRAP_H */
diff --git a/src/include/c.h b/src/include/c.h
index c95acd35f7f..d5000557c0e 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -135,7 +135,7 @@
 /* GCC, Sunpro and XLC support aligned, packed and noreturn */
 #if defined(__GNUC__) || defined(__SUNPRO_C) || defined(__IBMC__)
 #define pg_attribute_aligned(a) __attribute__((aligned(a)))
-#define pg_attribute_noreturn() __attribute__((noreturn))
+#define pg_noreturn __attribute__((noreturn))
 #define pg_attribute_packed() __attribute__((packed))
 #define HAVE_PG_ATTRIBUTE_NORETURN 1
 #else
@@ -144,7 +144,7 @@
  * affect code functionality; they *must* be implemented by the compiler
  * if they are to be used.
  */
-#define pg_attribute_noreturn()
+#define pg_noreturn
 #endif
 
 /*
@@ -813,9 +813,9 @@ typedef NameData *Name;
  * we should declare it as long as !FRONTEND.
  */
 #ifndef FRONTEND
-extern void ExceptionalCondition(const char *conditionName,
-								 const char *errorType,
-								 const char *fileName, int lineNumber) pg_attribute_noreturn();
+extern pg_noreturn void ExceptionalCondition(const char *conditionName,
+											 const char *errorType,
+											 const char *fileName, int lineNumber);
 #endif
 
 /*
diff --git a/src/include/mb/pg_wchar.h b/src/include/mb/pg_wchar.h
index 3e3e6c470e9..05169fc87de 100644
--- a/src/include/mb/pg_wchar.h
+++ b/src/include/mb/pg_wchar.h
@@ -608,9 +608,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();
+extern pg_noreturn void report_invalid_encoding(int encoding, const char *mbstr, int len);
+extern pg_noreturn void report_untranslatable_char(int src_encoding, int dest_encoding,
+												   const char *mbstr, int len);
 
 extern void local2local(const unsigned char *l, unsigned char *p, int len,
 						int src_encoding, int dest_encoding, const unsigned char *tab);
diff --git a/src/include/parser/parse_relation.h b/src/include/parser/parse_relation.h
index f7e078172de..4859cce8d1e 100644
--- a/src/include/parser/parse_relation.h
+++ b/src/include/parser/parse_relation.h
@@ -116,9 +116,9 @@ extern bool isLockedRefname(ParseState *pstate, const char *refname);
 extern void addRTEtoQuery(ParseState *pstate, RangeTblEntry *rte,
 						  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();
+extern pg_noreturn void errorMissingRTE(ParseState *pstate, RangeVar *relation);
+extern pg_noreturn void errorMissingColumn(ParseState *pstate,
+										   const char *relname, const char *colname, int location);
 extern void expandRTE(RangeTblEntry *rte, int rtindex, int sublevels_up,
 					  int location, bool include_dropped,
 					  List **colnames, List **colvars);
diff --git a/src/include/parser/scanner.h b/src/include/parser/scanner.h
index 731a2bd264a..c10d42bf35a 100644
--- a/src/include/parser/scanner.h
+++ b/src/include/parser/scanner.h
@@ -128,6 +128,6 @@ extern void scanner_finish(core_yyscan_t yyscanner);
 extern int	core_yylex(core_YYSTYPE *lvalp, YYLTYPE *llocp,
 					   core_yyscan_t yyscanner);
 extern int	scanner_errposition(int location, core_yyscan_t yyscanner);
-extern void scanner_yyerror(const char *message, core_yyscan_t yyscanner) pg_attribute_noreturn();
+extern pg_noreturn void scanner_yyerror(const char *message, core_yyscan_t yyscanner);
 
 #endif							/* SCANNER_H */
diff --git a/src/include/pgstat.h b/src/include/pgstat.h
index fe076d823db..58453faaaec 100644
--- a/src/include/pgstat.h
+++ b/src/include/pgstat.h
@@ -1240,7 +1240,7 @@ extern void pgstat_reset_all(void);
 extern void allow_immediate_pgstat_restart(void);
 
 #ifdef EXEC_BACKEND
-extern void PgstatCollectorMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void PgstatCollectorMain(int argc, char *argv[]);
 #endif

diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h
index 8451e5d9e27..663ac67d04c 100644
--- a/src/include/postmaster/autovacuum.h
+++ b/src/include/postmaster/autovacuum.h
@@ -65,8 +65,8 @@ extern void AutoVacWorkerFailed(void);
 extern void AutoVacuumUpdateDelay(void);
 
 #ifdef EXEC_BACKEND
-extern void AutoVacLauncherMain(int argc, char *argv[]) pg_attribute_noreturn();
-extern void AutoVacWorkerMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void AutoVacLauncherMain(int argc, char *argv[]);
+extern pg_noreturn void AutoVacWorkerMain(int argc, char *argv[]);
 extern void AutovacuumWorkerIAm(void);
 extern void AutovacuumLauncherIAm(void);
 #endif
diff --git a/src/include/postmaster/bgworker_internals.h b/src/include/postmaster/bgworker_internals.h
index 0809e0af538..db1358578cb 100644
--- a/src/include/postmaster/bgworker_internals.h
+++ b/src/include/postmaster/bgworker_internals.h
@@ -54,7 +54,7 @@ extern void BackgroundWorkerStopNotifications(pid_t pid);
 extern void ResetBackgroundWorkerCrashTimes(void);
 
 /* Function to start a background worker, called from postmaster.c */
-extern void StartBackgroundWorker(void) pg_attribute_noreturn();
+extern pg_noreturn void StartBackgroundWorker(void);
 
 #ifdef EXEC_BACKEND
 extern BackgroundWorker *BackgroundWorkerEntry(int slotno);
diff --git a/src/include/postmaster/bgwriter.h b/src/include/postmaster/bgwriter.h
index 630366f49ef..327bc4e784a 100644
--- a/src/include/postmaster/bgwriter.h
+++ b/src/include/postmaster/bgwriter.h
@@ -27,8 +27,8 @@ extern int	CheckPointTimeout;
 extern int	CheckPointWarning;
 extern double CheckPointCompletionTarget;
 
-extern void BackgroundWriterMain(void) pg_attribute_noreturn();
-extern void CheckpointerMain(void) pg_attribute_noreturn();
+extern pg_noreturn void BackgroundWriterMain(void);
+extern pg_noreturn void CheckpointerMain(void);
 
 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 2474eac26a5..d6f50650d5b 100644
--- a/src/include/postmaster/pgarch.h
+++ b/src/include/postmaster/pgarch.h
@@ -33,7 +33,7 @@
 extern int	pgarch_start(void);
 
 #ifdef EXEC_BACKEND
-extern void PgArchiverMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void PgArchiverMain(int argc, char *argv[]);
 #endif
 
 #endif							/* _PGARCH_H */
diff --git a/src/include/postmaster/postmaster.h b/src/include/postmaster/postmaster.h
index b692d8be110..7f7ef1c58cf 100644
--- a/src/include/postmaster/postmaster.h
+++ b/src/include/postmaster/postmaster.h
@@ -46,7 +46,7 @@ extern int	postmaster_alive_fds[2];
 
 extern PGDLLIMPORT const char *progname;
 
-extern void PostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void PostmasterMain(int argc, char *argv[]);
 extern void ClosePostmasterPorts(bool am_syslogger);
 extern void InitProcessGlobals(void);
 
@@ -56,7 +56,7 @@ extern bool PostmasterMarkPIDForWorkerNotify(int);
 
 #ifdef EXEC_BACKEND
 extern pid_t postmaster_forkexec(int argc, char *argv[]);
-extern void SubPostmasterMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void SubPostmasterMain(int argc, char *argv[]);
 
 extern Size ShmemBackendArraySize(void);
 extern void ShmemBackendArrayAllocation(void);
diff --git a/src/include/postmaster/startup.h b/src/include/postmaster/startup.h
index 7b3a089932e..771e1a1126b 100644
--- a/src/include/postmaster/startup.h
+++ b/src/include/postmaster/startup.h
@@ -13,7 +13,7 @@
 #define _STARTUP_H
 
 extern void HandleStartupProcInterrupts(void);
-extern void StartupProcessMain(void) pg_attribute_noreturn();
+extern pg_noreturn void StartupProcessMain(void);
 extern void PreRestoreCommand(void);
 extern void PostRestoreCommand(void);
 extern bool IsPromoteTriggered(void);
diff --git a/src/include/postmaster/syslogger.h b/src/include/postmaster/syslogger.h
index 3a611045736..17e0a22ec7b 100644
--- a/src/include/postmaster/syslogger.h
+++ b/src/include/postmaster/syslogger.h
@@ -84,7 +84,7 @@ extern int	SysLogger_Start(void);
 extern void write_syslogger_file(const char *buffer, int count, int dest);
 
 #ifdef EXEC_BACKEND
-extern void SysLoggerMain(int argc, char *argv[]) pg_attribute_noreturn();
+extern pg_noreturn void SysLoggerMain(int argc, char *argv[]);
 #endif
 
 extern bool CheckLogrotateSignal(void);
diff --git a/src/include/postmaster/walwriter.h b/src/include/postmaster/walwriter.h
index ae267d2411e..df73343ef9d 100644
--- a/src/include/postmaster/walwriter.h
+++ b/src/include/postmaster/walwriter.h
@@ -16,6 +16,6 @@
 extern int	WalWriterDelay;
 extern int	WalWriterFlushAfter;
 
-extern void WalWriterMain(void) pg_attribute_noreturn();
+extern pg_noreturn void WalWriterMain(void);
 
 #endif							/* _WALWRITER_H */
diff --git a/src/include/replication/walreceiver.h b/src/include/replication/walreceiver.h
index e12a9349660..47a0f5a22ed 100644
--- a/src/include/replication/walreceiver.h
+++ b/src/include/replication/walreceiver.h
@@ -300,7 +300,7 @@ walrcv_clear_result(WalRcvExecResult *walres)
 }
 
 /* prototypes for functions in walreceiver.c */
-extern void WalReceiverMain(void) pg_attribute_noreturn();
+extern pg_noreturn void WalReceiverMain(void);
 extern void ProcessWalRcvInterrupts(void);
 
 /* prototypes for functions in walreceiverfuncs.c */
diff --git a/src/include/replication/walsender_private.h b/src/include/replication/walsender_private.h
index 0dd6d1cf808..2eeee014933 100644
--- a/src/include/replication/walsender_private.h
+++ b/src/include/replication/walsender_private.h
@@ -120,7 +120,7 @@ extern void WalSndSetState(WalSndState state);
  */
 extern int	replication_yyparse(void);
 extern int	replication_yylex(void);
-extern void replication_yyerror(const char *str) pg_attribute_noreturn();
+extern pg_noreturn void replication_yyerror(const char *str);
 extern void replication_scanner_init(const char *query_string);
 extern void replication_scanner_finish(void);
 
diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h
index d113813df32..cd75c79825b 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();
+extern pg_noreturn 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 6efb7a96481..4bf0aa43f0e 100644
--- a/src/include/storage/lock.h
+++ b/src/include/storage/lock.h
@@ -575,7 +575,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();
+extern pg_noreturn void DeadLockReport(void);
 extern void RememberSimpleDeadLock(PGPROC *proc1,
 								   LOCKMODE lockmode,
 								   LOCK *lock,
diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h
index ec21f7e45c5..b04d02b198c 100644
--- a/src/include/tcop/tcopprot.h
+++ b/src/include/tcop/tcopprot.h
@@ -61,9 +61,9 @@ extern bool check_max_stack_depth(int *newval, void **extra, GucSource source);
 extern void assign_max_stack_depth(int newval, void *extra);
 
 extern void die(SIGNAL_ARGS);
-extern void quickdie(SIGNAL_ARGS) pg_attribute_noreturn();
+extern pg_noreturn void quickdie(SIGNAL_ARGS);
 extern void StatementCancelHandler(SIGNAL_ARGS);
-extern void FloatExceptionHandler(SIGNAL_ARGS) pg_attribute_noreturn();
+extern pg_noreturn void FloatExceptionHandler(SIGNAL_ARGS);
 extern void RecoveryConflictInterrupt(ProcSignalReason reason); /* called from SIGUSR1
 																 * handler */
 extern void ProcessClientReadInterrupt(bool blocked);
@@ -71,9 +71,9 @@ extern void ProcessClientWriteInterrupt(bool blocked);
 
 extern void process_postgres_switches(int argc, char *argv[],
 									  GucContext ctx, const char **dbname);
-extern void PostgresMain(int argc, char *argv[],
-						 const char *dbname,
-						 const char *username) pg_attribute_noreturn();
+extern pg_noreturn void PostgresMain(int argc, char *argv[],
+									 const char *dbname,
+									 const char *username);
 extern long get_stack_depth_rlimit(void);
 extern void ResetUsage(void);
 extern void ShowUsage(const char *title);
diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h
index 5ebf336071b..eba5f3c9a80 100644
--- a/src/include/utils/datetime.h
+++ b/src/include/utils/datetime.h
@@ -304,8 +304,8 @@ extern int	DecodeInterval(char **field, int *ftype, int nf, int range,
 extern int	DecodeISO8601Interval(char *str,
 								  int *dtype, struct pg_tm *tm, fsec_t *fsec);
 
-extern void DateTimeParseError(int dterr, const char *str,
-							   const char *datatype) pg_attribute_noreturn();
+extern pg_noreturn void DateTimeParseError(int dterr, const char *str,
+										   const char *datatype);
 
 extern int	DetermineTimeZoneOffset(struct pg_tm *tm, pg_tz *tzp);
 extern int	DetermineTimeZoneAbbrevOffset(struct pg_tm *tm, const char *abbr, pg_tz *tzp);
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 9ab4b5470b7..9c3569e2719 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -353,8 +353,8 @@ extern PGDLLIMPORT ErrorContextCallback *error_context_stack;
 	} while (0)
 
 /*
- * Some compilers understand pg_attribute_noreturn(); for other compilers,
- * insert pg_unreachable() so that the compiler gets the point.
+ * Some compilers understand pg_noreturn for other compilers, insert
+ * pg_unreachable() so that the compiler gets the point.
  */
 #ifdef HAVE_PG_ATTRIBUTE_NORETURN
 #define PG_RE_THROW()  \
@@ -414,9 +414,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();
+extern pg_noreturn void ReThrowError(ErrorData *edata);
 extern void ThrowErrorData(ErrorData *edata);
-extern void pg_re_throw(void) pg_attribute_noreturn();
+extern pg_noreturn void pg_re_throw(void);
 
 extern char *GetErrorContextStack(void);
 
diff --git a/src/include/utils/help_config.h b/src/include/utils/help_config.h
index f0eace59f50..7858973968f 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();
+extern pg_noreturn void GucInfoMain(void);
 
 #endif
diff --git a/src/interfaces/ecpg/preproc/preproc_extern.h b/src/interfaces/ecpg/preproc/preproc_extern.h
index 323fd5c3c1a..2d83e3fefb9 100644
--- a/src/interfaces/ecpg/preproc/preproc_extern.h
+++ b/src/interfaces/ecpg/preproc/preproc_extern.h
@@ -76,7 +76,7 @@ extern void base_yyerror(const char *);
 extern void *mm_alloc(size_t);
 extern char *mm_strdup(const char *);
 extern void mmerror(int errorcode, enum errortype type, const char *error,...) pg_attribute_printf(3, 4);
-extern void mmfatal(int errorcode, const char *error,...) pg_attribute_printf(2, 3) pg_attribute_noreturn();
+extern pg_noreturn void mmfatal(int errorcode, const char *error,...) pg_attribute_printf(2, 3);
 extern void output_get_descr_header(char *);
 extern void output_get_descr(char *, char *);
 extern void output_set_descr_header(char *);
diff --git a/src/pl/plpgsql/src/plpgsql.h b/src/pl/plpgsql/src/plpgsql.h
index f66b2baa70a..52e53c796e9 100644
--- a/src/pl/plpgsql/src/plpgsql.h
+++ b/src/pl/plpgsql/src/plpgsql.h
@@ -1318,7 +1318,7 @@ extern int	plpgsql_peek(void);
 extern void plpgsql_peek2(int *tok1_p, int *tok2_p, int *tok1_loc,
 						  int *tok2_loc);
 extern int	plpgsql_scanner_errposition(int location);
-extern void plpgsql_yyerror(const char *message) pg_attribute_noreturn();
+extern pg_noreturn void plpgsql_yyerror(const char *message);
 extern int	plpgsql_location_to_lineno(int location);
 extern int	plpgsql_latest_lineno(void);
 extern void plpgsql_scanner_init(const char *str);
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 4c0722297e9..3ff8b5f17d8 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 void test_shm_mq_main(Datum) pg_attribute_noreturn();
+extern pg_noreturn 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 bc9ef64a508..35583a70e72 100644
--- a/src/test/modules/worker_spi/worker_spi.c
+++ b/src/test/modules/worker_spi/worker_spi.c
@@ -46,7 +46,7 @@ PG_MODULE_MAGIC;
 PG_FUNCTION_INFO_V1(worker_spi_launch);
 
 void		_PG_init(void);
-void		worker_spi_main(Datum) pg_attribute_noreturn();
+pg_noreturn void worker_spi_main(Datum);
 
 /* flags set by signal handlers */
 static volatile sig_atomic_t got_sighup = false;
diff --git a/src/timezone/zic.c b/src/timezone/zic.c
index c27fb456d05..31f317d9cac 100644
--- a/src/timezone/zic.c
+++ b/src/timezone/zic.c
@@ -118,11 +118,11 @@ struct zone
 
 extern int	link(const char *fromname, const char *toname);
 
-static void memory_exhausted(const char *msg) pg_attribute_noreturn();
+static pg_noreturn 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();
+static pg_noreturn void usage(FILE *stream, int status);
 static void addtt(zic_t starttime, int type);
 static int	addtype(zic_t, char const *, bool, bool, bool);
 static void leapadd(zic_t, bool, int, int);
-- 
2.23.0.385.gbc12974a89

--k5olgh2lgulcruiy--