symbol: preserve address space qualifiers with typeof()
PATCH v2 1/1 symbol: preserve address space qualifiers with typeof()
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"
---
v2: Fix a NULL dereference because "base" can be NULL. Sorry for not running the validation/ tests... :(
symbol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
symbol.c +6 -1
@@ -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); }
Signature · 1 line
2.51.0
Hi Dan,
Thanks for the patch. Sorry for the late reply. Super busy recently. Now I am back and catching up on my back logs.
Quoted 8 lines · Dan Carpenter
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 <[email protected]>Signed-off-by Dan Carpenter <[email protected]>
Your patch makes one of the known to fail tests passed. I took the liberty to add the following change to make validation check happy:
validation/typeof-addresspace.c +0 -1
@@ -16,5 +16,4 @@ static void test_as(void)/* * check-name: typeof-addresspace.c -* check-known-to-fail */
Applied to sparse-dev.
Chris
Quoted 37 lines
---
v2: Fix a NULL dereference because "base" can be NULL. Sorry for not running the validation/ tests... :(symbol.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)symbol.c +6
-2@@ -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); } --2.51.0