From d83e5d4cf48fc973f0ecf769171c9de66dd9012f Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 12 Jan 2016 20:34:32 +0000 Subject: [PATCH] [modules] Don't diagnose a conflict between two using-declarations that name equivalent internal linkage entities. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257512 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclCXX.cpp | 4 ++++ test/Modules/Inputs/using-decl-redecl/a.h | 3 ++- test/Modules/Inputs/using-decl-redecl/d.h | 1 + .../Inputs/using-decl-redecl/module.modulemap | 5 +++-- test/Modules/using-decl-redecl.cpp | 12 +++++++++++- 5 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 test/Modules/Inputs/using-decl-redecl/d.h diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 4b03baf32a..11f232934e 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -7797,6 +7797,10 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig, if (UsingShadowDecl *Shadow = dyn_cast(*I)) PrevShadow = Shadow; FoundEquivalentDecl = true; + } else if (isEquivalentInternalLinkageDeclaration(D, Target)) { + // We don't conflict with an existing using shadow decl of an equivalent + // declaration, but we're not a redeclaration of it. + FoundEquivalentDecl = true; } if (isVisible(D)) diff --git a/test/Modules/Inputs/using-decl-redecl/a.h b/test/Modules/Inputs/using-decl-redecl/a.h index 477546945c..eaa1876aac 100644 --- a/test/Modules/Inputs/using-decl-redecl/a.h +++ b/test/Modules/Inputs/using-decl-redecl/a.h @@ -1,2 +1,3 @@ struct string {}; -namespace N { typedef ::string clstring; } +const int n = 0; +namespace N { typedef ::string clstring; using ::n; } diff --git a/test/Modules/Inputs/using-decl-redecl/d.h b/test/Modules/Inputs/using-decl-redecl/d.h new file mode 100644 index 0000000000..2243de1baf --- /dev/null +++ b/test/Modules/Inputs/using-decl-redecl/d.h @@ -0,0 +1 @@ +#include "a.h" diff --git a/test/Modules/Inputs/using-decl-redecl/module.modulemap b/test/Modules/Inputs/using-decl-redecl/module.modulemap index bd6ea830c2..a2ebc17676 100644 --- a/test/Modules/Inputs/using-decl-redecl/module.modulemap +++ b/test/Modules/Inputs/using-decl-redecl/module.modulemap @@ -1,3 +1,4 @@ module a { header "a.h" } -module b { header "b.h" export * } -module c { header "c.h" export * } +module b { header "b.h" export a } +module c { header "c.h" export a export b } +module d { header "d.h" } diff --git a/test/Modules/using-decl-redecl.cpp b/test/Modules/using-decl-redecl.cpp index 0e78cec118..0524052fce 100644 --- a/test/Modules/using-decl-redecl.cpp +++ b/test/Modules/using-decl-redecl.cpp @@ -2,10 +2,20 @@ // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t \ // RUN: -fmodule-map-file=%S/Inputs/using-decl-redecl/module.modulemap \ // RUN: -I%S/Inputs/using-decl-redecl \ +// RUN: -Wno-modules-ambiguous-internal-linkage \ // RUN: -verify %s + +#include "d.h" + +const int n = 0; +namespace M { using ::n; } + #include "c.h" + N::clstring y = b; // Use a typo to trigger import of all declarations in N. N::clstrinh s; // expected-error {{did you mean 'clstring'}} -// expected-note@a.h:2 {{here}} +// expected-note@a.h:3 {{here}} + +namespace M { using N::n; } -- 2.50.1