cocci.inria.fr archive mirror
 help / color / mirror / Atom feed
* [cocci]  Coccinelle does not parse macros ending in a comma
@ 2022-06-25 18:00 Lucian Popescu
  2022-06-25 18:32 ` Julia Lawall
  0 siblings, 1 reply; 2+ messages in thread
From: Lucian Popescu @ 2022-06-25 18:00 UTC (permalink / raw)
  To: cocci

[-- Attachment #1: Type: text/plain, Size: 951 bytes --]

Hi,

I ran spatch --parse-c on the following code:

#define something 0,

int main() {
    return 0;
}

This code compiles fine according to the C standard, however the output of
spatch is:

init_defs_builtins: /usr/local/lib/coccinelle/standard.h

PARSING: test.c
ERROR-RECOV: found sync end of #define, line 1
parsing pass2: try again
ERROR-RECOV: found sync end of #define, line 1
parse error
 = File "test.c", line 1, column 20, charpos = 20
  around = '',
  whole content = #define something 0,
badcount: 0
BAD:!!!!! #define something 0,
-----------------------------------------------------------------------
maybe 10 most problematic tokens
-----------------------------------------------------------------------
something: present in 1 parsing errors
example:

       #define something 0,

-----------------------------------------------------------------------

Is this a known limitation? If not, is there a way to solve this issue?

Lucian

[-- Attachment #2: Type: text/html, Size: 1244 bytes --]

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

* Re: [cocci] Coccinelle does not parse macros ending in a comma
  2022-06-25 18:00 [cocci] Coccinelle does not parse macros ending in a comma Lucian Popescu
@ 2022-06-25 18:32 ` Julia Lawall
  0 siblings, 0 replies; 2+ messages in thread
From: Julia Lawall @ 2022-06-25 18:32 UTC (permalink / raw)
  To: Lucian Popescu; +Cc: cocci

[-- Attachment #1: Type: text/plain, Size: 1315 bytes --]



On Sat, 25 Jun 2022, Lucian Popescu wrote:

> Hi,
> I ran spatch --parse-c on the following code:
>
> #define something 0,
>
> int main() {
>     return 0;
> }
>
> This code compiles fine according to the C standard, however the output of
> spatch is:
>
> init_defs_builtins: /usr/local/lib/coccinelle/standard.h
>
> PARSING: test.c
> ERROR-RECOV: found sync end of #define, line 1
> parsing pass2: try again
> ERROR-RECOV: found sync end of #define, line 1
> parse error
>  = File "test.c", line 1, column 20, charpos = 20
>   around = '',
>   whole content = #define something 0,
> badcount: 0
> BAD:!!!!! #define something 0,
> -----------------------------------------------------------------------
> maybe 10 most problematic tokens
> -----------------------------------------------------------------------
> something: present in 1 parsing errors
> example:
>        
>        #define something 0,
>        
> -----------------------------------------------------------------------
>
> Is this a known limitation? If not, is there a way to solve this issue?

This is the expected behavior.  Is there something that ou want to do
withe macro definition?  The inability to parse that shouldn't impact the
ability to treat other code, at least not other code that doesn't use the
macro.

julia

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

end of thread, other threads:[~2022-06-25 18:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-25 18:00 [cocci] Coccinelle does not parse macros ending in a comma Lucian Popescu
2022-06-25 18:32 ` Julia Lawall

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).