v2-0002-Use-pg_exprtype-instead-of-__typeof__-or-__typeof.patch
text/x-patch
Filename: v2-0002-Use-pg_exprtype-instead-of-__typeof__-or-__typeof.patch
Type: text/x-patch
Part: 1
Message:
Re: Make copyObject work in C++
From 62f920e519004d692b14659c5d00546baa6be87c Mon Sep 17 00:00:00 2001 From: Jelte Fennema-Nio <postgres@jeltef.nl> Date: Mon, 8 Dec 2025 08:13:51 +0100 Subject: [PATCH v2 2/2] Use pg_exprtype instead of __typeof__ or __typeof The previous commit introduced pg_exprtype. This starts using that in a few more places. --- src/include/c.h | 8 ++++---- src/include/utils/relptr.h | 16 ++++------------ 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 46a97f11ae7..230ea2d10af 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -987,10 +987,10 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName, */ #ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P #define AssertVariableIsOfType(varname, typename) \ - StaticAssertStmt(__builtin_types_compatible_p(__typeof__(varname), typename), \ + StaticAssertStmt(__builtin_types_compatible_p(pg_exprtype(varname), typename), \ CppAsString(varname) " does not have type " CppAsString(typename)) #define AssertVariableIsOfTypeMacro(varname, typename) \ - (StaticAssertExpr(__builtin_types_compatible_p(__typeof__(varname), typename), \ + (StaticAssertExpr(__builtin_types_compatible_p(pg_exprtype(varname), typename), \ CppAsString(varname) " does not have type " CppAsString(typename))) #else /* !HAVE__BUILTIN_TYPES_COMPATIBLE_P */ #define AssertVariableIsOfType(varname, typename) \ @@ -1238,11 +1238,11 @@ typedef struct PGAlignedXLogBlock #define unvolatize(underlying_type, expr) const_cast<underlying_type>(expr) #elif defined(HAVE__BUILTIN_TYPES_COMPATIBLE_P) #define unconstify(underlying_type, expr) \ - (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), const underlying_type), \ + (StaticAssertExpr(__builtin_types_compatible_p(pg_exprtype(expr), const underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #define unvolatize(underlying_type, expr) \ - (StaticAssertExpr(__builtin_types_compatible_p(__typeof(expr), volatile underlying_type), \ + (StaticAssertExpr(__builtin_types_compatible_p(pg_exprtype(expr), volatile underlying_type), \ "wrong cast"), \ (underlying_type) (expr)) #else diff --git a/src/include/utils/relptr.h b/src/include/utils/relptr.h index ea340fee657..dac61b13118 100644 --- a/src/include/utils/relptr.h +++ b/src/include/utils/relptr.h @@ -38,16 +38,12 @@ #define relptr_declare(type, relptrtype) \ typedef relptr(type) relptrtype -#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#ifdef pg_exprtype #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ - (__typeof__((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ + (pg_exprtype((rp).relptr_type)) ((rp).relptr_off == 0 ? NULL : \ (base) + (rp).relptr_off - 1)) #else -/* - * If we don't have __builtin_types_compatible_p, assume we might not have - * __typeof__ either. - */ #define relptr_access(base, rp) \ (AssertVariableIsOfTypeMacro(base, char *), \ (void *) ((rp).relptr_off == 0 ? NULL : (base) + (rp).relptr_off - 1)) @@ -72,16 +68,12 @@ relptr_store_eval(char *base, char *val) } } -#ifdef HAVE__BUILTIN_TYPES_COMPATIBLE_P +#ifdef pg_exprtype #define relptr_store(base, rp, val) \ (AssertVariableIsOfTypeMacro(base, char *), \ - AssertVariableIsOfTypeMacro(val, __typeof__((rp).relptr_type)), \ + AssertVariableIsOfTypeMacro(val, pg_exprtype((rp).relptr_type)), \ (rp).relptr_off = relptr_store_eval((base), (char *) (val))) #else -/* - * If we don't have __builtin_types_compatible_p, assume we might not have - * __typeof__ either. - */ #define relptr_store(base, rp, val) \ (AssertVariableIsOfTypeMacro(base, char *), \ (rp).relptr_off = relptr_store_eval((base), (char *) (val))) -- 2.52.0