Skip to content

Commit

Permalink
Fix github#629.
Browse files Browse the repository at this point in the history
  • Loading branch information
fjatWbyT committed Oct 30, 2024
1 parent 041150a commit 61d4ba3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 2 additions & 0 deletions change_notes/2024-10-30-fix-issue-629.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- `A7-1-7` - `IdentifierDeclarationAndInitializationNotOnSeparateLines.ql`
- Fixes #629. Adds brackets, excluding expressions statements in macros.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import codingstandards.cpp.autosar
class UniqueLineStmt extends Locatable {
UniqueLineStmt() {
not isAffectedByMacro() and
exists(Declaration d |
(exists(Declaration d |
this = d.getADeclarationEntry() and
not d instanceof Parameter and
not d instanceof TemplateParameter and
Expand All @@ -38,7 +38,7 @@ class UniqueLineStmt extends Locatable {
or
this instanceof ExprStmt and
not exists(ForStmt f | f.getInitialization().getAChild*() = this) and
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this)
not exists(LambdaExpression l | l.getLambdaFunction().getBlock().getAChild*() = this))
}
}

Expand Down
12 changes: 11 additions & 1 deletion cpp/autosar/test/rules/A7-1-7/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,14 @@ void example_function() { f1(); } // COMPLIANT

// clang-format off
typedef struct x { int y; } z; //COMPLIANT - for struct typedef and struct var //NON_COMPLIANT - for struct all on one line
// clang-format on
// clang-format on

#define foo(x, y) \
x++; \
y++;

void test_foo() {
int a = 1;
int b = 1;
foo(a, b); // COMPLIANT
}

0 comments on commit 61d4ba3

Please sign in to comment.