r270482 - Fix filtering of prior declarations when checking for a tag redeclaration to
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon May 23 13:03:04 PDT 2016
Author: rsmith
Date: Mon May 23 15:03:04 2016
New Revision: 270482
URL: http://llvm.org/viewvc/llvm-project?rev=270482&view=rev
Log:
Fix filtering of prior declarations when checking for a tag redeclaration to
map to the redecl context for both decls, not just one of them, and to properly
check that the decl contexts are equivalent.
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/extern-c.cpp
cfe/trunk/test/SemaCXX/friend.cpp
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=270482&r1=270481&r2=270482&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon May 23 15:03:04 2016
@@ -12338,7 +12338,8 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
LookupResult::Filter F = Previous.makeFilter();
while (F.hasNext()) {
NamedDecl *ND = F.next();
- if (ND->getDeclContext()->getRedeclContext() != SearchDC)
+ if (!ND->getDeclContext()->getRedeclContext()->Equals(
+ SearchDC->getRedeclContext()))
F.erase();
}
F.done();
Modified: cfe/trunk/test/SemaCXX/extern-c.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/extern-c.cpp?rev=270482&r1=270481&r2=270482&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/extern-c.cpp (original)
+++ cfe/trunk/test/SemaCXX/extern-c.cpp Mon May 23 15:03:04 2016
@@ -204,3 +204,41 @@ extern "C" {
struct pr5065_n6 : public virtual pr5065_3 {};
}
struct pr5065_n7 {};
+
+namespace tag_hiding {
+ namespace namespace_with_injected_name {
+ class Boo {
+ friend struct ExternCStruct1;
+ };
+ void ExternCStruct4(); // expected-note 2{{candidate}}
+ }
+
+ class Baz {
+ friend struct ExternCStruct2;
+ friend void ExternCStruct3();
+ };
+
+ using namespace namespace_with_injected_name;
+
+ extern "C" {
+ struct ExternCStruct1;
+ struct ExternCStruct2;
+ struct ExternCStruct3;
+ struct ExternCStruct4; // expected-note {{candidate}}
+ }
+ ExternCStruct1 *p1;
+ ExternCStruct2 *p2;
+ ExternCStruct3 *p3;
+ ExternCStruct4 *p4; // expected-error {{ambiguous}}
+
+ extern "C" {
+ struct ExternCStruct1;
+ struct ExternCStruct2;
+ struct ExternCStruct3;
+ struct ExternCStruct4; // expected-note {{candidate}}
+ }
+ ExternCStruct1 *q1 = p1;
+ ExternCStruct2 *q2 = p2;
+ ExternCStruct3 *q3 = p3;
+ ExternCStruct4 *q4 = p4; // expected-error {{ambiguous}}
+}
Modified: cfe/trunk/test/SemaCXX/friend.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend.cpp?rev=270482&r1=270481&r2=270482&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend.cpp Mon May 23 15:03:04 2016
@@ -363,3 +363,17 @@ void g_pr6954() {
f_pr6954(5); // expected-error{{undeclared identifier 'f_pr6954'}}
}
+namespace tag_redecl {
+ namespace N {
+ struct X *p;
+ namespace {
+ class K {
+ friend struct X;
+ };
+ }
+ }
+ namespace N {
+ struct X;
+ X *q = p;
+ }
+}
More information about the cfe-commits
mailing list