From 01b3fa89ef82af22f1274d90c0fed83cd4005388 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Tue, 18 Nov 2025 08:43:13 +0100 Subject: [PATCH 4/6] Remove StaticAssertStmt() It's no longer used. You can always use StaticAssertDecl() instead. --- src/include/c.h | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/include/c.h b/src/include/c.h index 41edd31b835..f074c50fc0c 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -919,8 +919,8 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName, * "declaration", and so it must be placed where for example a variable * declaration would be valid. As long as we compile with * -Wno-declaration-after-statement, that also means it cannot be placed after - * statements in a function. Macros StaticAssertStmt() and StaticAssertExpr() - * make it safe to use as a statement or in an expression, respectively. + * statements in a function. The macro StaticAssertExpr() makes it safe to + * use in an expression. * * For compilers without _Static_assert(), we fall back on a kluge that * assumes the compiler will complain about a negative width for a struct @@ -931,33 +931,25 @@ pg_noreturn extern void ExceptionalCondition(const char *conditionName, #ifdef HAVE__STATIC_ASSERT #define StaticAssertDecl(condition, errmessage) \ _Static_assert(condition, errmessage) -#define StaticAssertStmt(condition, errmessage) \ - do { _Static_assert(condition, errmessage); } while(0) #define StaticAssertExpr(condition, errmessage) \ - ((void) ({ StaticAssertStmt(condition, errmessage); true; })) + ((void) ({ StaticAssertDecl(condition, errmessage); true; })) #else /* !HAVE__STATIC_ASSERT */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) -#define StaticAssertStmt(condition, errmessage) \ - ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) #define StaticAssertExpr(condition, errmessage) \ - StaticAssertStmt(condition, errmessage) + ((void) sizeof(struct { int static_assert_failure : (condition) ? 1 : -1; })) #endif /* HAVE__STATIC_ASSERT */ #else /* C++ */ #if defined(__cpp_static_assert) && __cpp_static_assert >= 200410 #define StaticAssertDecl(condition, errmessage) \ static_assert(condition, errmessage) -#define StaticAssertStmt(condition, errmessage) \ - static_assert(condition, errmessage) #define StaticAssertExpr(condition, errmessage) \ ({ static_assert(condition, errmessage); }) #else /* !__cpp_static_assert */ #define StaticAssertDecl(condition, errmessage) \ extern void static_assert_func(int static_assert_failure[(condition) ? 1 : -1]) -#define StaticAssertStmt(condition, errmessage) \ - do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0) #define StaticAssertExpr(condition, errmessage) \ - ((void) ({ StaticAssertStmt(condition, errmessage); })) + ((void) ({ do { struct static_assert_struct { int static_assert_failure : (condition) ? 1 : -1; }; } while(0); })) #endif /* __cpp_static_assert */ #endif /* C++ */ -- 2.51.0