Skip to content

Commit 61d4ba3

Browse files
committed
Fix #629.
1 parent 041150a commit 61d4ba3

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
- `A7-1-7` - `IdentifierDeclarationAndInitializationNotOnSeparateLines.ql`
2+
- Fixes #629. Adds brackets, excluding expressions statements in macros.

cpp/autosar/src/rules/A7-1-7/IdentifierDeclarationAndInitializationNotOnSeparateLines.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import codingstandards.cpp.autosar
1919
class UniqueLineStmt extends Locatable {
2020
UniqueLineStmt() {
2121
not isAffectedByMacro() and
22-
exists(Declaration d |
22+
(exists(Declaration d |
2323
this = d.getADeclarationEntry() and
2424
not d instanceof Parameter and
2525
not d instanceof TemplateParameter and
@@ -38,7 +38,7 @@ class UniqueLineStmt extends Locatable {
3838
or
3939
this instanceof ExprStmt and
4040
not exists(ForStmt f | f.getInitialization().getAChild*() = this) and
41-
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this)
41+
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this))
4242
}
4343
}
4444

cpp/autosar/test/rules/A7-1-7/test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,4 +152,14 @@ void example_function() { f1(); } // COMPLIANT
152152

153153
// clang-format off
154154
typedef struct x { int y; } z; //COMPLIANT - for struct typedef and struct var //NON_COMPLIANT - for struct all on one line
155-
// clang-format on
155+
// clang-format on
156+
157+
#define foo(x, y) \
158+
x++; \
159+
y++;
160+
161+
void test_foo() {
162+
int a = 1;
163+
int b = 1;
164+
foo(a, b); // COMPLIANT
165+
}

0 commit comments

Comments
 (0)