fix passedByValueError on enums (#2869)
This commit is contained in:
parent
b96f23a388
commit
a623168942
|
@ -2807,7 +2807,9 @@ bool Type::isClassType() const
|
|||
|
||||
bool Type::isEnumType() const
|
||||
{
|
||||
return classScope && classScope->type == Scope::ScopeType::eEnum;
|
||||
//We explicitly check for "enum" because a forward declared enum doesn't get its own scope
|
||||
return (classDef && classDef->str() == "enum") ||
|
||||
(classScope && classScope->type == Scope::ScopeType::eEnum);
|
||||
}
|
||||
|
||||
bool Type::isStructType() const
|
||||
|
|
|
@ -1614,6 +1614,24 @@ private:
|
|||
" virtual void func(const std::string str) {}\n"
|
||||
"};");
|
||||
ASSERT_EQUALS("[test.cpp:2]: (performance) Function parameter 'str' should be passed by const reference.\n", errout.str());
|
||||
|
||||
check("enum X;\n"
|
||||
"void foo(X x1){}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("enum X { a, b, c };\n"
|
||||
"void foo(X x2){}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("enum X { a, b, c };\n"
|
||||
"enum X;"
|
||||
"void foo(X x3){}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
|
||||
check("enum X;\n"
|
||||
"enum X { a, b, c };"
|
||||
"void foo(X x4){}\n");
|
||||
ASSERT_EQUALS("", errout.str());
|
||||
}
|
||||
|
||||
void passedByValue_nonConst() {
|
||||
|
|
Loading…
Reference in New Issue