This commit is contained in:
Robert Reif 2015-07-22 13:48:30 +02:00 committed by PKEuS
parent 1df46140c1
commit 4e693f1620
4 changed files with 22 additions and 2 deletions

View File

@ -347,7 +347,7 @@ SymbolDatabase::SymbolDatabase(const Tokenizer *tokenizer, const Settings *setti
function.nestedIn = scope;
// operator function
if (function.tokenDef->str().find("operator") == 0) {
if (function.tokenDef->isOperator()) {
function.isOperator(true);
// 'operator =' is special

View File

@ -374,6 +374,12 @@ public:
void isAttributeNothrow(bool value) {
setFlag(fIsAttributeNothrow, value);
}
bool isOperator() const {
return getFlag(fIsOperator);
}
void isOperator(bool value) {
setFlag(fIsOperator, value);
}
static const Token *findsimplematch(const Token *tok, const char pattern[]);
static const Token *findsimplematch(const Token *tok, const char pattern[], const Token *end);
@ -777,7 +783,8 @@ private:
fIsAttributeConst = (1 << 11), // __attribute__((const))
fIsAttributeNoreturn = (1 << 12), // __attribute__((noreturn)), __declspec(noreturn)
fIsAttributeNothrow = (1 << 13), // __attribute__((nothrow)), __declspec(nothrow)
fIsAttributeUsed = (1 << 14) // __attribute__((used))
fIsAttributeUsed = (1 << 14), // __attribute__((used))
fIsOperator = (1 << 15) // operator=, etc
};
unsigned int _flags;

View File

@ -9983,6 +9983,9 @@ void Tokenizer::simplifyOperatorName()
tok->str("operator" + op);
Token::eraseTokens(tok, par);
}
if (!op.empty())
tok->isOperator(true);
}
}

View File

@ -176,6 +176,7 @@ private:
TEST_CASE(uninitVarPointer); // ticket #3801
TEST_CASE(uninitConstVar);
TEST_CASE(constructors_crash1); // ticket #5641
TEST_CASE(classWithOperatorInName);// ticket #2827
}
@ -3190,6 +3191,15 @@ private:
"};\n");
ASSERT_EQUALS("", errout.str());
}
void classWithOperatorInName() { // ticket #2827
check("class operatorX {\n"
" int mValue;\n"
"public:\n"
" operatorX() : mValue(0) {}\n"
"};");
ASSERT_EQUALS("", errout.str());
}
};
REGISTER_TEST(TestConstructors)