Fixed #3237 (Bug in parser of class operator functions)
This commit is contained in:
parent
65380d16d6
commit
b7ab1e7d7e
|
@ -9446,6 +9446,11 @@ void Tokenizer::simplifyOperatorName()
|
||||||
if (par && par->isName()) {
|
if (par && par->isName()) {
|
||||||
op += par->str();
|
op += par->str();
|
||||||
par = par->next();
|
par = par->next();
|
||||||
|
// merge namespaces eg. 'operator std :: string () const {'
|
||||||
|
if (par && par->str() == "::" && par->next() && par->next()->isName()) {
|
||||||
|
op += par->str();
|
||||||
|
par = par->next();
|
||||||
|
}
|
||||||
done = false;
|
done = false;
|
||||||
}
|
}
|
||||||
if (Token::Match(par, "=|.|++|--|%op%")) {
|
if (Token::Match(par, "=|.|++|--|%op%")) {
|
||||||
|
|
|
@ -294,6 +294,8 @@ private:
|
||||||
TEST_CASE(simplifyTypedefFunction7);
|
TEST_CASE(simplifyTypedefFunction7);
|
||||||
TEST_CASE(simplifyTypedefFunction8);
|
TEST_CASE(simplifyTypedefFunction8);
|
||||||
|
|
||||||
|
TEST_CASE(simplifyOperator1);
|
||||||
|
|
||||||
TEST_CASE(reverseArraySyntax)
|
TEST_CASE(reverseArraySyntax)
|
||||||
TEST_CASE(simplify_numeric_condition)
|
TEST_CASE(simplify_numeric_condition)
|
||||||
TEST_CASE(simplify_condition);
|
TEST_CASE(simplify_condition);
|
||||||
|
@ -6168,6 +6170,21 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str()); // make sure that there is no internal error
|
ASSERT_EQUALS("", errout.str()); // make sure that there is no internal error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void simplifyOperator1() {
|
||||||
|
// #3237 - error merging namespaces with operators
|
||||||
|
const char code[] = "class c {\n"
|
||||||
|
"public:\n"
|
||||||
|
" operator std::string() const;\n"
|
||||||
|
" operator string() const;\n"
|
||||||
|
"};\n";
|
||||||
|
const char expected[] = "class c { "
|
||||||
|
"public: "
|
||||||
|
"operatorstd::string ( ) const ; "
|
||||||
|
"operatorstring ( ) const ; "
|
||||||
|
"} ;";
|
||||||
|
ASSERT_EQUALS(expected, tok(code));
|
||||||
|
}
|
||||||
|
|
||||||
void reverseArraySyntax() {
|
void reverseArraySyntax() {
|
||||||
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
ASSERT_EQUALS("a [ 13 ]", tok("13[a]"));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue