From: Richard Smith Date: Mon, 16 Mar 2015 20:54:07 +0000 (+0000) Subject: [modules] If we find more formerly-canonical declarations of an entity while X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=77a38f8d37e73de86dc0621b83d6a5d13c5efcde;p=clang [modules] If we find more formerly-canonical declarations of an entity while building its redecl chains, make sure we pull in the redeclarations of those canonical declarations. It's pretty difficult to reach a situation where we can find more canonical declarations of an entity while building its redecl chains; I think the provided testcase (4 modules and 7 declarations) cannot be reduced further. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@232411 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index 68d57569b7..ec14eec2ab 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -8304,8 +8304,8 @@ void ASTReader::finishPendingActions() { // Load pending declaration chains. for (unsigned I = 0; I != PendingDeclChains.size(); ++I) { - loadPendingDeclChain(PendingDeclChains[I]); PendingDeclChainsKnown.erase(PendingDeclChains[I]); + loadPendingDeclChain(PendingDeclChains[I]); } assert(PendingDeclChainsKnown.empty()); PendingDeclChains.clear(); diff --git a/test/Modules/Inputs/redecl-found-building-chains/a.h b/test/Modules/Inputs/redecl-found-building-chains/a.h new file mode 100644 index 0000000000..27f503c2c6 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/a.h @@ -0,0 +1 @@ +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/b.h b/test/Modules/Inputs/redecl-found-building-chains/b.h new file mode 100644 index 0000000000..f69dccb2a0 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/b.h @@ -0,0 +1,2 @@ +struct A; // ensure that loading b's canonical decl doesn't load the definition +struct A {}; diff --git a/test/Modules/Inputs/redecl-found-building-chains/c.h b/test/Modules/Inputs/redecl-found-building-chains/c.h new file mode 100644 index 0000000000..27f503c2c6 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/c.h @@ -0,0 +1 @@ +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/d.h b/test/Modules/Inputs/redecl-found-building-chains/d.h new file mode 100644 index 0000000000..0beef5a79d --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/d.h @@ -0,0 +1,6 @@ +#include "a.h" // ensure that our canonical decl is not from b +struct A; +#include "b.h" +struct A; +#include "c.h" // ensure that our type for A doesn't reference the definition in b +struct A; diff --git a/test/Modules/Inputs/redecl-found-building-chains/module.modulemap b/test/Modules/Inputs/redecl-found-building-chains/module.modulemap new file mode 100644 index 0000000000..73a7c41ec5 --- /dev/null +++ b/test/Modules/Inputs/redecl-found-building-chains/module.modulemap @@ -0,0 +1,4 @@ +module a { header "a.h" export * } +module b { header "b.h" export * } +module c { header "c.h" export * } +module d { header "d.h" export * } diff --git a/test/Modules/redecl-found-building-chains.cpp b/test/Modules/redecl-found-building-chains.cpp new file mode 100644 index 0000000000..1173863ceb --- /dev/null +++ b/test/Modules/redecl-found-building-chains.cpp @@ -0,0 +1,6 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t -I%S/Inputs/redecl-found-building-chains -verify %s +// expected-no-diagnostics +int n, m; +#include "d.h" +A a;