Index: lib/AST/Decl.cpp
===================================================================
--- lib/AST/Decl.cpp	(revision 153815)
+++ lib/AST/Decl.cpp	(working copy)
@@ -935,7 +935,53 @@
            cast<UsingDirectiveDecl>(OldD)->getNominatedNamespace()
              ->getOriginalNamespace();
   }
+  
+  
+  // Declarations within nested inline namespaces should not replace 
+  // or be replaced by declarations in enclosing namespaces :
+  // namespace A { 
+  //   int i = 10; 
+  //   enum { e = 11 };
+  //   int x = 12; 
+  //   static union { int u; };
+  //
+  //   inline namespace B {
+  //     int i = 20;
+  //     enum { e = 21 };
+  //     extern "C" { int x = 22; }
+  //     static union { int u; };
+  //   }
+  // }
+  
+  // If one of the declarations is in a different 
+  // (semantic) declaration context ...  
+  if (this->getDeclContext() != OldD->getDeclContext())
+  {
+    const DeclContext* newDC = this->getDeclContext();
+    const DeclContext* oldDC = OldD->getDeclContext();
+    
+    // ... get the enclosing namespace if we are in a transparent context
+    // such as an unscoped enum or linkage declaration.  Note, 
+    // anonymous union members are injected individually via 
+    // InjectAnonymousStructOrUnionMembers() into 
+    // the enclosing DeclContext, unlike members of transparent 
+    // contexts such as enums and linkage specifications, so we
+    // don't need to get their enclosing namespace
+    if (!newDC->isNamespace() && newDC->isTransparentContext())
+      newDC = newDC->getEnclosingNamespaceContext();
+    
+    if (!oldDC->isNamespace() && oldDC->isTransparentContext())
+      oldDC = oldDC->getEnclosingNamespaceContext();
 
+    // ... if the namespaces containing the declarations of this name 
+    // are different and if either one of them is inline, then do 
+    // not replace the old declaration with the new since they are 
+    // truly different
+    if (newDC != oldDC && 
+            newDC->isInlineNamespace() || oldDC->isInlineNamespace()) 
+      return false;    
+  }
+  
   if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
     // For function declarations, we keep track of redeclarations.
     return FD->getPreviousDecl() == OldD;
@@ -973,6 +1019,8 @@
       (isa<ObjCInterfaceDecl>(this) && isa<TypedefNameDecl>(OldD)))
     return true;
   
+  
+
   // For non-function declarations, if the declarations are of the
   // same kind then this must be a redeclaration, or semantic analysis
   // would not have given us the new declaration.
Index: test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2_inline.cpp
===================================================================
--- test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2_inline.cpp	(revision 0)
+++ test/CXX/basic/basic.lookup/basic.lookup.qual/namespace.qual/p2_inline.cpp	(working copy)
@@ -0,0 +1,34 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+namespace PR10361 {
+  inline namespace A {
+  
+     int i = 10; // expected-note {{candidate found by name lookup is 'PR10361::A::i'}}
+     enum { e = 11 }; // expected-note {{candidate found by name lookup is 'PR10361::A::::e'}}
+     int x = 12; // expected-note {{candidate found by name lookup is 'PR10361::A::x'}}
+     static union { int u; }; // expected-note {{candidate found by name lookup is 'PR10361::A::u'}}
+     template<typename A> struct f { }; // expected-note {{candidate found by name lookup is 'PR10361::A::f'}}
+     
+     inline namespace B {
+       int i = 20; // expected-note {{candidate found by name lookup is 'PR10361::A::B::i'}}
+       enum { e = 21 }; // expected-note {{candidate found by name lookup is 'PR10361::A::B::::e'}}
+       extern "C" { int x = 22; } // expected-note {{candidate found by name lookup is 'x'}}
+       static union { int u; }; // expected-note {{candidate found by name lookup is 'PR10361::A::B::u'}}
+       template<typename A> struct f { }; // expected-note {{candidate found by name lookup is 'PR10361::A::B::f'}}      
+     }
+  }
+  void test()
+  {
+    A::i = 10; // expected-error {{reference to 'i' is ambiguous}}
+    A::B::i = 20; // ok
+    int e_ = e; // expected-error {{reference to 'e' is ambiguous}}
+    e_ = A::B::e; // ok
+    int x_ = x; // expected-error {{reference to 'x' is ambiguous}}
+    x_ = A::B::x;
+    int u_ = u; // expected-error {{reference to 'u' is ambiguous}}
+    u_ = A::B::u;
+    f<int> f_; // expected-error {{reference to 'f' is ambiguous}}
+    A::B::f<int> f_ok;
+  }
+}
+
