Fixed #5328 (Does not handle __attribute((xxx)) in typedefs)

This commit is contained in:
Robert Reif 2014-03-19 05:38:23 +01:00 committed by Daniel Marjamäki
parent b564986d5d
commit 806ef44509
2 changed files with 6 additions and 1 deletions

View File

@ -9099,7 +9099,7 @@ void Tokenizer::simplifyDeclspec()
void Tokenizer::simplifyAttribute()
{
for (Token *tok = list.front(); tok; tok = tok->next()) {
while (Token::simpleMatch(tok, "__attribute__ (") && tok->next()->link() && tok->next()->link()->next()) {
while (Token::Match(tok, "__attribute__|__attribute (") && tok->next()->link() && tok->next()->link()->next()) {
if (Token::simpleMatch(tok->tokAt(2), "( constructor")) {
// prototype for constructor is: void func(void);
if (tok->next()->link()->next()->str() == "void") // __attribute__((constructor)) void func() {}

View File

@ -7079,6 +7079,11 @@ private:
ASSERT_EQUALS("short array [ 3 ] ;", tokenizeAndStringify("short array[3] __attribute__ ((aligned));"));
ASSERT_EQUALS("int x [ 2 ] ;", tokenizeAndStringify("int x[2] __attribute__ ((packed));"));
ASSERT_EQUALS("int vecint ;", tokenizeAndStringify("int __attribute__((mode(SI))) __attribute__((vector_size (16))) vecint;"));
// alternate spelling #5328
ASSERT_EQUALS("short array [ 3 ] ;", tokenizeAndStringify("short array[3] __attribute ((aligned));"));
ASSERT_EQUALS("int x [ 2 ] ;", tokenizeAndStringify("int x[2] __attribute ((packed));"));
ASSERT_EQUALS("int vecint ;", tokenizeAndStringify("int __attribute((mode(SI))) __attribute((vector_size (16))) vecint;"));
}
void cpp0xtemplate1() {