]> granicus.if.org Git - clang/commitdiff
When checking the redeclaration context of a typedef that refers to a
authorDouglas Gregor <dgregor@apple.com>
Tue, 27 Apr 2010 16:26:47 +0000 (16:26 +0000)
committerDouglas Gregor <dgregor@apple.com>
Tue, 27 Apr 2010 16:26:47 +0000 (16:26 +0000)
tag of the same name, compare the lookup contexts rather than the
actual contexts. Fixes PR6923.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@102437 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaCXX/typedef-redecl.cpp

index d9696d9ed596d086cdec7e6e9296e34a0181945d..fcee68d474f6714e90ac60e4b950b7e68ab0b4fa 100644 (file)
@@ -5029,7 +5029,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
         if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
           TagDecl *Tag = TT->getDecl();
           if (Tag->getDeclName() == Name &&
-              Tag->getDeclContext()->Equals(TD->getDeclContext())) {
+              Tag->getDeclContext()->getLookupContext()
+                          ->Equals(TD->getDeclContext()->getLookupContext())) {
             PrevDecl = Tag;
             Previous.clear();
             Previous.addDecl(Tag);
index 2acf6757fa3d19202f4e2fd214a9cd9db36f6f01..49e1f3aa79e549855e8b95217dc944430e75541d 100644 (file)
@@ -37,3 +37,14 @@ namespace test1 {
   using namespace a; 
   foo x;
 }
+
+namespace PR6923 {
+  struct A;
+
+  extern "C" {
+    struct A;
+    typedef struct A A;
+  }
+
+  struct A;
+}