diff --git a/src/shared/cplusplus/ASTVisit.cpp b/src/shared/cplusplus/ASTVisit.cpp
index 5caaa444a23fc3717c5964637143f4196162c422..d5238f52a63aa3f0af5e3ee8bc2ad16a121d97cf 100644
--- a/src/shared/cplusplus/ASTVisit.cpp
+++ b/src/shared/cplusplus/ASTVisit.cpp
@@ -1307,8 +1307,10 @@ void ObjcPropertyAttributeListAST::accept0(ASTVisitor *visitor)
 {
     if (visitor->visit(this)) {
         // visit ObjcPropertyAttributeListAST
-        for (ObjcPropertyAttributeListAST *it = this; it; it = it->next)
-            accept(it, visitor);
+        if (attr)
+            accept(attr, visitor);
+        if (next)
+            accept(next, visitor);
         // visit AST
     }
     visitor->endVisit(this);