Fixed crash on wrong __attribute__((constructor)) syntax
This commit is contained in:
parent
4cad45e084
commit
6b16b519a2
|
@ -9099,7 +9099,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
// prototype for constructor is: void func(void);
|
// prototype for constructor is: void func(void);
|
||||||
if (tok->next()->link()->next()->str() == "void") // __attribute__((constructor)) void func() {}
|
if (tok->next()->link()->next()->str() == "void") // __attribute__((constructor)) void func() {}
|
||||||
tok->next()->link()->next()->next()->isAttributeConstructor(true);
|
tok->next()->link()->next()->next()->isAttributeConstructor(true);
|
||||||
else if (tok->next()->link()->next()->str() == ";") // void func() __attribute__((constructor));
|
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1)) // void func() __attribute__((constructor));
|
||||||
tok->previous()->link()->previous()->isAttributeConstructor(true);
|
tok->previous()->link()->previous()->isAttributeConstructor(true);
|
||||||
else // void __attribute__((constructor)) func() {}
|
else // void __attribute__((constructor)) func() {}
|
||||||
tok->next()->link()->next()->isAttributeConstructor(true);
|
tok->next()->link()->next()->isAttributeConstructor(true);
|
||||||
|
@ -9109,7 +9109,7 @@ void Tokenizer::simplifyAttribute()
|
||||||
// prototype for destructor is: void func(void);
|
// prototype for destructor is: void func(void);
|
||||||
if (tok->next()->link()->next()->str() == "void") // __attribute__((destructor)) void func() {}
|
if (tok->next()->link()->next()->str() == "void") // __attribute__((destructor)) void func() {}
|
||||||
tok->next()->link()->next()->next()->isAttributeDestructor(true);
|
tok->next()->link()->next()->next()->isAttributeDestructor(true);
|
||||||
else if (tok->next()->link()->next()->str() == ";") // void func() __attribute__((destructor));
|
else if (tok->next()->link()->next()->str() == ";" && tok->linkAt(-1)) // void func() __attribute__((destructor));
|
||||||
tok->previous()->link()->previous()->isAttributeDestructor(true);
|
tok->previous()->link()->previous()->isAttributeDestructor(true);
|
||||||
else // void __attribute__((destructor)) func() {}
|
else // void __attribute__((destructor)) func() {}
|
||||||
tok->next()->link()->next()->isAttributeDestructor(true);
|
tok->next()->link()->next()->isAttributeDestructor(true);
|
||||||
|
|
|
@ -277,6 +277,11 @@ private:
|
||||||
check("void f() __attribute__((destructor(1000)));\n"
|
check("void f() __attribute__((destructor(1000)));\n"
|
||||||
"void f() { }");
|
"void f() { }");
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
// Don't crash on wrong syntax
|
||||||
|
check("int x __attribute__((constructor));\n"
|
||||||
|
"int x __attribute__((destructor));");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue