Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion addons/misra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,8 +1169,14 @@ def numberOfParentheses(tok1, tok2):
def findGotoLabel(gotoToken):
label = gotoToken.next.str
tok = gotoToken.next.next
functionScope = gotoToken.scope
while functionScope and functionScope.type != 'Function':
functionScope = functionScope.nestedIn
functionEnd = functionScope.bodyEnd if functionScope else None
while tok:
if tok.str == '}' and tok.scope.type == 'Function':
if tok is functionEnd:
break
if functionEnd is None and tok.str == '}' and tok.scope and tok.scope.type == 'Function':
break
if tok.str == label and tok.next.str == ':':
return tok
Expand Down
17 changes: 17 additions & 0 deletions addons/test/misra/misra-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,23 @@ static void misra_15_3(int a) {
}
}

struct misra_15_2_s {
int a;
int b;
};

static void misra_15_2_initializer_list(void) {
int err = 0;
if (err == 0) {
err = 1;
goto done; // 15.1
}
struct misra_15_2_s s = { 1, 2 };
(void)s;
done:
return;
}

static void misra_15_4(void) {
misra_15_4_label:
return;
Expand Down
Loading