From 8f9d2a63bcdf30a445cb24c5453f34d8f54a4b29 Mon Sep 17 00:00:00 2001
From: Jelte Fennema-Nio <postgres@jeltef.nl>
Date: Sat, 17 Jan 2026 14:51:36 +0100
Subject: [PATCH v8 2/6] Test most StaticAssert macros in C++ extensions

Most of the StaticAssert macros already worked 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++.

The only macros that StaticAssert macros that don't work yet are the
StaticAssertVariableIsOfType and StaticAssertVariableIsOfTypeMacro.
These will be added in a follow on commit.
---
 src/test/modules/test_cplusplusext/test_cplusplusext.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/test/modules/test_cplusplusext/test_cplusplusext.cpp b/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
index f1a2ab7f2bf..8c2eabcca43 100644
--- a/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
+++ b/src/test/modules/test_cplusplusext/test_cplusplusext.cpp
@@ -25,6 +25,8 @@ PG_MODULE_MAGIC;
 PG_FUNCTION_INFO_V1(test_cplusplus_add);
 }
 
+StaticAssertDecl(sizeof(int32) == 4, "int32 should be 4 bytes");
+
 /*
  * Simple function that returns the sum of two integers.  This verifies that
  * C++ extension modules can be loaded and called correctly at runtime.
@@ -47,6 +49,9 @@ test_cplusplus_add(PG_FUNCTION_ARGS)
 		(void) rtr;
 	}
 
+	StaticAssertStmt(sizeof(int32) == 4, "int32 should be 4 bytes");
+	(void) StaticAssertExpr(sizeof(int64) == 8, "int64 should be 8 bytes");
+
 	list_free(list);
 	pfree(node);
 
-- 
2.52.0

