From 6f8acfd2c5ae1c296c8cc314ceb144beb6b353a7 Mon Sep 17 00:00:00 2001
From: Andres Freund <andres@anarazel.de>
Date: Wed, 22 Aug 2018 16:04:47 -0700
Subject: [PATCH v2 3/4] Remove test for VA_ARGS, implied by C99.

This simplifies logic / reduces duplication in a few headers.

Author: Andres Freund
Discussion: https://postgr.es/m/97d4b165-192d-3605-749c-f614a0c4e783@2ndquadrant.com
---
 config/c-compiler.m4          | 19 -------------------
 configure                     | 32 --------------------------------
 configure.in                  |  1 -
 src/include/pg_config.h.in    |  3 ---
 src/include/pg_config.h.win32 |  3 ---
 src/include/utils/elog.h      |  8 +-------
 src/pl/plpython/plpy_elog.h   |  4 ----
 7 files changed, 1 insertion(+), 69 deletions(-)

diff --git a/config/c-compiler.m4 b/config/c-compiler.m4
index 67675a31bb6..eedaf12d69c 100644
--- a/config/c-compiler.m4
+++ b/config/c-compiler.m4
@@ -415,25 +415,6 @@ fi])# PGAC_C_COMPUTED_GOTO
 
 
 
-# PGAC_C_VA_ARGS
-# --------------
-# Check if the C compiler understands C99-style variadic macros,
-# and define HAVE__VA_ARGS if so.
-AC_DEFUN([PGAC_C_VA_ARGS],
-[AC_CACHE_CHECK(for __VA_ARGS__, pgac_cv__va_args,
-[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdio.h>],
-[#define debug(...) fprintf(stderr, __VA_ARGS__)
-debug("%s", "blarg");
-])],
-[pgac_cv__va_args=yes],
-[pgac_cv__va_args=no])])
-if test x"$pgac_cv__va_args" = xyes ; then
-AC_DEFINE(HAVE__VA_ARGS, 1,
-          [Define to 1 if your compiler understands __VA_ARGS__ in macros.])
-fi])# PGAC_C_VA_ARGS
-
-
-
 # PGAC_PROG_VARCC_VARFLAGS_OPT
 # -----------------------
 # Given a compiler, variable name and a string, check if the compiler
diff --git a/configure b/configure
index dd439ddd2f6..b143c6d6ba4 100755
--- a/configure
+++ b/configure
@@ -13962,38 +13962,6 @@ if test x"$pgac_cv_computed_goto" = xyes ; then
 
 $as_echo "#define HAVE_COMPUTED_GOTO 1" >>confdefs.h
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __VA_ARGS__" >&5
-$as_echo_n "checking for __VA_ARGS__... " >&6; }
-if ${pgac_cv__va_args+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdio.h>
-int
-main ()
-{
-#define debug(...) fprintf(stderr, __VA_ARGS__)
-debug("%s", "blarg");
-
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  pgac_cv__va_args=yes
-else
-  pgac_cv__va_args=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $pgac_cv__va_args" >&5
-$as_echo "$pgac_cv__va_args" >&6; }
-if test x"$pgac_cv__va_args" = xyes ; then
-
-$as_echo "#define HAVE__VA_ARGS 1" >>confdefs.h
-
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
diff --git a/configure.in b/configure.in
index 5869ab7c5bc..3280afa0dab 100644
--- a/configure.in
+++ b/configure.in
@@ -1434,7 +1434,6 @@ PGAC_C_BUILTIN_BSWAP64
 PGAC_C_BUILTIN_CONSTANT_P
 PGAC_C_BUILTIN_UNREACHABLE
 PGAC_C_COMPUTED_GOTO
-PGAC_C_VA_ARGS
 PGAC_STRUCT_TIMEZONE
 PGAC_UNION_SEMUN
 PGAC_STRUCT_SOCKADDR_UN
diff --git a/src/include/pg_config.h.in b/src/include/pg_config.h.in
index 827574ee40d..37649d77d67 100644
--- a/src/include/pg_config.h.in
+++ b/src/include/pg_config.h.in
@@ -754,9 +754,6 @@
 /* Define to 1 if your compiler understands _Static_assert. */
 #undef HAVE__STATIC_ASSERT
 
-/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
-#undef HAVE__VA_ARGS
-
 /* Define to 1 if you have the `__strtoll' function. */
 #undef HAVE___STRTOLL
 
diff --git a/src/include/pg_config.h.win32 b/src/include/pg_config.h.win32
index 46ce49def2f..4e2bd3c1352 100644
--- a/src/include/pg_config.h.win32
+++ b/src/include/pg_config.h.win32
@@ -597,9 +597,6 @@
 /* Define to 1 if your compiler understands _Static_assert. */
 /* #undef HAVE__STATIC_ASSERT */
 
-/* Define to 1 if your compiler understands __VA_ARGS__ in macros. */
-#define HAVE__VA_ARGS 1
-
 /* Define to the appropriate printf length modifier for 64-bit ints. */
 #define INT64_MODIFIER "ll"
 
diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h
index 4350b120aab..33c6b53e278 100644
--- a/src/include/utils/elog.h
+++ b/src/include/utils/elog.h
@@ -207,9 +207,8 @@ extern int	getinternalerrposition(void);
  *		elog(ERROR, "portal \"%s\" not found", stmt->portalname);
  *----------
  */
-#ifdef HAVE__VA_ARGS
 /*
- * If we have variadic macros, we can give the compiler a hint about the
+ * Using variadic macros, we can give the compiler a hint about the
  * call not returning when elevel >= ERROR.  See comments for ereport().
  * Note that historically elog() has called elog_start (which saves errno)
  * before evaluating "elevel", so we preserve that behavior here.
@@ -236,11 +235,6 @@ extern int	getinternalerrposition(void);
 		} \
 	} while(0)
 #endif							/* HAVE__BUILTIN_CONSTANT_P */
-#else							/* !HAVE__VA_ARGS */
-#define elog  \
-	elog_start(__FILE__, __LINE__, PG_FUNCNAME_MACRO), \
-	elog_finish
-#endif							/* HAVE__VA_ARGS */
 
 extern void elog_start(const char *filename, int lineno, const char *funcname);
 extern void elog_finish(int elevel, const char *fmt,...) pg_attribute_printf(2, 3);
diff --git a/src/pl/plpython/plpy_elog.h b/src/pl/plpython/plpy_elog.h
index e4b30c3cca1..b56ac412476 100644
--- a/src/pl/plpython/plpy_elog.h
+++ b/src/pl/plpython/plpy_elog.h
@@ -15,7 +15,6 @@ extern PyObject *PLy_exc_spi_error;
  *
  * See comments at elog() about the compiler hinting.
  */
-#ifdef HAVE__VA_ARGS
 #ifdef HAVE__BUILTIN_CONSTANT_P
 #define PLy_elog(elevel, ...) \
 	do { \
@@ -32,9 +31,6 @@ extern PyObject *PLy_exc_spi_error;
 			pg_unreachable(); \
 	} while(0)
 #endif							/* HAVE__BUILTIN_CONSTANT_P */
-#else							/* !HAVE__VA_ARGS */
-#define PLy_elog PLy_elog_impl
-#endif							/* HAVE__VA_ARGS */
 
 extern void PLy_elog_impl(int elevel, const char *fmt,...) pg_attribute_printf(2, 3);
 
-- 
2.18.0.rc2.dirty

