This commit is contained in:
parent
51c8630bb3
commit
829ca9ab7f
|
@ -4710,13 +4710,15 @@ const Token * Scope::addEnum(const Token * tok, bool isCpp)
|
||||||
|
|
||||||
const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<std::string>& tokensThatAreNotEnumeratorValues) const
|
const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<std::string>& tokensThatAreNotEnumeratorValues) const
|
||||||
{
|
{
|
||||||
const Scope * scope = tok->scope();
|
if (tok->isKeyword())
|
||||||
|
|
||||||
const std::string &tokStr = tok->str();
|
|
||||||
|
|
||||||
if (tokensThatAreNotEnumeratorValues.find(tokStr) != tokensThatAreNotEnumeratorValues.end()) {
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
|
||||||
|
const std::string& tokStr = tok->str();
|
||||||
|
|
||||||
|
if (tokensThatAreNotEnumeratorValues.find(tokStr) != tokensThatAreNotEnumeratorValues.end())
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
const Scope* scope = tok->scope();
|
||||||
|
|
||||||
// check for qualified name
|
// check for qualified name
|
||||||
if (tok->strAt(-1) == "::") {
|
if (tok->strAt(-1) == "::") {
|
||||||
|
@ -4758,22 +4760,22 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<st
|
||||||
for (std::vector<Scope *>::const_iterator it = scope->nestedList.begin(), end = scope->nestedList.end(); it != end; ++it) {
|
for (std::vector<Scope *>::const_iterator it = scope->nestedList.begin(), end = scope->nestedList.end(); it != end; ++it) {
|
||||||
enumerator = (*it)->findEnumerator(tokStr);
|
enumerator = (*it)->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else { // unqualified name
|
||||||
const Enumerator * enumerator = scope->findEnumerator(tokStr);
|
const Enumerator * enumerator = scope->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|
||||||
for (std::vector<Scope *>::const_iterator s = scope->nestedList.begin(); s != scope->nestedList.end(); ++s) {
|
for (std::vector<Scope *>::const_iterator s = scope->nestedList.begin(); s != scope->nestedList.end(); ++s) {
|
||||||
enumerator = (*s)->findEnumerator(tokStr);
|
enumerator = (*s)->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4784,7 +4786,7 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<st
|
||||||
if (derivedFromType && derivedFromType->classScope) {
|
if (derivedFromType && derivedFromType->classScope) {
|
||||||
enumerator = derivedFromType->classScope->findEnumerator(tokStr);
|
enumerator = derivedFromType->classScope->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4798,13 +4800,13 @@ const Enumerator * SymbolDatabase::findEnumerator(const Token * tok, std::set<st
|
||||||
|
|
||||||
enumerator = scope->findEnumerator(tokStr);
|
enumerator = scope->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
|
|
||||||
for (std::vector<Scope*>::const_iterator s = scope->nestedList.begin(); s != scope->nestedList.end(); ++s) {
|
for (std::vector<Scope*>::const_iterator s = scope->nestedList.begin(); s != scope->nestedList.end(); ++s) {
|
||||||
enumerator = (*s)->findEnumerator(tokStr);
|
enumerator = (*s)->findEnumerator(tokStr);
|
||||||
|
|
||||||
if (enumerator)
|
if (enumerator && !(enumerator->scope && enumerator->scope->enumClass))
|
||||||
return enumerator;
|
return enumerator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1137,6 +1137,23 @@ private:
|
||||||
ASSERT_EQUALS("", errout.str());
|
ASSERT_EQUALS("", errout.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void comparisonOfBoolWithInt10() { // #10935
|
||||||
|
check("enum class E { H = 2 };\n"
|
||||||
|
"template <bool H>\n"
|
||||||
|
"void f(bool v) {\n"
|
||||||
|
" if (v == H) {}\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
|
||||||
|
check("namespace N {\n"
|
||||||
|
" enum class E { H = 2 };\n"
|
||||||
|
"}\n"
|
||||||
|
"void f(bool v) {\n"
|
||||||
|
" if (v == N::H) {}\n"
|
||||||
|
"}\n");
|
||||||
|
ASSERT_EQUALS("", errout.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void pointerArithBool1() { // #5126
|
void pointerArithBool1() { // #5126
|
||||||
check("void f(char *p) {\n"
|
check("void f(char *p) {\n"
|
||||||
|
|
Loading…
Reference in New Issue