Tokenizer: simplification of typedefs in _Generic arguments (#5059)
This commit is contained in:
parent
793d6aef01
commit
d475591665
|
@ -935,6 +935,18 @@ namespace {
|
|||
return true;
|
||||
if (Token::Match(tok->previous(), "public|protected|private"))
|
||||
return true;
|
||||
if (Token::Match(tok->previous(), ", %name% :")) {
|
||||
bool isGeneric = false;
|
||||
for (; tok; tok = tok->previous()) {
|
||||
if (Token::Match(tok, ")|]"))
|
||||
tok = tok->link();
|
||||
else if (Token::Match(tok, "[;{}(]")) {
|
||||
isGeneric = Token::simpleMatch(tok->previous(), "_Generic (");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return isGeneric;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (Token::Match(tok->previous(), "%name%") && !tok->previous()->isKeyword())
|
||||
|
|
|
@ -69,6 +69,7 @@ private:
|
|||
TEST_CASE(carray2);
|
||||
TEST_CASE(cdonotreplace1);
|
||||
TEST_CASE(cppfp1);
|
||||
TEST_CASE(Generic1);
|
||||
|
||||
TEST_CASE(simplifyTypedef1);
|
||||
TEST_CASE(simplifyTypedef2);
|
||||
|
@ -463,6 +464,12 @@ private:
|
|||
ASSERT_EQUALS("void foo ( void ( * p ) ( void ) ) ;", tok(code));
|
||||
}
|
||||
|
||||
void Generic1() {
|
||||
const char code[] = "typedef void func(void);\n"
|
||||
"_Generic((x), func: 1, default: 2);";
|
||||
ASSERT_EQUALS("_Generic ( x , void ( ) : 1 , default : 2 ) ;", tok(code));
|
||||
}
|
||||
|
||||
void simplifyTypedef1() {
|
||||
const char code[] = "class A\n"
|
||||
"{\n"
|
||||
|
|
Loading…
Reference in New Issue