diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp
index 19d8c611d25b177c4622b9c88d99bf4a9751dd28..7a2fca86ad596036f34173999c8541baa2b20cac 100644
--- a/src/libs/cplusplus/ResolveExpression.cpp
+++ b/src/libs/cplusplus/ResolveExpression.cpp
@@ -609,17 +609,18 @@ ClassOrNamespace *ResolveExpression::baseExpression(const QList<LookupItem> &bas
                         return retBinding;
                 }
             }
-        }
-
-        if (replacedDotOperator && accessOp == T_DOT) {
-            if (PointerType *ptrTy = ty->asPointerType()) {
-                ty = ptrTy->elementType();
-                *replacedDotOperator = true;
+        } else if (accessOp == T_DOT) {
+            if (replacedDotOperator) {
+                if (PointerType *ptrTy = ty->asPointerType()) {
+                    // replace . with ->
+                    ty = ptrTy->elementType();
+                    *replacedDotOperator = true;
+                }
             }
-        }
 
-        if (ClassOrNamespace *binding = findClass(ty, scope))
-            return binding;
+            if (ClassOrNamespace *binding = findClass(ty, scope))
+                return binding;
+        }
     }
 
     return 0;