From f0c3d35627b381087053a4e42cdb52f333bcec4d Mon Sep 17 00:00:00 2001
From: Thomas Munro <thomas.munro@enterprisedb.com>
Date: Thu, 4 Jan 2018 22:16:28 +1300
Subject: [PATCH] Fix warnings about pg_attribute_always_inline.

MSVC warned about the use of both __forceinline and inline.  We can't just
remove inline or GCC 7 will complain, so move it into the macro.  GCC 2.95
warned that it didn't understand always_inline, so choose GCC 4.x as a pretty
old cut-off point that is known to understand it.

Thomas Munro and Michail Nikolaev, per buildfarm and Tom Lane.
Discussion: https://postgr.es/m/32278.1514863068@sss.pgh.pa.us
Discussion: https://postgr.es/m/CANtu0oiYp74brgntKOxgg1FK5%2Bt8uQ05guSiFU6FYz_5KUhr6Q%40mail.gmail.com
---
 src/backend/executor/nodeHashjoin.c | 3 +--
 src/include/c.h                     | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c
index 8f2b634b124..03d78042fa0 100644
--- a/src/backend/executor/nodeHashjoin.c
+++ b/src/backend/executor/nodeHashjoin.c
@@ -161,8 +161,7 @@ static void ExecParallelHashJoinPartitionOuter(HashJoinState *node);
  *			  the other one is "outer".
  * ----------------------------------------------------------------
  */
-pg_attribute_always_inline
-static inline TupleTableSlot *
+static pg_attribute_always_inline TupleTableSlot *
 ExecHashJoinImpl(PlanState *pstate, bool parallel)
 {
 	HashJoinState *node = castNode(HashJoinState, pstate);
diff --git a/src/include/c.h b/src/include/c.h
index 34a7fa67b45..0dbde17bff2 100644
--- a/src/include/c.h
+++ b/src/include/c.h
@@ -147,13 +147,13 @@
 #endif
 
 /* GCC, Sunpro and XLC support always_inline via __attribute__ */
-#if defined(__GNUC__)
-#define pg_attribute_always_inline __attribute__((always_inline))
+#if (defined(__GNUC__) && __GNUC__ > 3) || defined(__SUNPRO_C) || defined(__IBMC__)
+#define pg_attribute_always_inline __attribute__((always_inline)) inline
 /* msvc via a special keyword */
 #elif defined(_MSC_VER)
 #define pg_attribute_always_inline __forceinline
 #else
-#define pg_attribute_always_inline
+#define pg_attribute_always_inline inline
 #endif
 
 /*
-- 
2.15.1

