]> granicus.if.org Git - clang/commitdiff
[modules] Don't diagnose a conflict between two using-declarations that name equivale...
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 12 Jan 2016 20:34:32 +0000 (20:34 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 12 Jan 2016 20:34:32 +0000 (20:34 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@257512 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclCXX.cpp
test/Modules/Inputs/using-decl-redecl/a.h
test/Modules/Inputs/using-decl-redecl/d.h [new file with mode: 0644]
test/Modules/Inputs/using-decl-redecl/module.modulemap
test/Modules/using-decl-redecl.cpp

index 4b03baf32ac95e1c6991f2d3f31357dc4276b8a9..11f232934e5a5ef978667282d2f5b6efe3e8cce7 100644 (file)
@@ -7797,6 +7797,10 @@ bool Sema::CheckUsingShadowDecl(UsingDecl *Using, NamedDecl *Orig,
       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))
index 477546945c09ee2c22535236ad2de0a378e614d2..eaa1876aac684c4d9fa72aa5f7f4fc3834111e4f 100644 (file)
@@ -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 (file)
index 0000000..2243de1
--- /dev/null
@@ -0,0 +1 @@
+#include "a.h"
index bd6ea830c2d41db47a8912acbeab3795cb6f4417..a2ebc1767645a73c37b761b2242d79f29f6d7a72 100644 (file)
@@ -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" }
index 0e78cec1188fbac2b4e0b1063bb4846a4a0526a8..0524052fce5b66db0d4a567e1f9d3bbc34c85cb1 100644 (file)
@@ -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; }