Skip to content

Commit 4423926

Browse files
committed
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. llvm-svn: 102437
1 parent 19defcd commit 4423926

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5029,7 +5029,8 @@ Sema::DeclPtrTy Sema::ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK,
50295029
if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
50305030
TagDecl *Tag = TT->getDecl();
50315031
if (Tag->getDeclName() == Name &&
5032-
Tag->getDeclContext()->Equals(TD->getDeclContext())) {
5032+
Tag->getDeclContext()->getLookupContext()
5033+
->Equals(TD->getDeclContext()->getLookupContext())) {
50335034
PrevDecl = Tag;
50345035
Previous.clear();
50355036
Previous.addDecl(Tag);

clang/test/SemaCXX/typedef-redecl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,14 @@ namespace test1 {
3737
using namespace a;
3838
foo x;
3939
}
40+
41+
namespace PR6923 {
42+
struct A;
43+
44+
extern "C" {
45+
struct A;
46+
typedef struct A A;
47+
}
48+
49+
struct A;
50+
}

0 commit comments

Comments
 (0)