Fix issue with __declspec and final (#2107)
* Add missing Qt macros Add two Qt macros that were missing * Fix issue with __declspec and final This change is a bit naive but it fixes the issues I was having when combining __declspec(dllexport) and final classes. Without the fix I get errors along the line of "The code 'class x final :' is not handled. You can use -I or --include to add handling of this code. "
This commit is contained in:
parent
fd3cb24973
commit
d122b1c722
|
@ -4345,6 +4345,10 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
if (mSettings->terminated())
|
if (mSettings->terminated())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// Remove __declspec()
|
||||||
|
simplifyDeclspec();
|
||||||
|
validate();
|
||||||
|
|
||||||
// Remove "inline", "register", and "restrict"
|
// Remove "inline", "register", and "restrict"
|
||||||
simplifyKeyword();
|
simplifyKeyword();
|
||||||
|
|
||||||
|
@ -4390,9 +4394,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
|
||||||
// remove calling conventions __cdecl, __stdcall..
|
// remove calling conventions __cdecl, __stdcall..
|
||||||
simplifyCallingConvention();
|
simplifyCallingConvention();
|
||||||
|
|
||||||
// Remove __declspec()
|
|
||||||
simplifyDeclspec();
|
|
||||||
validate();
|
|
||||||
// remove some unhandled macros in global scope
|
// remove some unhandled macros in global scope
|
||||||
removeMacrosInGlobalScope();
|
removeMacrosInGlobalScope();
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,8 @@ private:
|
||||||
settings.experimental = true;
|
settings.experimental = true;
|
||||||
|
|
||||||
// don't freak out when the syntax is wrong
|
// don't freak out when the syntax is wrong
|
||||||
|
|
||||||
|
TEST_CASE(final_class_x);
|
||||||
TEST_CASE(wrong_syntax1);
|
TEST_CASE(wrong_syntax1);
|
||||||
TEST_CASE(wrong_syntax2);
|
TEST_CASE(wrong_syntax2);
|
||||||
TEST_CASE(wrong_syntax3); // #3544
|
TEST_CASE(wrong_syntax3); // #3544
|
||||||
|
@ -298,6 +300,20 @@ private:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void final_class_x() {
|
||||||
|
|
||||||
|
const char code[] = "class __declspec(dllexport) x final { };";
|
||||||
|
{
|
||||||
|
errout.str("");
|
||||||
|
Tokenizer tokenizer(&settings, this);
|
||||||
|
std::istringstream istr(code);
|
||||||
|
tokenizer.tokenize(istr, "test.cpp");
|
||||||
|
tokenizer.simplifyTokenList2();
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wrong_syntax1() {
|
void wrong_syntax1() {
|
||||||
{
|
{
|
||||||
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
|
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
|
||||||
|
@ -328,6 +344,7 @@ private:
|
||||||
ASSERT_THROW(checkCode(code), InternalError);
|
ASSERT_THROW(checkCode(code), InternalError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wrong_syntax3() { // #3544
|
void wrong_syntax3() { // #3544
|
||||||
const char code[] = "X #define\n"
|
const char code[] = "X #define\n"
|
||||||
"{\n"
|
"{\n"
|
||||||
|
|
Loading…
Reference in New Issue