Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x1dOS-005KbE-19 for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 05:20:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1x1dOR-00AR3T-10 for pgsql-hackers@arkaria.postgresql.org; Wed, 02 Sep 2026 05:20:15 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1x1dOR-00AR3L-02 for pgsql-hackers@lists.postgresql.org; Wed, 02 Sep 2026 05:20:15 +0000 Received: from mail-pg1-x532.google.com ([2607:f8b0:4864:20::532]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x1dOO-00000003aDo-49Su for pgsql-hackers@postgresql.org; Wed, 02 Sep 2026 05:20:14 +0000 Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-c9aea40d799so417502a12.0 for ; Tue, 01 Sep 2026 22:20:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1788326412; x=1788931212; darn=postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:from:to:cc :subject:date:message-id:reply-to:content-type; bh=oz2cvoj5R2ADLzd7DUCTKZyAqSE7067kqqUsGnF6ioA=; b=dqhjERx8dH+PQ8zJ6f32nKLMDjtnQBo2qt7HnNqzMdXUI4nMwJZxZMbL5sb2sxYE4E 1onn64/7bbqFi5dPjKp6aQ4Ks58o/WDuVVZD1EIX4DRKaAgAh4eXA+hR/7o3GRZTq/S6 vqBXdIaG806kGzi41VaiB0cWpWa/KirpOOjd/U6m2wdF0J3Rj8rR4iFldgJJgQ0XtiAb w0RkwnVszOKsrdYjGgYofBoPxb5jjr61iwnVgRSHwxeolVT3x1el382COpYSpqcxY1AE isWawC12TAHCtpSTyoN4A1Ql0eMGu3ktfr6A0CQQu2QRen15inZaioIgSDHnHv4sQnYr /tCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1788326412; x=1788931212; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:content-type:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=oz2cvoj5R2ADLzd7DUCTKZyAqSE7067kqqUsGnF6ioA=; b=hKxqNaVDkGSoDsHwJHAzn+WdzQrYHtheoDF9gmvr/2Am8/JTpVbXGsr0wUH8dOW4YK l2aaL4FJYZkoFSK8OsfFIs2y9dZlJ77POMzqb+pDZKAbJmCz3+fQEA/LxiQfvkWTW1fG zJCzYVDsFAlkL3wOrFwOYKVt0K0eNID+g97dvW+Qis22IyFO0zVuhoDlQwSlwbEKw2jM m+bEod+FzA5KrhFSgWip53FSGWNlCJ5tUz//xFPHeEH1ADjZZo9/CiRdu/nTWvF8rZY5 3GBB3Fpmt9PTzAWG5aCJE71rGh1QsvUZeID3g0fXPo5jUSyOSy1uMOakQVxUAW2hGqQa hI4w== X-Gm-Message-State: AFuF++nvPZa7aMNUCSrsdgkkoC+lGrjznxwje3QEzMVpmI8/yyt2yhF/ mxZuuRr1ZuyiuIy7hjuZhBX0gTzNK5Efw41cQp7yOsV7274iPNZvglUsisxZmA== X-Gm-Gg: AYBFou0skKtta6KcHLj3I7Qw+HQb6tquQvWxUf61phWq9cs4LbkzFoIcm3O1bq9Zw2S eMcI71V8+kxPG0ESJgKOkIkWNOBxSLN86ixpoqizTFXytonuH6Rs5kbl+T9N5GkE83mmbSTU9CG kEwtWAFPifNjn7EPsMa2T6XOmLDroh4fTrcqGSErbchuev6Uz1DbZNC1uUhErL5oJiUaT79TzUf qx6p8G44VxgwOeKa+aPfDYHqGTEaKw+uJqewXnl2Sb2tfE/CM/q37VfvBIuFNdu4UoBmSXHWquO kT4eiOYKJYmHBUhdGoW8w1KjTBv+Y3CRCWHIc8AhzZp+9xSENKDgiArSK4KNV6kCJn/iTwAFNu/ qdmFcPfVl19dDpNAHE2BItERKD7mGlS1JRrni6zSp5wzx+VHVdTkVdmY5dFxmP654h0/eNnqhuj WMkqU9XVHMFT/a+m0khTD679RebyeAj1xmf5gZ/ceyBtsss1Q7+VQsU0ekaCMdG3bjZ8vEC1ErH 4fp14p8 X-Received: by 2002:a17:90b:3902:b0:398:9bd1:3215 with SMTP id 98e67ed59e1d1-39aee13c238mr3131926a91.22.1788326411938; Tue, 01 Sep 2026 22:20:11 -0700 (PDT) Received: from smtpclient.apple ([185.135.79.125]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3990baaeec3sm9600168a91.0.2026.09.01.22.20.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2026 22:20:11 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.700.51.1.1\)) Subject: Re: Fix -Wshadow=local warnings From: Chao Li In-Reply-To: <84b6f128-91f5-480e-8a9e-7d0e8f538cea@eisentraut.org> Date: Wed, 2 Sep 2026 13:19:36 +0800 Cc: pgsql-hackers Content-Transfer-Encoding: quoted-printable Message-Id: <12D9618F-F1FF-41E4-8B9E-55E8DDADAFBD@gmail.com> References: <84b6f128-91f5-480e-8a9e-7d0e8f538cea@eisentraut.org> To: Peter Eisentraut X-Mailer: Apple Mail (2.3864.700.51.1.1) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Sep 1, 2026, at 22:58, Peter Eisentraut = wrote: >=20 > I bumped into some variable shadowings that to my slight surprise the = current warning option -Wshadow=3Dcompatible-local does not catch. For = example >=20 > const char *p; > char *p; >=20 > or >=20 > bool skipped; > int64 skipped; >=20 > These are not "compatible" in the technical C language sense, but they = are mutually assignable, so IMO just as confusing and fragile. >=20 > Also, there are things like >=20 > EState *estate; > ExprState *estate; >=20 > which are not mutually assignable, but almost as dangerous given the = propensity to cast node types around. >=20 > These can be caught if we dial up the warning one notch to = -Wshadow=3Dlocal. This then flags all shadowing of a local variable by = another local variable. I have fixed all the warnings in the attached = patch. I think everything this catches is obviously bad, so this seems = well worth fixing. (And if we buy into the idea of = -Wshadow=3Dcompatible-local, then this is obviously better and more = complete.) >=20 > So the first patch fixes all the warnings, but doesn't turn up the = compiler flag yet. There is a hiccup with the LLVM headers, because = they themselves trigger these warnings. So the second patch provides a = workaround to silence warnings from those headers. It's a bit different = from what we have done before, but I think it works better for this = case. Alternative ideas welcome. In the third patch, the warning = option is then changed. > = <0001-Fix-Wshadow-local-warnings.patch><0002-Use-isystem-for-LLVM-include-= directories.patch><0003-Use-warning-option-Wshadow-local.patch> I had a patch to fix all warnings from -Wshadow-all, and 0001 seems to = be a subset of that patch. My patch was not accepted due to a concern = about adding burden to future back-patching work. Anyway, +1 from my = side for fixing these warnings. A few small comments: 1 - 0001 - dependencies.c ``` * expression into *expr. */ static bool -dependency_is_compatible_expression(Node *clause, Index relid, List = *statlist, Node **expr) +dependency_is_compatible_expression(Node *clause, Index relid, List = *statlist, Node **stat_expr_p) ``` As =E2=80=9Cexpr=E2=80=9D is renamed, the function header comment needs = to be updated as well. 2 - 0001 - pg_constraint.c ``` + CookedConstraint *cooked_constr; ``` In the current RelationGetNotNullConstraints(), other local variables = use camelCase naming, for example constrRel, so maybe it would be better = to keep the naming style consistent. Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/