aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
authorDan Carpenter <dan.carpenter@linaro.org>2025-10-28 16:05:59 +0300
committerChris Li <chriscli@google.com>2025-12-01 19:17:56 +0400
commitc1f02d959ac047a980f121f0be077e5905560ec6 (patch)
tree7ec90e5e43cc0efcaa10c2f0a181e1d412ceccd5
parent27b34d720c4a06a90ed1982e91e1c049471f12e2 (diff)
downloadsparse-dev-c1f02d959ac047a980f121f0be077e5905560ec6.tar.gz
symbol: preserve address space qualifiers with typeof()HEADmaster
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> Signed-off-by: Chris Li <chriscli@google.com>
-rw-r--r--symbol.c7
-rw-r--r--validation/typeof-addresspace.c1
2 files changed, 6 insertions, 2 deletions
diff --git a/symbol.c b/symbol.c
index 7060acb6..a4228922 100644
--- a/symbol.c
+++ b/symbol.c
@@ -544,9 +544,12 @@ 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 = NULL;
unsigned long mod = 0;
- if (!base)
+ if (base)
+ as = base->ctype.as;
+ else
base = &bad_ctype;
if (base->type == SYM_NODE) {
mod |= base->ctype.modifiers & MOD_TYPEOF;
@@ -559,6 +562,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);
}
diff --git a/validation/typeof-addresspace.c b/validation/typeof-addresspace.c
index a94f77a3..34ac3089 100644
--- a/validation/typeof-addresspace.c
+++ b/validation/typeof-addresspace.c
@@ -16,5 +16,4 @@ static void test_as(void)
/*
* check-name: typeof-addresspace.c
- * check-known-to-fail
*/