Skip to content

Commit ab0eba6

Browse files
committed
Fix #14353
1 parent 2c73f8f commit ab0eba6

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
@@ -3671,21 +3671,27 @@ bool isGlobalData(const Token *expr)
36713671
globalData = true;
36723672
return ChildrenToVisit::none;
36733673
}
3674-
if (Token::Match(tok, "[*[]") && tok->astOperand1() && tok->astOperand1()->variable()) {
3674+
if (Token::Match(tok, "[*[]") && tok->astOperand1()) {
36753675
// TODO check if pointer points at local data
3676-
const Variable *lhsvar = tok->astOperand1()->variable();
3677-
const ValueType *lhstype = tok->astOperand1()->valueType();
3678-
if (lhsvar->isPointer() || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3679-
globalData = true;
3680-
return ChildrenToVisit::none;
3681-
}
3682-
if (lhsvar->isArgument() && lhsvar->isArray()) {
3683-
globalData = true;
3684-
return ChildrenToVisit::none;
3676+
const Token *lhs = tok->astOperand1();
3677+
if (!lhs->variable() && lhs->isCast()) {
3678+
lhs = lhs->astOperand1();
36853679
}
3686-
if (lhsvar->isArgument() && lhstype->type <= ValueType::Type::VOID && !lhstype->container) {
3687-
globalData = true;
3688-
return ChildrenToVisit::none;
3680+
if (lhs && lhs->variable()) {
3681+
const Variable *lhsvar = lhs->variable();
3682+
const ValueType *lhstype = lhs->valueType();
3683+
if (lhsvar->isPointer() || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3684+
globalData = true;
3685+
return ChildrenToVisit::none;
3686+
}
3687+
if (lhsvar->isArgument() && lhsvar->isArray()) {
3688+
globalData = true;
3689+
return ChildrenToVisit::none;
3690+
}
3691+
if (lhsvar->isArgument() && lhstype->type <= ValueType::Type::VOID && !lhstype->container) {
3692+
globalData = true;
3693+
return ChildrenToVisit::none;
3694+
}
36893695
}
36903696
}
36913697
if (tok->varId() == 0 && tok->isName() && tok->strAt(-1) != ".") {

0 commit comments

Comments
 (0)