v3-0002-Use-pg_exprtype-instead-of-typeof.patch
text/x-patch
Filename: v3-0002-Use-pg_exprtype-instead-of-typeof.patch
Type: text/x-patch
Part: 1
Message:
Re: Make copyObject work in C++
From 8a4b4749aa87dff7e4e40d2eeb21b84f97811738 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 v3 2/2] Use pg_exprtype instead of 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 | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 040f2ffc32b..f0800669f09 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -997,10 +997,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) \ @@ -1248,11 +1248,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 48e394dba71..dac61b13118 100644 --- a/src/include/utils/relptr.h +++ b/src/include/utils/relptr.h @@ -38,10 +38,10 @@ #define relptr_declare(type, relptrtype) \ typedef relptr(type) relptrtype -#ifdef HAVE_TYPEOF +#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 #define relptr_access(base, rp) \ @@ -68,10 +68,10 @@ relptr_store_eval(char *base, char *val) } } -#ifdef HAVE_TYPEOF +#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 #define relptr_store(base, rp, val) \ -- 2.52.0