Coccinelle patterns are designed to match source code that contains some construct. The following is a technique that can be used to match source code that does not contain some construct. For instance, to match all if-statements whose then arm contains a statement that is not a compound statement, i.e., not enclosed in curly brackets.
The idea is to create two patterns, one that matches just the construct that is not required and another that matches a generalised set of that construct and use position meta-variables to exclude the specific cases from the general cases.
@curly_if@
position p;
@@
if@p (...) { ... }
@simple_if@
position p != curly_if.p;
statement S;
@@
if@p (...) S
The all_if pattern will match all if-statements, but the requirement that p != curly_if.p excludes those cases where the statement has the form of a compound statement.