Parser; Partial C++20 support, explicit(bool)
This commit is contained in:
parent
32b28d568f
commit
3b37c14b3c
|
@ -3693,6 +3693,16 @@ void TemplateSimplifier::simplifyTemplates(
|
||||||
if (end)
|
if (end)
|
||||||
Token::eraseTokens(tok, end);
|
Token::eraseTokens(tok, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// explicit(bool)
|
||||||
|
for (Token *tok = mTokenList.front(); tok; tok = tok->next()) {
|
||||||
|
if (Token::Match(tok, "explicit (")) {
|
||||||
|
bool isFalse = Token::simpleMatch(tok->tokAt(2), "false )");
|
||||||
|
Token::eraseTokens(tok, tok->linkAt(1)->next());
|
||||||
|
if (isFalse)
|
||||||
|
tok->deleteThis();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mTokenizer->calculateScopes();
|
mTokenizer->calculateScopes();
|
||||||
|
|
|
@ -295,6 +295,9 @@ private:
|
||||||
TEST_CASE(requires3);
|
TEST_CASE(requires3);
|
||||||
TEST_CASE(requires4);
|
TEST_CASE(requires4);
|
||||||
TEST_CASE(requires5);
|
TEST_CASE(requires5);
|
||||||
|
|
||||||
|
TEST_CASE(explicitBool1);
|
||||||
|
TEST_CASE(explicitBool2);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string tok(const char code[], bool debugwarnings = false, Settings::PlatformType type = Settings::Native) {
|
std::string tok(const char code[], bool debugwarnings = false, Settings::PlatformType type = Settings::Native) {
|
||||||
|
@ -6146,6 +6149,20 @@ private:
|
||||||
const char expected[] = "int add<int> ( int a , int b ) ; add<int> ( 123 , 456 ) ; int add<int> ( int a , int b ) { return a + b ; }";
|
const char expected[] = "int add<int> ( int a , int b ) ; add<int> ( 123 , 456 ) ; int add<int> ( int a , int b ) { return a + b ; }";
|
||||||
ASSERT_EQUALS(expected, tok(code));
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void explicitBool1() {
|
||||||
|
Settings settings;
|
||||||
|
settings.standards.cpp = Standards::CPP20;
|
||||||
|
const char code[] = "class Fred { explicit(true) Fred(int); };";
|
||||||
|
ASSERT_EQUALS("class Fred { explicit Fred ( int ) ; } ;", tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
|
void explicitBool2() {
|
||||||
|
Settings settings;
|
||||||
|
settings.standards.cpp = Standards::CPP20;
|
||||||
|
const char code[] = "class Fred { explicit(false) Fred(int); };";
|
||||||
|
ASSERT_EQUALS("class Fred { Fred ( int ) ; } ;", tok(code));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
REGISTER_TEST(TestSimplifyTemplate)
|
REGISTER_TEST(TestSimplifyTemplate)
|
||||||
|
|
Loading…
Reference in New Issue