On 02/03/2016 11:01 PM, Richard Henderson wrote:
While attempting to write some code that uses the new x86 named address
space support in gcc 6, I found that __typeof is very unhelpful. In
particular, given
int __seg_fs *ptr;
__typeof(*ptr) obj;
OBJ will not be type "int", but "int __seg_fs". Which means that you
can't use it to create temporaries within statement expressions.
ISTM __typeof is doing the obvious thing here -- what's wrong is the
__seg_fs is inherently "associated" with the pointer, right?
In the process of writing this, I found a hack in __typeof added just to
support _Atomic. Which suggests that one of these variants would be
more generally helpful than the hack.
Yea, seems that way.
I add __typeof_noas and __typeof_noqual. The first strips only the
address space, leaving 'const' and 'volatile' (and, I suppose
'restrict'). The second strips all qualifiers, essentially yielding the
TYPE_MAIN_VARIANT.
Something like this seems reasonable.
jeff