Index: lib/Parse/ParseDeclCXX.cpp
===================================================================
--- lib/Parse/ParseDeclCXX.cpp	(revision 166866)
+++ lib/Parse/ParseDeclCXX.cpp	(working copy)
@@ -88,6 +88,12 @@
   }
 
   if (Tok.is(tok::equal)) {
+    if (Ident == 0) {
+      Diag(Tok, diag::err_expected_ident);
+      // Skip to end of the definition and eat the ';'.
+      SkipUntil(tok::semi);
+      return 0;
+    }
     if (!attrs.empty())
       Diag(attrTok, diag::err_unexpected_namespace_attributes_alias);
     if (InlineLoc.isValid())
Index: test/Parser/namespaces.cpp
===================================================================
--- test/Parser/namespaces.cpp	(revision 166866)
+++ test/Parser/namespaces.cpp	(working copy)
@@ -6,3 +6,5 @@
 void foo() {
   namespace a { typedef g::o o; } // expected-error{{namespaces can only be defined in global or namespace scope}}
 }
+
+namespace = a; // expected-error {{expected identifier}}
