8000 C99 Compound Literals not supported · Issue #380 · coccinelle/coccinelle · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

C99 Compound Literals not supported #380

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
archigup opened this issue Oct 9, 2024 · 1 comment
Open

C99 Compound Literals not supported #380

archigup opened this issue Oct 9, 2024 · 1 comment

Comments

@archigup
Copy link
archigup commented Oct 9, 2024

Hi, as far as I can tell, I can't match on a C99 compound literal (https://en.cppreference.com/w/c/language/compound_literal).

For example, I want to match this C code:

typedef struct { int * a; } A;

static A aaa = { .a = (int[500]) { 0 } };

I tried a cocci script to match all compound literals:

@@
@@
* ( ... ) { ... }

I would expect that to match all compound literals but I get the following error:

init_defs_builtins: /nix/store/7ii5nryp5xl1frrlqz0s7r1p3i888jva-coccinelle-1.2/lib/coccinelle/standard.h
minus: parse error: 
  File "test.cocci", line 3, column 10, charpos = 16
  around = '{',
  whole content = * ( ... ) { ... }
@elfring
Copy link
elfring commented Oct 19, 2024

Would you like to try another SmPL script variant out once more? 🤔

@display@
initialiser list il;
type t;
@@
*( t ) { il }

Test result:

Markus_Elfring@Sonne:…/Projekte/Coccinelle/Probe> spatch suggestion_for_Archit_Gupta-20241019.cocci example_Archit_Gupta-20241010.c
…
diff = 
--- example_Archit_Gupta-20241010.c
+++ /tmp/cocci-output-38036-9c76c6-example_Archit_Gupta-20241010.c
@@ -4,4 +4,3 @@
 
 
 typedef struct { int * a; } A;
-static A aaa = { .a = (int[500]) { 0 } };

@coccinelle coccinelle deleted a comment from elfring Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0