All of lore.kernel.org
 help / color / mirror / Atom feed
From: tipecaml@gmail.com (Cyril Roelandt)
To: cocci@systeme.lip6.fr
Subject: [Cocci] [Coccinellery] drop_continue/cont.cocci broken ?
Date: Tue, 19 Feb 2013 21:44:12 +0100	[thread overview]
Message-ID: <5123E41C.30603@gmail.com> (raw)

Hi!

I think the drop_continue/cont.cocci script is broken. Here is a simple 
semantic patch extracted from it:


$ cat foo.cocci
@@
statement S;
@@
for (...;...;...) {
   ...
   if (...)
- {
     S
-   continue;
- }
}


A simple C file:

$ cat continue.c
static void
foo(int max)
{
	int i;
	for (i = 0; i < max; i++) {
		do_stuff();
		if (i == 42) {
			do_stg_else();
			continue;
		}
	}
}

$ spatch -sp_file foo.cocci continue.c --debug --verbose-parsing
init_defs_builtins: /home/cyril/opt/spatch/share/coccinelle/standard.h
-----------------------------------------------------------------------
processing semantic patch file: foo.cocci
with isos from: /home/cyril/opt/spatch/share/coccinelle/standard.iso
-----------------------------------------------------------------------
@@
statement S;
@@
for (...;...;...) {
   ...
   if (...)
- {
     S
-   continue;
- }
}

warning: iso braces1 does not match the code below on line 4
{
   ...
   if (...) {
     S
     continue;
   }
}
braces must be all minus (plus code allowed) or all
context (plus code not allowed in the body) to match:
{
   ...
   if (...) {
     S
     continue;
   }
}
HANDLING: continue.c
-----------------------------------------------------------------------
let's go
-----------------------------------------------------------------------
-----------------------------------------------------------------------
-----------------------------------------------------------------------
rule starting on line 1 =
-----------------------------------------------------------------------
dependencies for rule rule starting on line 1 satisfied:
binding in = []
binding relevant in = []
      transformation info returned:
           transform state: 18
                with rule_elem: -{

                with binding: []
           transform state: 20
                with rule_elem: -continue-;
                with binding: []
      binding out = []
      transform one node: 20
      transform one node: 18
PB: found closing brace alone in fuzzy parsing
ERROR-RECOV: end of file while in recovery mode
parsing pass2: try again
ERROR-RECOV: end of file while in recovery mode
parse error
  = File "/tmp/cocci_small_output-5101-1385aa.c", line 11, column 0, 
charpos = 118
     around = '}', whole content = }
badcount: 1
bad: 	}
BAD:!!!!! }
ALREADY AT END
-----------------------------------------------------------------------
Finished
-----------------------------------------------------------------------
PB: found closing brace alone in fuzzy parsing
ERROR-RECOV: end of file while in recovery mode
parsing pass2: try again
ERROR-RECOV: end of file while in recovery mode
parse error
  = File "/tmp/cocci-output-5101-f0bc97-continue.c", line 11, column 0, 
  charpos = 118
     around = '}', whole content = }
badcount: 1
bad: 	}
BAD:!!!!! }
ALREADY AT END
diff =
--- continue.c
+++ /tmp/cocci-output-5101-f0bc97-continue.c
@@ -4,9 +4,8 @@ foo(int max)
  	int i;
  	for (i = 0; i < max; i++) {
  		do_stuff();
-		if (i == 42) {
+		if (i == 42)
  			do_stg_else();
-			continue;
  		}
  	}
  }
Check duplication for 1 files




There is a missing closing brace in the resulting code. I can reproduce 
this with both 1.0-rc12 (packaged in Debian) and 1.0-rc16. The same 
thing happens when using "*" instead of "-", and when using the "break" 
keyword instead of the "continue" keyword.


WBR,
Cyril Roelandt.

             reply	other threads:[~2013-02-19 20:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-19 20:44 Cyril Roelandt [this message]
2013-02-19 21:54 ` [Cocci] [Coccinellery] drop_continue/cont.cocci broken ? Julia Lawall
2013-02-19 22:05 ` 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=5123E41C.30603@gmail.com \
    --to=tipecaml@gmail.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 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.