linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] symbol: preserve address space qualifiers with typeof()
@ 2025-10-18  9:35 Dan Carpenter
  2025-10-21  7:22 ` Chris Li
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2025-10-18  9:35 UTC (permalink / raw)
  To: Uros Bizjak; +Cc: Sparse Mailing-list

When we're parsing typeof(var) we then preserve the address space
qualifiers as well.  Otherwise it leads to warnings like this:

"warning: cast removes address space '__seg_gs' of expression"

Reported-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
 symbol.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/symbol.c b/symbol.c
index 6a39e5487c17..301a6ed225d2 100644
--- a/symbol.c
+++ b/symbol.c
@@ -552,6 +552,7 @@ static struct symbol *examine_pointer_type(struct symbol *sym)
 static struct symbol *examine_typeof_helper(struct symbol *sym, bool qual)
 {
 	struct symbol *base = evaluate_expression(sym->initializer);
+	struct ident *as = base->ctype.as;
 	unsigned long mod = 0;
 
 	if (!base)
@@ -567,6 +568,8 @@ static struct symbol *examine_typeof_helper(struct symbol *sym, bool qual)
 	sym->type = SYM_NODE;
 	sym->ctype.modifiers = mod;
 	sym->ctype.base_type = base;
+	if (qual)
+		sym->ctype.as = as;
 	return examine_node_type(sym);
 }
 
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] symbol: preserve address space qualifiers with typeof()
  2025-10-18  9:35 [PATCH] symbol: preserve address space qualifiers with typeof() Dan Carpenter
@ 2025-10-21  7:22 ` Chris Li
  0 siblings, 0 replies; 2+ messages in thread
From: Chris Li @ 2025-10-21  7:22 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Uros Bizjak, Sparse Mailing-list

On Sat, Oct 18, 2025 at 2:36 AM Dan Carpenter <dan.carpenter@linaro.org> wrote:
>
> When we're parsing typeof(var) we then preserve the address space
> qualifiers as well.  Otherwise it leads to warnings like this:
>
> "warning: cast removes address space '__seg_gs' of expression"
>
> Reported-by: Uros Bizjak <ubizjak@gmail.com>
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>

Thanks.

I just apply it on sparse-dev tips, it applies without conflicts.

However it seems "make check" has 67 tests failed now rather than 65
known failures.
There are two more test cases that failed with this patch:

KO: out of 902 tests, 835 passed, 67 failed
65 of them are known to fail
2 tests were disabled
make: *** [Makefile:285: check] Error 1

Maybe some test cases need to be updated as well? I haven't debugged
the details of the new failure yet.

While we are at it, can we add Uros' reporting case as a validator
check as well?

After fixing the new test failure, I can apply this patch to
sparse-dev. If the validation check patch shows up in the sparse
mailing list. I will move the validation check before this patch.

Chris

> ---
>  symbol.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/symbol.c b/symbol.c
> index 6a39e5487c17..301a6ed225d2 100644
> --- a/symbol.c
> +++ b/symbol.c
> @@ -552,6 +552,7 @@ static struct symbol *examine_pointer_type(struct symbol *sym)
>  static struct symbol *examine_typeof_helper(struct symbol *sym, bool qual)
>  {
>         struct symbol *base = evaluate_expression(sym->initializer);
> +       struct ident *as = base->ctype.as;
>         unsigned long mod = 0;
>
>         if (!base)
> @@ -567,6 +568,8 @@ static struct symbol *examine_typeof_helper(struct symbol *sym, bool qual)
>         sym->type = SYM_NODE;
>         sym->ctype.modifiers = mod;
>         sym->ctype.base_type = base;
> +       if (qual)
> +               sym->ctype.as = as;
>         return examine_node_type(sym);
>  }
>
> --
> 2.51.0
>
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-10-21  7:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-18  9:35 [PATCH] symbol: preserve address space qualifiers with typeof() Dan Carpenter
2025-10-21  7:22 ` Chris Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).