]> granicus.if.org Git - clang/commitdiff
Miscellaneous found by inspection with John and Sebastian
authorDouglas Gregor <dgregor@apple.com>
Fri, 27 Aug 2010 22:55:10 +0000 (22:55 +0000)
committerDouglas Gregor <dgregor@apple.com>
Fri, 27 Aug 2010 22:55:10 +0000 (22:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@112315 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
lib/Sema/SemaDecl.cpp

index cb794ff60a73b7d80b435331a35944b5dec6451d..407ee3d123d574351cad17090a37b85f75cfb38f 100644 (file)
@@ -701,11 +701,10 @@ public:
   bool isFileVarDecl() const {
     if (getKind() != Decl::Var)
       return false;
-    if (const DeclContext *Ctx = getDeclContext()) {
-      Ctx = Ctx->getLookupContext();
-      if (isa<TranslationUnitDecl>(Ctx) || isa<NamespaceDecl>(Ctx) )
-        return true;
-    }
+    
+    if (getDeclContext()->getLookupContext()->isFileContext())
+      return true;
+    
     if (isStaticDataMember())
       return true;
 
index 122a956cb38ac2e0b34049ecb8d79a09e4f69b15..26d4941917438e3b338a2fef1dbd1b2096b6c0ee 100644 (file)
@@ -2627,26 +2627,23 @@ isOutOfScopePreviousDeclaration(NamedDecl *PrevDecl, DeclContext *DC,
     if (!OuterContext->isFunctionOrMethod())
       // This rule only applies to block-scope declarations.
       return false;
-    else {
-      DeclContext *PrevOuterContext = PrevDecl->getDeclContext();
-      if (PrevOuterContext->isRecord())
-        // We found a member function: ignore it.
-        return false;
-      else {
-        // Find the innermost enclosing namespace for the new and
-        // previous declarations.
-        while (!OuterContext->isFileContext())
-          OuterContext = OuterContext->getParent();
-        while (!PrevOuterContext->isFileContext())
-          PrevOuterContext = PrevOuterContext->getParent();
-
-        // The previous declaration is in a different namespace, so it
-        // isn't the same function.
-        if (OuterContext->getPrimaryContext() !=
-            PrevOuterContext->getPrimaryContext())
-          return false;
-      }
-    }
+    
+    DeclContext *PrevOuterContext = PrevDecl->getDeclContext();
+    if (PrevOuterContext->isRecord())
+      // We found a member function: ignore it.
+      return false;
+    
+    // Find the innermost enclosing namespace for the new and
+    // previous declarations.
+    while (!OuterContext->isFileContext())
+      OuterContext = OuterContext->getParent();
+    while (!PrevOuterContext->isFileContext())
+      PrevOuterContext = PrevOuterContext->getParent();
+
+    // The previous declaration is in a different namespace, so it
+    // isn't the same function.
+    if (!OuterContext->Equals(PrevOuterContext))
+      return false;
   }
 
   return true;
@@ -5511,6 +5508,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
             PrevDecl = Tag;
             Previous.clear();
             Previous.addDecl(Tag);
+            Previous.resolveKind();
           }
         }
       }