This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Variants of __typeof
- From: Marek Polacek <polacek at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 4 Feb 2016 11:09:15 +0100
- Subject: Re: [RFC] Variants of __typeof
- Authentication-results: sourceware.org; auth=none
- References: <56B2E940 dot 5060108 at redhat dot com>
On Thu, Feb 04, 2016 at 05:01:36PM +1100, 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.
>
> 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.
>
> 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.
>
> Thoughts?
We've already been asked to add something like __typeof_noqual, e.g.
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=39985#c3 . In a similar PR,
I wanted to modify __typeof to drop all qualifiers, but Joseph suggested
instead to add a new typeof variant:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65455#c19
(or adjust __typeof to only drop all qualifiers on rvalues?).
So this makes sense, though I don't see the need for __typeof_noas if we
can have __typeof_noqual.
Marek