patch 8.2.3274: macro for printf format check can be simplified

Problem:    Macro for printf format check can be simplified.
Solution:   Add ATTRIBUTE_FORMAT_PRINTF(). (Dominique Pellé, issue #8635)
diff --git a/src/channel.c b/src/channel.c
index 5307792..47c742d 100644
--- a/src/channel.c
+++ b/src/channel.c
@@ -229,11 +229,7 @@
 #endif
 
     static void
-ch_error(channel_T *ch, const char *fmt, ...)
-#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 2, 3)))
-#endif
-    ;
+ch_error(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
 
     static void
 ch_error(channel_T *ch, const char *fmt, ...)
diff --git a/src/gui_xim.c b/src/gui_xim.c
index 2dd6fd9..2a12412 100644
--- a/src/gui_xim.c
+++ b/src/gui_xim.c
@@ -31,7 +31,9 @@
  * in the "xim.log" file.
  */
 // #define XIM_DEBUG
-#ifdef XIM_DEBUG
+#if defined(XIM_DEBUG) && defined(FEAT_GUI_GTK)
+static void xim_log(char *s, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
+
     static void
 xim_log(char *s, ...)
 {
diff --git a/src/if_mzsch.c b/src/if_mzsch.c
index c8be940..57b593a 100644
--- a/src/if_mzsch.c
+++ b/src/if_mzsch.c
@@ -139,7 +139,7 @@
 # define OUTPUT_LEN_TYPE long
 #endif
 static void do_output(char *mesg, OUTPUT_LEN_TYPE len);
-static void do_printf(char *format, ...);
+static void do_printf(char *format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
 static void do_flush(void);
 static Scheme_Object *_apply_thunk_catch_exceptions(
 	Scheme_Object *, Scheme_Object **);
diff --git a/src/nbdebug.c b/src/nbdebug.c
index 43bee8d..c79081b 100644
--- a/src/nbdebug.c
+++ b/src/nbdebug.c
@@ -32,7 +32,7 @@
 FILE		*nb_debug = NULL;
 u_int		 nb_dlevel = 0;		// nb_debug verbosity level
 
-void		 nbdb(char *, ...);
+void		 nbdb(char *, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
 static int	 lookup(char *);
 #ifdef USE_NB_ERRORHANDLER
diff --git a/src/nbdebug.h b/src/nbdebug.h
index e1bb171..9a47c3a 100644
--- a/src/nbdebug.h
+++ b/src/nbdebug.h
@@ -42,11 +42,7 @@
 } WtWait;
 
 
-void		 nbdbg(char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-   __attribute__((format(printf, 1, 2)))
-# endif
-;
+void		 nbdbg(char *, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
 void nbdebug_wait(u_int wait_flags, char *wait_var, u_int wait_secs);
 void nbdebug_log_init(char *log_var, char *level_var);
diff --git a/src/netbeans.c b/src/netbeans.c
index 1a565df..bf47df7 100644
--- a/src/netbeans.c
+++ b/src/netbeans.c
@@ -54,7 +54,7 @@
 static int getConnInfo(char *file, char **host, char **port, char **password);
 
 static void nb_init_graphics(void);
-static void coloncmd(char *cmd, ...);
+static void coloncmd(char *cmd, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
 static void nb_set_curbuf(buf_T *buf);
 static void nb_parse_cmd(char_u *);
 static int  nb_do_cmd(int, char_u *, int, int, char_u *);
diff --git a/src/proto.h b/src/proto.h
index 29f8238..f639ad5 100644
--- a/src/proto.h
+++ b/src/proto.h
@@ -121,52 +121,26 @@
 # endif
 
 // These prototypes cannot be produced automatically.
-int smsg(const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 1, 2)))
-# endif
-    ;
+int smsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
-int smsg_attr(int, const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 2, 3)))
-# endif
-    ;
+int smsg_attr(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
 
-int smsg_attr_keep(int, const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 2, 3)))
-# endif
-    ;
+int smsg_attr_keep(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
 
 // These prototypes cannot be produced automatically.
-int semsg(const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 1, 2)))
-# endif
-    ;
+int semsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
 // These prototypes cannot be produced automatically.
-void siemsg(const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 1, 2)))
-# endif
-    ;
+void siemsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
 
-int vim_snprintf_add(char *, size_t, const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 3, 4)))
-# endif
-    ;
+int vim_snprintf_add(char *, size_t, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4);
 
-int vim_snprintf(char *, size_t, const char *, ...)
-# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 3, 4)))
-# endif
-    ;
+int vim_snprintf(char *, size_t, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4);
 
-int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
-int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, typval_T *tvs);
+int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap)
+	ATTRIBUTE_FORMAT_PRINTF(3, 0);
+int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, typval_T *tvs)
+	ATTRIBUTE_FORMAT_PRINTF(3, 0);
 
 # include "message.pro"
 # include "misc1.pro"
@@ -284,11 +258,7 @@
 #  include "channel.pro"
 
 // Not generated automatically, to add extra attribute.
-void ch_log(channel_T *ch, const char *fmt, ...)
-#  ifdef USE_PRINTF_FORMAT_ATTRIBUTE
-    __attribute__((format(printf, 2, 3)))
-#  endif
-    ;
+void ch_log(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
 
 # endif
 
diff --git a/src/term.c b/src/term.c
index a13959b..b61667d 100644
--- a/src/term.c
+++ b/src/term.c
@@ -100,7 +100,7 @@
     // Change this to "if 1" to debug what happens with termresponse.
 #  if 0
 #   define DEBUG_TERMRESPONSE
-static void log_tr(const char *fmt, ...);
+static void log_tr(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
 #   define LOG_TR(msg) log_tr msg
 #  else
 #   define LOG_TR(msg) do { /**/ } while (0)
diff --git a/src/version.c b/src/version.c
index b15034e..34e4ceb 100644
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3274,
+/**/
     3273,
 /**/
     3272,
diff --git a/src/vim.h b/src/vim.h
index 7d23986..b9105b5 100644
--- a/src/vim.h
+++ b/src/vim.h
@@ -2132,8 +2132,21 @@
 typedef struct stat stat_T;
 #endif
 
-#if defined(__GNUC__) && !defined(__MINGW32__)
-# define USE_PRINTF_FORMAT_ATTRIBUTE
+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__MINGW32__)
+# define ATTRIBUTE_FORMAT_PRINTF(fmt_idx, arg_idx) \
+    __attribute__((format(printf, fmt_idx, arg_idx)))
+#else
+# define ATTRIBUTE_FORMAT_PRINTF(fmt_idx, arg_idx)
+#endif
+
+#if defined(__GNUC__) || defined(__clang__)
+# define likely(x)      __builtin_expect((x), 1)
+# define unlikely(x)    __builtin_expect((x), 0)
+# define ATTRIBUTE_COLD __attribute__((cold))
+#else
+# define unlikely(x)  (x)
+# define likely(x)    (x)
+# define ATTRIBUTE_COLD
 #endif
 
 typedef enum {
diff --git a/src/vim9execute.c b/src/vim9execute.c
index f944fd7..11f190c 100644
--- a/src/vim9execute.c
+++ b/src/vim9execute.c
@@ -22,14 +22,6 @@
 
 #include "vim9.h"
 
-#if defined(__GNUC__) || defined(__clang__)
-# define likely(x)    __builtin_expect((x), 1)
-# define unlikely(x)  __builtin_expect((x), 0)
-#else
-# define unlikely(x)  (x)
-# define likely(x)    (x)
-#endif
-
 // Structure put on ec_trystack when ISN_TRY is encountered.
 typedef struct {
     int	    tcd_frame_idx;	// ec_frame_idx at ISN_TRY