From c8fd2dae17a0fc631a07ab7b66c9d3ebe90a0cc6 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Tue, 27 Apr 2010 16:26:47 +0000 Subject: [PATCH] When checking the redeclaration context of a typedef that refers to a 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 | 3 ++- test/SemaCXX/typedef-redecl.cpp | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index d9696d9ed5..fcee68d474 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -5029,7 +5029,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, if (const TagType *TT = TD->getUnderlyingType()->getAs()) { 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); diff --git a/test/SemaCXX/typedef-redecl.cpp b/test/SemaCXX/typedef-redecl.cpp index 2acf6757fa..49e1f3aa79 100644 --- a/test/SemaCXX/typedef-redecl.cpp +++ b/test/SemaCXX/typedef-redecl.cpp @@ -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; +}