From 8a5bbbd0e73edafc340c938ec6e234384dbe672a Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <postgres@jeltef.nl>
Date: Fri, 13 Feb 2026 09:14:47 +0100
Subject: [PATCH v8 1/6] Test List macros in C++ extensions

All of these macros already work in C++ with Clang and GCC (the only
compilers we're currently testing C++ extension support for). This adds
a regression test for them in our test C++ extension, so we can safely
change their implementation without accidentally breaking C++. Some of
the List macros didn't work in C++ in the past (d5ca15ee5), this would
have caught that.
---
 .../test_cplusplusext/test_cplusplusext.cpp     | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/src/test/modules/test_cplusplusext/test_cplusplusext.cpp b/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
index 435937c00d2..f1a2ab7f2bf 100644
--- a/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
+++ b/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
@@ -17,6 +17,8 @@
 extern "C" {
 #include "postgres.h"
 #include "fmgr.h"
+#include "nodes/pg_list.h"
+#include "nodes/primnodes.h"
 
 PG_MODULE_MAGIC;
 
@@ -32,6 +34,21 @@ test_cplusplus_add(PG_FUNCTION_ARGS)
 {
 	int32		a = PG_GETARG_INT32(0);
 	int32		b = PG_GETARG_INT32(1);
+	RangeTblRef *node = makeNode(RangeTblRef);
+	List	   *list = list_make1(node);
+
+	foreach_ptr(RangeTblRef, rtr, list)
+	{
+		(void) rtr;
+	}
+
+	foreach_node(RangeTblRef, rtr, list)
+	{
+		(void) rtr;
+	}
+
+	list_free(list);
+	pfree(node);
 
 	PG_RETURN_INT32(a + b);
 }

base-commit: d7edcec35c7c28edb3bf283dfe9c892b042ca158
-- 
2.52.0

