Fix PR clang/3291

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61886 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 49719ab..351694c 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -343,11 +343,11 @@
           }
         }
         
+        if (!LookInParent && !Ctx->isTransparentContext())
+          return 0;
+
         Ctx = Ctx->getParent();
       }
-      
-      if (!LookInParent && !Ctx->isTransparentContext())
-        return 0;
     }
   }