Fixed #1711 (Wrong typedef name shown when struct declared with __attribute__)
This commit is contained in:
parent
8881a0c361
commit
dc34a1b3ff
|
@ -1582,6 +1582,9 @@ bool Tokenizer::tokenize(std::istream &code, const char FileName[], const std::s
|
|||
// remove calling conventions __cdecl, __stdcall..
|
||||
simplifyCallingConvention();
|
||||
|
||||
// remove __attribute__((?))
|
||||
simplifyAttribute();
|
||||
|
||||
// typedef..
|
||||
simplifyTypedef();
|
||||
|
||||
|
@ -7537,3 +7540,20 @@ void Tokenizer::simplifyDeclspec()
|
|||
}
|
||||
}
|
||||
|
||||
void Tokenizer::simplifyAttribute()
|
||||
{
|
||||
while (Token::simpleMatch(_tokens, "__attribute__ (") && _tokens->next()->link() && _tokens->next()->link()->next())
|
||||
{
|
||||
Token::eraseTokens(_tokens, _tokens->next()->link()->next());
|
||||
_tokens->deleteThis();
|
||||
}
|
||||
for (Token *tok = _tokens; tok; tok = tok->next())
|
||||
{
|
||||
if (Token::simpleMatch(tok, "__attribute__ (") && tok->next()->link() && tok->next()->link()->next())
|
||||
{
|
||||
Token::eraseTokens(tok, tok->next()->link()->next());
|
||||
tok->deleteThis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -438,6 +438,11 @@ public:
|
|||
*/
|
||||
void simplifyCallingConvention();
|
||||
|
||||
/**
|
||||
* Remove __attribute__ ((?))
|
||||
*/
|
||||
void simplifyAttribute();
|
||||
|
||||
/**
|
||||
* This will return a short name describing function parameters
|
||||
* e.g. parameters: (int a, char b) should get name "int,char,".
|
||||
|
|
|
@ -208,6 +208,7 @@ private:
|
|||
TEST_CASE(removeRedundantAssignment);
|
||||
|
||||
TEST_CASE(removedeclspec);
|
||||
TEST_CASE(removeattribute);
|
||||
TEST_CASE(cpp0xtemplate);
|
||||
|
||||
TEST_CASE(arraySize);
|
||||
|
@ -3264,6 +3265,12 @@ private:
|
|||
ASSERT_EQUALS("int x [ ] ;", tokenizeAndStringify("__declspec(property(get=GetX, put=PutX)) int x[];"));
|
||||
}
|
||||
|
||||
void removeattribute()
|
||||
{
|
||||
ASSERT_EQUALS("short array [ 3 ] ;", tokenizeAndStringify("short array[3] __attribute__ ((aligned));"));
|
||||
ASSERT_EQUALS("int x [ 2 ] ;", tokenizeAndStringify("int x[2] __attribute__ ((packed));"));
|
||||
}
|
||||
|
||||
void cpp0xtemplate()
|
||||
{
|
||||
const char *code = "template <class T>\n"
|
||||
|
|
Loading…
Reference in New Issue