From: mstefani@redhat.com (Michael Stefaniuc)
To: cocci@systeme.lip6.fr
Subject: [Cocci] spatch issue with C struct initialization
Date: Sat, 05 Apr 2014 17:01:33 +0200 [thread overview]
Message-ID: <53401ACD.8010004@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.10.1404041317240.2088@hadrien>
On 04/04/2014 01:21 PM, Julia Lawall wrote:
>> bad: static const VMStateDescription vmstate_stellaris_gptm = {
>> bad: .name = "stellaris_gptm",
>> bad: .version_id = 1,
>> bad: .minimum_version_id = 1,
>> bad: .minimum_version_id_old = 1,
>> BAD:!!!!! .fields = (VMStateField[]) {
>> bad: VMSTATE_UINT32(config, gptm_state),
>> bad: VMSTATE_UINT32_ARRAY(mode, gptm_state, 2),
>> bad: VMSTATE_UINT32(control, gptm_state),
>> bad: VMSTATE_UINT32(state, gptm_state),
>> bad: VMSTATE_UINT32(mask, gptm_state),
>> bad: VMSTATE_UNUSED(8),
>> bad: VMSTATE_UINT32_ARRAY(load, gptm_state, 2),
>> bad: VMSTATE_UINT32_ARRAY(match, gptm_state, 2),
>> bad: VMSTATE_UINT32_ARRAY(prescale, gptm_state, 2),
>> bad: VMSTATE_UINT32_ARRAY(match_prescale, gptm_state, 2),
>> bad: VMSTATE_UINT32(rtc, gptm_state),
>> bad: VMSTATE_INT64_ARRAY(tick, gptm_state, 2),
>> bad: VMSTATE_TIMER_ARRAY(timer, gptm_state, 2),
>> bad: VMSTATE_END_OF_LIST()
>> bad: }
>> bad: };
>>
>> Judging by the capital "BAD", the ".fields" field is making
>> the problem. Any way around it?
>
> Unfortunately, I'm not sure how to do this without introducing conflicts
> in the grammar. Currently the grammar is roughly of the following form
> (copied from http://www.lysator.liu.se/c/ANSI-C-grammar-y.html):
>
> initializer
> : assignment_expression
> | '{' initializer_list '}'
> | '{' initializer_list ',' '}'
> ;
>
> A cast on an ordinary expression is a bit deep in assignment_expression.
> So the parser is not happy to have the possibility of a cast on { ... } as
> well.
>
> The cast seems to be allowed in C99, but I don't know what the grammar
> looks like to allow that.
That's actually not a cast but a compound literal
http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html
bye
micheal
next prev parent reply other threads:[~2014-04-05 15:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 8:30 [Cocci] spatch issue with C struct initialization Marcel Apfelbaum
2014-04-03 10:16 ` Julia Lawall
2014-04-03 13:31 ` Marcel Apfelbaum
2014-04-03 14:19 ` Julia Lawall
2014-04-03 14:29 ` Marcel Apfelbaum
2014-04-03 14:33 ` Julia Lawall
2014-04-03 14:38 ` Marcel Apfelbaum
2014-04-04 11:21 ` Julia Lawall
2014-04-05 15:01 ` Michael Stefaniuc [this message]
2014-04-05 15:17 ` Julia Lawall
2014-04-06 6:21 ` [Cocci] Handling of compound literals? SF Markus Elfring
2014-04-06 7:45 ` [Cocci] spatch issue with C struct initialization Marcel Apfelbaum
2014-04-06 10:57 ` Julia Lawall
2014-04-20 20:29 ` Julia Lawall
2014-04-22 8:21 ` Marcel Apfelbaum
2014-04-03 14:22 ` Julia Lawall
-- strict thread matches above, loose matches on Subject: below --
2014-04-07 10:37 Nic Volanschi (R&D)
2014-04-07 12:54 ` Julia Lawall
2014-04-07 13:27 ` Nic Volanschi (R&D)
2014-04-07 13:48 ` Julia Lawall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=53401ACD.8010004@redhat.com \
--to=mstefani@redhat.com \
--cc=cocci@systeme.lip6.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox