@@ -3696,21 +3696,27 @@ bool isGlobalData(const Token *expr)
36963696 globalData = true ;
36973697 return ChildrenToVisit::none;
36983698 }
3699- if (Token::Match (tok, " [*[]" ) && tok->astOperand1 () && tok-> astOperand1 ()-> variable () ) {
3699+ if (Token::Match (tok, " [*[]" ) && tok->astOperand1 ()) {
37003700 // TODO check if pointer points at local data
3701- const Variable *lhsvar = tok->astOperand1 ()->variable ();
3702- const ValueType *lhstype = tok->astOperand1 ()->valueType ();
3703- if (lhsvar->isPointer () || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3704- globalData = true ;
3705- return ChildrenToVisit::none;
3706- }
3707- if (lhsvar->isArgument () && lhsvar->isArray ()) {
3708- globalData = true ;
3709- return ChildrenToVisit::none;
3701+ const Token *lhs = tok->astOperand1 ();
3702+ if (lhs->isCast ()) {
3703+ lhs = lhs->astOperand2 () ? lhs->astOperand2 () : lhs->astOperand1 ();
37103704 }
3711- if (lhsvar->isArgument () && lhstype->type <= ValueType::Type::VOID && !lhstype->container ) {
3712- globalData = true ;
3713- return ChildrenToVisit::none;
3705+ if (lhs && lhs->variable ()) {
3706+ const Variable *lhsvar = lhs->variable ();
3707+ const ValueType *lhstype = lhs->valueType ();
3708+ if (lhsvar->isPointer () || !lhstype || lhstype->type == ValueType::Type::ITERATOR) {
3709+ globalData = true ;
3710+ return ChildrenToVisit::none;
3711+ }
3712+ if (lhsvar->isArgument () && lhsvar->isArray ()) {
3713+ globalData = true ;
3714+ return ChildrenToVisit::none;
3715+ }
3716+ if (lhsvar->isArgument () && lhstype->type <= ValueType::Type::VOID && !lhstype->container ) {
3717+ globalData = true ;
3718+ return ChildrenToVisit::none;
3719+ }
37143720 }
37153721 }
37163722 if (tok->varId () == 0 && tok->isName () && tok->strAt (-1 ) != " ." ) {
0 commit comments