Fixed #6931 (noexcept and override qualifiers plus less than operator results in a syntax error)
This commit is contained in:
parent
be2ab9eb12
commit
cd89e68f60
|
@ -64,14 +64,12 @@ const Token * Tokenizer::isFunctionHead(const Token *tok, const std::string &end
|
|||
tok = tok->next();
|
||||
return (endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
|
||||
}
|
||||
if (isCPP() && (Token::Match(tok, ") const| throw|noexcept (") || Token::Match(tok, ") const| &|&&|noexcept| [;:{=]"))) {
|
||||
if (isCPP() && tok->str() == ")") {
|
||||
tok = tok->next();
|
||||
while (tok->isName())
|
||||
while (Token::Match(tok, "const|noexcept|override|volatile|&|&& !!("))
|
||||
tok = tok->next();
|
||||
if (Token::Match(tok, "&|&&"))
|
||||
tok = tok->next();
|
||||
if (tok->str() == "(")
|
||||
tok = tok->link()->next();
|
||||
if (Token::Match(tok, "throw|noexcept ("))
|
||||
tok = tok->linkAt(1)->next();
|
||||
if (Token::Match(tok, "= 0|default|delete ;"))
|
||||
tok = tok->tokAt(2);
|
||||
return (tok && endsWith.find(tok->str()) != std::string::npos) ? tok : nullptr;
|
||||
|
@ -2242,7 +2240,7 @@ Token * Tokenizer::startOfFunction(Token * tok) const
|
|||
{
|
||||
tok = tok->next();
|
||||
while (tok && tok->str() != "{") {
|
||||
if (isCPP() && Token::Match(tok, "const|volatile")) {
|
||||
if (isCPP() && Token::Match(tok, "const|volatile|override")) {
|
||||
tok = tok->next();
|
||||
} else if (isCPP() && tok->str() == "noexcept") {
|
||||
tok = tok->next();
|
||||
|
@ -2272,7 +2270,7 @@ const Token * Tokenizer::startOfExecutableScope(const Token * tok)
|
|||
bool inInit = false;
|
||||
while (tok && tok->str() != "{") {
|
||||
if (!inInit) {
|
||||
if (Token::Match(tok, "const|volatile")) {
|
||||
if (Token::Match(tok, "const|override|volatile")) {
|
||||
tok = tok->next();
|
||||
} else if (tok->str() == "noexcept") {
|
||||
tok = tok->next();
|
||||
|
@ -9191,9 +9189,6 @@ void Tokenizer::simplifyKeyword()
|
|||
}
|
||||
// final:
|
||||
// 2) void f() final; <- function is final
|
||||
// override:
|
||||
// void f() override;
|
||||
//if (Token::Match(tok, ") override [{;]"))
|
||||
if (Token::Match(tok, ") const|override|final")) {
|
||||
Token* specifier = tok->tokAt(2);
|
||||
while (specifier && Token::Match(specifier, "const|override|final")) {
|
||||
|
@ -9202,10 +9197,10 @@ void Tokenizer::simplifyKeyword()
|
|||
if (specifier && Token::Match(specifier, "[{;]")) {
|
||||
specifier = tok->next();
|
||||
while (!Token::Match(specifier, "[{;]")) {
|
||||
if (specifier->str()=="const")
|
||||
specifier=specifier->next();
|
||||
else
|
||||
if (specifier->str()=="final")
|
||||
specifier->deleteThis();
|
||||
else
|
||||
specifier=specifier->next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3844,7 +3844,6 @@ private:
|
|||
ASSERT_EQUALS("int foo ( ) { }", tok("__inline int foo ( ) { }", true));
|
||||
ASSERT_EQUALS("int foo ( ) { }", tok("__forceinline int foo ( ) { }", true));
|
||||
ASSERT_EQUALS("int foo ( ) { }", tok("constexpr int foo() { }", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() override ; };", true));
|
||||
ASSERT_EQUALS("class C { int f ( ) ; } ;", tok("class C { int f() final ; };", true));
|
||||
ASSERT_EQUALS("void f ( ) { int final [ 10 ] ; }", tok("void f() { int final[10]; }", true));
|
||||
ASSERT_EQUALS("int * p ;", tok("int * __restrict p;", "test.c"));
|
||||
|
|
|
@ -4011,13 +4011,13 @@ private:
|
|||
" virtual int test() final override;"
|
||||
"};";
|
||||
const char out2[] = "class Derived {\n"
|
||||
"virtual int test ( ) ; } ;";
|
||||
"virtual int test ( ) override ; } ;";
|
||||
ASSERT_EQUALS(out2, tokenizeAndStringify(in2));
|
||||
const char in3[] = "class Derived{\n"
|
||||
" virtual int test() final override const;"
|
||||
"};";
|
||||
const char out3[] = "class Derived {\n"
|
||||
"virtual int test ( ) const ; } ;";
|
||||
"virtual int test ( ) override const ; } ;";
|
||||
ASSERT_EQUALS(out3, tokenizeAndStringify(in3));
|
||||
|
||||
const char in4 [] = "struct B final : A { void foo(); };";
|
||||
|
@ -4033,7 +4033,7 @@ private:
|
|||
"};\n";
|
||||
const char out5 [] =
|
||||
"struct ArrayItemsValidator {\n"
|
||||
"SchemaError validate ( ) const {\n"
|
||||
"SchemaError validate ( ) const override {\n"
|
||||
"for ( ; pos < value . size ( ) ; ++ pos ) {\n"
|
||||
"}\n"
|
||||
"return none ;\n"
|
||||
|
@ -8320,6 +8320,7 @@ private:
|
|||
ASSERT(isStartOfExecutableScope(3, "void foo() { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() const { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() volatile { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() override { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() noexcept { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() NOEXCEPT { }"));
|
||||
ASSERT(isStartOfExecutableScope(3, "void foo() CONST NOEXCEPT { }"));
|
||||
|
|
Loading…
Reference in New Issue