File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -4824,7 +4824,7 @@ void Tokenizer::setVarIdPass1()
48244824 }
48254825
48264826 // function declaration inside executable scope? Function declaration is of form: type name "(" args ")"
4827- if (scopeStack.top ().isExecutable && Token::Match (tok, " %name% [,)]" )) {
4827+ if (scopeStack.top ().isExecutable && Token::Match (tok, " %name% [,)[ ]" )) {
48284828 bool par = false ;
48294829 const Token *start, *end;
48304830
@@ -4844,7 +4844,7 @@ void Tokenizer::setVarIdPass1()
48444844 }
48454845
48464846 // search end of function declaration
4847- for (end = tok->next (); Token::Match (end, " %name%|*|&|," ); end = end->next ()) {}
4847+ for (end = tok->next (); Token::Match (end, " %name%|*|&|,|[|]|%num% " ); end = end->next ()) {}
48484848
48494849 // there are tokens which can't appear at the begin of a function declaration such as "return"
48504850 const bool isNotstartKeyword = start->next () && notstart.find (start->next ()->str ()) != notstart.end ();
Original file line number Diff line number Diff line change @@ -1497,6 +1497,22 @@ class TestVarID : public TestFixture {
14971497 const char expected[] = " 1: bool f ( X x@1 , int = 3 ) ;\n " ;
14981498 ASSERT_EQUALS (expected, actual);
14991499 }
1500+
1501+ {
1502+ const std::string actual = tokenize (" int main() {\n "
1503+ " int a[2];\n "
1504+ " extern void f(int a[2]);\n "
1505+ " f(a);\n "
1506+ " a[0] = 0;\n "
1507+ " }\n " , " test.cpp" );
1508+ const char expected[] = " 1: int main ( ) {\n "
1509+ " 2: int a@1 [ 2 ] ;\n "
1510+ " 3: extern void f ( int a [ 2 ] ) ;\n "
1511+ " 4: f ( a@1 ) ;\n "
1512+ " 5: a@1 [ 0 ] = 0 ;\n "
1513+ " 6: }\n " ;
1514+ ASSERT_EQUALS (expected, actual);
1515+ }
15001516 }
15011517
15021518 void varid_sizeof () {
You can’t perform that action at this time.
0 commit comments