semicolon.cocci (1095B)
1// SPDX-License-Identifier: GPL-2.0-only 2/// 3/// Remove unneeded semicolon. 4/// 5// Confidence: Moderate 6// Copyright: (C) 2012 Peter Senna Tschudin, INRIA/LIP6. 7// URL: http://coccinelle.lip6.fr/ 8// Comments: Some false positives on empty default cases in switch statements. 9// Options: --no-includes --include-headers 10 11virtual patch 12virtual report 13virtual context 14virtual org 15 16@r_default@ 17position p; 18@@ 19switch (...) 20{ 21default: ...;@p 22} 23 24@r_case@ 25position p; 26@@ 27( 28switch (...) 29{ 30case ...:;@p 31} 32| 33switch (...) 34{ 35case ...:... 36case ...:;@p 37} 38| 39switch (...) 40{ 41case ...:... 42case ...: 43case ...:;@p 44} 45) 46 47@r1@ 48statement S; 49position p1; 50position p != {r_default.p, r_case.p}; 51identifier label; 52@@ 53( 54label:; 55| 56S@p1;@p 57) 58 59@script:python@ 60p << r1.p; 61p1 << r1.p1; 62@@ 63if p[0].line != p1[0].line_end: 64 cocci.include_match(False) 65 66@depends on patch@ 67position r1.p; 68@@ 69-;@p 70 71@script:python depends on report@ 72p << r1.p; 73@@ 74coccilib.report.print_report(p[0],"Unneeded semicolon") 75 76@depends on context@ 77position r1.p; 78@@ 79*;@p 80 81@script:python depends on org@ 82p << r1.p; 83@@ 84cocci.print_main("Unneeded semicolon",p)