Skip to content

Commit 2e6361a

Browse files
committed
Fix #14353
1 parent 388afe6 commit 2e6361a

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

lib/astutils.cpp

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3670,21 +3670,27 @@ bool isGlobalData(const Token *expr)
36703670
globalData = true;
36713671
return ChildrenToVisit::none;
36723672
}
3673-
if (Token::Match(tok, "[*[]") && tok->astOperand1() && tok->astOperand1()->variable()) {
3673+
if (Token::Match(tok, "[*[]") && tok->astOperand1()) {
36743674
// TODO check if pointer points at local data
3675-
const Variable *lhsvar = tok->astOperand1()->variable();
3676-
const ValueType *lhstype = tok->astOperand1()->valueType();
3677-
if (lhsvar->isPointer() || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3678-
globalData = true;
3679-
return ChildrenToVisit::none;
3680-
}
3681-
if (lhsvar->isArgument() && lhsvar->isArray()) {
3682-
globalData = true;
3683-
return ChildrenToVisit::none;
3675+
const Token *lhs = tok->astOperand1();
3676+
if (!lhs->variable() && lhs->isCast()) {
3677+
lhs = lhs->astOperand1();
36843678
}
3685-
if (lhsvar->isArgument() && lhstype->type <= ValueType::Type::VOID && !lhstype->container) {
3686-
globalData = true;
3687-
return ChildrenToVisit::none;
3679+
if (lhs && lhs->variable()) {
3680+
const Variable *lhsvar = lhs->variable();
3681+
const ValueType *lhstype = lhs->valueType();
3682+
if (lhsvar->isPointer() || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3683+
globalData = true;
3684+
return ChildrenToVisit::none;
3685+
}
3686+
if (lhsvar->isArgument() && lhsvar->isArray()) {
3687+
globalData = true;
3688+
return ChildrenToVisit::none;
3689+
}
3690+
if (lhsvar->isArgument() && lhstype->type <= ValueType::Type::VOID && !lhstype->container) {
3691+
globalData = true;
3692+
return ChildrenToVisit::none;
3693+
}
36883694
}
36893695
}
36903696
if (tok->varId() == 0 && tok->isName() && tok->strAt(-1) != ".") {

0 commit comments

Comments
 (0)