From e5c8e01b6f27528ea3d51bc4ef278b67c8b84f54 Mon Sep 17 00:00:00 2001 From: Henson Choi Date: Thu, 3 Sep 2026 09:38:32 +0900 Subject: [PATCH] Place pg_nodiscard ahead of the storage class in the RPR optimizer Seven forward declarations in the RPR pattern optimizer wrote the attribute as "static pg_nodiscard List *". c.h defines pg_nodiscard as [[nodiscard]] once __STDC_VERSION__ reaches C23, and a standard attribute may only lead a declaration, so a compiler defaulting to that revision rejects the line: ../src/backend/optimizer/plan/rpr.c:56:21: error: expected identifier or '(' before 'List' 56 | static pg_nodiscard List *flattenSeqChildren(List *children); The GCC branch of the macro, __attribute__((warn_unused_result)), accepts the attribute after the storage class, which is why this went unnoticed: only a toolchain defaulting to -std=gnu23 takes the C23 branch. Move the attribute in front of static, where the rest of the tree puts it -- pg_list.h and base64.h both write "pg_nodiscard extern". These seven were the only "static pg_nodiscard" in the tree. The commitfest bot's Windows MinGW job reported this and is what has to confirm the fix: no Windows toolchain is at hand here. No functional change where the file compiled at all. --- src/backend/optimizer/plan/rpr.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/backend/optimizer/plan/rpr.c b/src/backend/optimizer/plan/rpr.c index 122aaa67a24..2fc27796af8 100644 --- a/src/backend/optimizer/plan/rpr.c +++ b/src/backend/optimizer/plan/rpr.c @@ -53,15 +53,15 @@ static bool rprBodyHasUniformLength(List *children); static bool rprChildrenMatchAt(List *children, int start, List *content); static List *rprGroupContent(RPRPatternNode *group); static bool rprTryAddIteration(RPRPatternNode *group); -static pg_nodiscard List *flattenSeqChildren(List *children); -static pg_nodiscard List *mergeConsecutiveVars(List *children); -static pg_nodiscard List *mergeConsecutiveGroups(List *children); -static pg_nodiscard List *mergeConsecutiveAlts(List *children); -static pg_nodiscard List *mergeGroupPrefixSuffix(List *children); +pg_nodiscard static List *flattenSeqChildren(List *children); +pg_nodiscard static List *mergeConsecutiveVars(List *children); +pg_nodiscard static List *mergeConsecutiveGroups(List *children); +pg_nodiscard static List *mergeConsecutiveAlts(List *children); +pg_nodiscard static List *mergeGroupPrefixSuffix(List *children); static RPRPatternNode *optimizeSeqPattern(RPRPatternNode *pattern); -static pg_nodiscard List *flattenAltChildren(List *children); -static pg_nodiscard List *removeDuplicateAlternatives(List *children); +pg_nodiscard static List *flattenAltChildren(List *children); +pg_nodiscard static List *removeDuplicateAlternatives(List *children); static RPRPatternNode *optimizeAltPattern(RPRPatternNode *pattern); static RPRPatternNode *tryMultiplyQuantifiers(RPRPatternNode *pattern);