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 @@ -802,9 +802,15 @@ def get_function_pointer_type(tok):
return None
ret += '('
tok = tok.next.next
prev_is_name = False
while tok and (tok.str not in '()'):
if tok.varId is None:
if tok.isName:
if not prev_is_name:
ret += ' ' + tok.str
prev_is_name = True
else:
ret += ' ' + tok.str
prev_is_name = False
tok = tok.next
if (tok is None) or tok.str != ')':
return None
Expand Down
10 changes: 10 additions & 0 deletions lib/tokenize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4714,6 +4714,16 @@ void Tokenizer::setVarIdPass1()
bool initlist = false;
bool inlineFunction = false;
for (Token *tok = list.front(); tok; tok = tok->next()) {
if (Token::simpleMatch(tok, ") (") && Token::simpleMatch(tok->link(), "( *")) {
const Token *typeTok = tok->link()->previous();
while (Token::Match(typeTok, "*|&")) {
typeTok = tok->previous();
}
if (Token::Match(typeTok, "%type%")) {
tok = tok->linkAt(1);
continue;
}
}
if (tok->isOp())
continue;
if (cpp && Token::simpleMatch(tok, "template <")) {
Expand Down
2 changes: 1 addition & 1 deletion test/testvarid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1328,7 +1328,7 @@ class TestVarID : public TestFixture {
ASSERT_EQUALS(expected2, tokenize(code2));

const char code3[] = "extern void (*arr[10])(uint32_t some);\n";
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some@2 ) ;\n";
const char expected3[] = "1: extern void ( * arr@1 [ 10 ] ) ( uint32_t some ) ;\n";
ASSERT_EQUALS(expected3, tokenize(code3));

const char code4[] = "_Static_assert(sizeof((struct S){0}.i) == 4);\n"; // #12729
Expand Down
Loading