All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] spatch issue with C struct initialization
@ 2014-04-03  8:30 Marcel Apfelbaum
  2014-04-03 10:16 ` Julia Lawall
  0 siblings, 1 reply; 20+ messages in thread
From: Marcel Apfelbaum @ 2014-04-03  8:30 UTC (permalink / raw)
  To: cocci

Hi,
I tried to use the coccinellery/doubleinit/doubleinit.cocci script
using the latest spatch version (1.0.0-rc20, I tried prev versions too).

I received the following error:
init_defs_builtins: /usr/local/share/coccinelle/standard.h
400 401
Fatal error: exception Failure("minus: parse error: 
 = File "coccinellery/doubleinit/doubleinit.cocci", line 17, column 22,  charpos = 400
    around = '.', whole content = struct I s =@p0 { ... .fld at p = E, ...};
")

Am I missing something, am I doing something wrong?

I need the following construct to work:
struct I s =
{
...
.fld = E,
...
};

Any help will be appreciated,
Thanks,
Marcel

^ permalink raw reply	[flat|nested] 20+ messages in thread
* [Cocci] spatch issue with C struct initialization
@ 2014-04-07 10:37 Nic Volanschi (R&D)
  2014-04-07 12:54 ` Julia Lawall
  0 siblings, 1 reply; 20+ messages in thread
From: Nic Volanschi (R&D) @ 2014-04-07 10:37 UTC (permalink / raw)
  To: cocci

On Mon, 2014-04-07 at 12:00 +0200, cocci-request at systeme.lip6.fr wrote:
> Not being an expert on grammar, there is a chance this will work ?
> >
> >  initializer
> >     : assignment_expression
> >        | '{' initializer_list '}'
> >        | '{' initializer_list ',' '}'
> >        | ( type-name ) { initializer-list }
> >        | ( type-name ) { initializer-list , }
> >
> > If you can point me to the code dealing with it, I can try to play
> with
> > it a little bit.
> 
> I think I already tried the same thing.  The problem is that
> ( type-name )
> is already buried deep within assignment_expression, for an ordinary
> cast,
> so the parser doesn't know which rule to choose.
> 
> julia

I agree that the "initializer" nonterminal is not the right place to
extend the grammar, because it would not allow legal statements such as:

  structure = ((struct foo) {x + y, 'a', 0});

the example coming from:
http://gcc.gnu.org/onlinedocs/gcc/Compound-Literals.html

Rather, it seems to me that the right place to extend the grammar is the
"cast_expression" nonterminal:

> cast_expression
> 	: unary_expression
> 	| '(' type_name ')' cast_expression
          | '(' type_name ')' '{' initializer_list '}'
> 	;

This would not only allow the above legal expression, but should also 
avoid to introduce a conflict in the grammar.

Hope this helps.

Nic.

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2014-04-22  8:21 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
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
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.