Skip to content

Commit c5180d7

Browse files
Update checkother.cpp
1 parent b2d8361 commit c5180d7

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎lib/checkother.cpp‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4226,7 +4226,7 @@ static const Token *findShadowed(const Scope *scope, const Variable& var, int li
42264226
if (!scope)
42274227
return nullptr;
42284228
for (const Variable &v : scope->varlist) {
4229-
if (scope->isExecutable() && v.nameToken()->linenr() > linenr)
4229+
if ((scope->isExecutable() || scope->type == ScopeType::eGlobal) && v.nameToken()->linenr() > linenr)
42304230
continue;
42314231
if (v.name() == var.name())
42324232
return v.nameToken();
@@ -4312,9 +4312,10 @@ void CheckOtherImpl::checkShadowVariables()
43124312
void CheckOtherImpl::shadowError(const Token *shadows, const std::string &shadowsType,
43134313
const Token *shadowed, const std::string &shadowedType)
43144314
{
4315-
ErrorPath errorPath;
4316-
errorPath.emplace_back(shadowed, "Shadowed " + shadowedType);
4317-
errorPath.emplace_back(shadows, "Shadow " + shadowsType);
4315+
ErrorPath errorPath{
4316+
{shadowed, "Shadowed " + shadowedType},
4317+
{shadows, "Shadow " + shadowsType}
4318+
};
43184319
const std::string &varname = shadows ? shadows->str() : shadowsType;
43194320
const std::string ShadowsType = char(std::toupper(shadowsType[0])) + shadowsType.substr(1);
43204321
const std::string ShadowedType = char(std::toupper(shadowedType[0])) + shadowedType.substr(1);

0 commit comments

Comments
 (0)