On 25/11/2026 17:29, Peter Eisentraut wrote:
>> See the sketch solution in the attached patch.
>
> Maybe for cases like this it would be easier to stick a pg_attribute_unused()
> on
> the variable declarations. Otherwise, it might get too annoying to maintain
> all
> these #ifdef groups consistently.
Ok. I never thought that Clang supports GCC 4 and this compiler directive. New
patch attached.
--
regards, Andrei Lepikhov,
pgEdge
From e27d2346952cdb4e4ebe82bdcfb5f130f7c1c751 Mon Sep 17 00:00:00 2001
From: Andrei Lepikhov <[email protected]>
Date: Thu, 26 Nov 2026 10:11:46 +0100
Subject: [PATCH v1] Silence -Wunused-but-set-global warnings with libedit
Commit 4e108ce790e removed the set-but-unused static globals reported by
clang 23's new -Wunused-but-set-global warning, but two more remain in psql.
They show up only when psql is built against a line-editing library that lacks
some optional functions, such as the libedit that ships with macOS.
Mark both variables pg_attribute_unused() to make compiler silent.
---
src/bin/psql/input.c | 2 +-
src/bin/psql/tab-complete.in.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/bin/psql/input.c b/src/bin/psql/input.c
index 76b479387b1..b649ee02a29 100644
--- a/src/bin/psql/input.c
+++ b/src/bin/psql/input.c
@@ -33,7 +33,7 @@ static bool useHistory;
static char *psql_history;
-static int history_lines_added;
+static int history_lines_added pg_attribute_unused();
/*
diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c
index 96de78cd087..ab633a58b2c 100644
--- a/src/bin/psql/tab-complete.in.c
+++ b/src/bin/psql/tab-complete.in.c
@@ -222,7 +222,7 @@ static int completion_max_records;
* macros) and then used by the completion callback functions. Ugly but there
* is no better way.
*/
-static char completion_last_char; /* last char of input word */
+static char completion_last_char pg_attribute_unused(); /* last char of
input word */
static const char *completion_charp; /* to pass a string */
static const char *const *completion_charpp; /* to pass a list of strings */
static const VersionedQuery *completion_vquery; /* to pass a VersionedQuery */
--
2.56.1