diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 4e5e307..b99007e 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -7015,6 +7015,30 @@ void Sema::HideUsingShadowDecl(Scope *S, UsingShadowDecl *Shadow) {
   // be possible for this to happen, because...?
 }
 
+class UsingValidatorCCC : public CorrectionCandidateCallback {
+public:
+  UsingValidatorCCC(bool IsTypeName, bool IsInstantiation)
+      : IsTypeName(IsTypeName), IsInstantiation(IsInstantiation) {}
+  
+  virtual bool ValidateCandidate(const TypoCorrection &Candidate) {
+    if (NamedDecl *ND = Candidate.getCorrectionDecl()) {
+      if (isa<NamespaceDecl>(ND))
+        return false;
+      else if (isa<TypeDecl>(ND))
+        return IsTypeName || !IsInstantiation;
+      else
+        return !IsTypeName;
+    } else {
+      // Keywords are not valid here.
+      return false;
+    }
+  }
+
+private:
+  bool IsTypeName;
+  bool IsInstantiation;
+};
+
 /// Builds a using declaration.
 ///
 /// \param IsInstantiation - Whether this call arises from an
@@ -7124,6 +7148,24 @@ NamedDecl *Sema::BuildUsingDeclaration(Scope *S, AccessSpecifier AS,
 
   LookupQualifiedName(R, LookupContext);
 
+  // Try to correct typos if possible.
+  if (S && R.empty()) {
+    UsingValidatorCCC CCC(IsTypeName, IsInstantiation);
+    if (TypoCorrection Corrected = CorrectTypo(R.getLookupNameInfo(),
+                                               R.getLookupKind(), S, &SS, CCC)){
+      if (NamedDecl *ND = Corrected.getCorrectionDecl()) {
+        std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
+        std::string CorrectedQuotedStr(Corrected.getQuoted(getLangOpts()));
+        R.setLookupName(Corrected.getCorrection());
+        R.addDecl(ND);
+        Diag(R.getNameLoc(), diag::err_no_member_suggest)
+            << NameInfo.getName() << LookupContext << CorrectedQuotedStr
+            << SS.getRange();
+        Diag(ND->getLocation(), diag::note_previous_decl) << CorrectedQuotedStr;
+      }
+    }
+  }
+
   if (R.empty()) {
     Diag(IdentLoc, diag::err_no_member) 
       << NameInfo.getName() << LookupContext << SS.getRange();
diff --git a/test/SemaCXX/typo-correction.cpp b/test/SemaCXX/typo-correction.cpp
index 3d40d84..05135b8 100644
--- a/test/SemaCXX/typo-correction.cpp
+++ b/test/SemaCXX/typo-correction.cpp
@@ -54,6 +54,10 @@ somename Foo; // expected-error {{unknown type name 'somename'; did you mean 'so
 namespace SomeName {} // expected-note {{namespace 'SomeName' defined here}}
 using namespace somename; // expected-error {{no namespace named 'somename'; did you mean 'SomeName'?}}
 
+namespace using_suggestion {
+namespace N { class AAA { }; } // expected-note {{'AAA' declared here}}
+using N::AAB; // expected-error {{no member named 'AAB' in namespace 'using_suggestion::N'; did you mean 'AAA'?}}
+}
 
 // Without the callback object, CorrectTypo would choose "field1" as the
 // correction for "fielda" as it is closer than "FieldA", but that correction
