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:
Thomas Niederberger 2019-08-23 06:43:02 +02:00 committed by Daniel Marjamäki
parent fd3cb24973
commit d122b1c722
2 changed files with 22 additions and 3 deletions

View File

@ -4345,6 +4345,10 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
if (mSettings->terminated())
return false;
// Remove __declspec()
simplifyDeclspec();
validate();
// Remove "inline", "register", and "restrict"
simplifyKeyword();
@ -4390,9 +4394,7 @@ bool Tokenizer::simplifyTokenList1(const char FileName[])
// remove calling conventions __cdecl, __stdcall..
simplifyCallingConvention();
// Remove __declspec()
simplifyDeclspec();
validate();
// remove some unhandled macros in global scope
removeMacrosInGlobalScope();

View File

@ -45,6 +45,8 @@ private:
settings.experimental = true;
// don't freak out when the syntax is wrong
TEST_CASE(final_class_x);
TEST_CASE(wrong_syntax1);
TEST_CASE(wrong_syntax2);
TEST_CASE(wrong_syntax3); // #3544
@ -298,6 +300,20 @@ private:
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() {
{
const char code[] ="TR(kvmpio, PROTO(int rw), ARGS(rw), TP_(aa->rw;))";
@ -328,6 +344,7 @@ private:
ASSERT_THROW(checkCode(code), InternalError);
}
void wrong_syntax3() { // #3544
const char code[] = "X #define\n"
"{\n"