Skip to content

Commit 66d7f2b

Browse files
Don't report '//*comment' in RULE-3-1
1 parent db1061e commit 66d7f2b

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

c/misra/src/rules/RULE-3-1/CharacterSequencesAndUsedWithinAComment.ql

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ where
4343
not isExcluded(comment, SyntaxPackage::characterSequencesAndUsedWithinACommentQuery()) and
4444
(
4545
exists(IllegalCommentSequence c | illegalSequence = c |
46-
comment.getContents().indexOf(illegalSequence) > 0
46+
comment.getContents().indexOf(illegalSequence) > 1
4747
)
4848
or
4949
exists(IllegalCCommentRegexp c | illegalSequence = c.getDescription() |

c/misra/test/rules/RULE-3-1/CharacterSequencesAndUsedWithinAComment.expected

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
| test.c:21:1:21:7 | // /* | Comment contains an illegal sequence '/*' |
44
| test.c:30:1:30:27 | /* https://github.com // */ | Comment contains an illegal sequence '//' |
55
| test.c:33:1:33:60 | /* a://b, a://b., ://a.b, a://b., a://.b, ://, a://, ://b */ | Comment contains an illegal sequence '//' |
6+
| test.c:42:1:42:8 | ///* foo | Comment contains an illegal sequence '/*' |

c/misra/test/rules/RULE-3-1/test.c

+6
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,10 @@
3535
// COMPLIANT
3636
// https://github.com
3737

38+
// COMPLIANT
39+
//* foo
40+
41+
// NON_COMPLIANT
42+
///* foo
43+
3844
void f(){}

change_notes/2024-12-13-implement-misra-c-amendment4-rule-amendments.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
- `RULE-13-2` - `UnsequencedAtomicReads.ql`
88
- New query to find expressions which read an atomic variable more than once between sequence points, to address new case from MISRA-C 2012 Amendment 4.
99
- `RULE-3-1` - `CharacterSequencesAndUsedWithinAComment.ql`
10-
- Add exception allowing URLs inside of cpp-style `/* ... */` comments, in compliance with MISRA-C 2012 Amendment 4
10+
- Add exception allowing URLs inside of cpp-style `/* ... */` comments, in compliance with MISRA-C 2012 Amendment 4.
11+
- No longer report cases of `//*some comment` in this rule.

0 commit comments

Comments
 (0)