This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] typeof: Remove type qualifiers for atomic types
- From: "Joseph S. Myers" <joseph at codesourcery dot com>
- To: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 25 Jun 2014 21:20:48 +0000
- Subject: Re: [PATCH] typeof: Remove type qualifiers for atomic types
- Authentication-results: sourceware.org; auth=none
- References: <1403708691-26883-1-git-send-email-sebastian dot huber at embedded-brains dot de> <Pine dot LNX dot 4 dot 64 dot 1406251554300 dot 12113 at digraph dot polyomino dot org dot uk> <53AB10FA dot 6060008 at embedded-brains dot de>
On Wed, 25 Jun 2014, Sebastian Huber wrote:
> On 06/25/2014 05:56 PM, Joseph S. Myers wrote:
> > On Wed, 25 Jun 2014, Sebastian Huber wrote:
> >
> > > 2014-06-25 Sebastian Huber <sebastian.huber@embedded-brains.de>
> > >
> > > * c-parser.c (c_parser_declaration_or_fndef): Discard all type
> > > qualifiers in __auto_type for atomic types.
> > > (c_parser_typeof_specifier): Discard all type qualifiers in
> > > __typeof__ for atomic types.
> > This patch should include a testcase that typeof is discarding volatile
> > (you can e.g. declare an extern variable twice, once as int and once as
> > typeof (*p) where p is volatile _Atomic int *, so the type compatibility
> > check fails unless volatile is discarded).
> >
>
> Would be something like this all right for the check?
>
> #define CHECK_CORRESPONDING(TYPE1, TYPE2) \
> do { TYPE1 a; TYPE2 *b = &a; TYPE2 c; TYPE1 *d = &c; } while (0)
>
> void f(void)
> {
> const int *ci;
> volatile int *vi;
> CHECK_CORRESPONDING(int *, __typeof__(ci));
> CHECK_CORRESPONDING(int *, __typeof__(vi));
> }
Yes.
> I think its not possible to write a test for the restrict, since it cannot be
> part of a type?
You should be able to use types such as int *_Atomic restrict * (and then
test that typeof (*p) is int *, if p has that type).
--
Joseph S. Myers
joseph@codesourcery.com