r257512 - [modules] Don't diagnose a conflict between two using-declarations that name equivalent internal linkage entities.
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 12 12:34:32 PST 2016
Author: rsmith
Date: Tue Jan 12 14:34:32 2016
New Revision: 257512
URL: http://llvm.org/viewvc/llvm-project?rev=257512&view=rev
Log:
[modules] Don't diagnose a conflict between two using-declarations that name equivalent internal linkage entities.
Added:
cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h
Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h
cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap
cfe/trunk/test/Modules/using-decl-redecl.cpp
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=257512&r1=257511&r2=257512&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jan 12 14:34:32 2016
@@ -7797,6 +7797,10 @@ bool Sema::CheckUsingShadowDecl(UsingDec
if (UsingShadowDecl *Shadow = dyn_cast<UsingShadowDecl>(*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))
Modified: cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h?rev=257512&r1=257511&r2=257512&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h (original)
+++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/a.h Tue Jan 12 14:34:32 2016
@@ -1,2 +1,3 @@
struct string {};
-namespace N { typedef ::string clstring; }
+const int n = 0;
+namespace N { typedef ::string clstring; using ::n; }
Added: cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h?rev=257512&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h (added)
+++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/d.h Tue Jan 12 14:34:32 2016
@@ -0,0 +1 @@
+#include "a.h"
Modified: cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap?rev=257512&r1=257511&r2=257512&view=diff
==============================================================================
--- cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap (original)
+++ cfe/trunk/test/Modules/Inputs/using-decl-redecl/module.modulemap Tue Jan 12 14:34:32 2016
@@ -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" }
Modified: cfe/trunk/test/Modules/using-decl-redecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/using-decl-redecl.cpp?rev=257512&r1=257511&r2=257512&view=diff
==============================================================================
--- cfe/trunk/test/Modules/using-decl-redecl.cpp (original)
+++ cfe/trunk/test/Modules/using-decl-redecl.cpp Tue Jan 12 14:34:32 2016
@@ -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 at a.h:2 {{here}}
+// expected-note at a.h:3 {{here}}
+
+namespace M { using N::n; }
More information about the cfe-commits
mailing list