On Tue, Nov 17, 2020 at 3:22 PM Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > Would doing the same unqualify_type() in degenerate() be sufficient? Actually, that's a stupid suggestion. Forget I ever mentioned it. I should have reacted to Martin Ucker pointing out > > lvalue conversion drops qualifers in C. In GCC, this is not > > implemented correctly as it is unobvervable in standard C > > (but it using typeof). with the notable point that it is unobservable outside of "typeof". I'm not actually entirely sure that is true: if you don't drop qualifiers, it's potentially observable in code generation, in that a "volatile" that didn't get dropped might perhaps cause unnecessary memory ops. But from a kernel variable type standpoint where we want to just drop qualifiers on variables using "typeof()", maybe the simplest solution would be just special-casing typeof itself, using something (entirely untested and probably complete garbage) like this: --- a/symbol.c +++ b/symbol.c @@ -509,6 +509,7 @@ static struct symbol *examine_pointer_type(struct symbol *sym) static struct symbol *examine_typeof(struct symbol *sym) { + int lvalue = lvalue_expression(sym->initializer); struct symbol *base = evaluate_expression(sym->initializer); unsigned long mod = 0; @@ -520,6 +521,8 @@ static struct symbol *examine_typeof(struct symbol *sym) } if (base->type == SYM_BITFIELD) warning(base->pos, "typeof applied to bitfield type"); + if (!lvalue) + mod &= MOD_QUALIFIER; sym->type = SYM_NODE; sym->ctype.modifiers = mod; sym->ctype.base_type = base; Hmm? Linus