Don't try to parse a malformed parameter list after a constructor or operator
name as a direct initializer.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153628 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/include/clang/Sema/DeclSpec.h b/include/clang/Sema/DeclSpec.h
index 49460a5..f147950 100644
--- a/include/clang/Sema/DeclSpec.h
+++ b/include/clang/Sema/DeclSpec.h
@@ -1655,6 +1655,10 @@
         Context != FileContext)
       return false;
 
+    // Special names can't have direct initializers.
+    if (Name.getKind() != UnqualifiedId::IK_Identifier)
+      return false;
+
     switch (Context) {
     case FileContext:
     case BlockContext:
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp
index 8b8caa5..1b3dd41 100644
--- a/test/Parser/cxx-class.cpp
+++ b/test/Parser/cxx-class.cpp
@@ -72,17 +72,16 @@
     Ctor(x[5]); // expected-error{{incomplete type}}
 
     Ctor(UnknownType *); // expected-error{{unknown type name 'UnknownType'}}
+    void operator+(UnknownType*); // expected-error{{unknown type name 'UnknownType'}}
   };
 
   Ctor::Ctor (x) = { 0 }; // \
     // expected-error{{qualified reference to 'Ctor' is a constructor name}}
 
-  // FIXME: These diagnostics are terrible.
   Ctor::Ctor(UnknownType *) {} // \
-    // expected-error{{'Ctor' cannot be the name of a variable or data member}} \
-    // expected-error{{use of undeclared identifier 'UnknownType'}} \
-    // expected-error{{expected expression}} \
-    // expected-error{{expected ';' after top level declarator}}
+    // expected-error{{unknown type name 'UnknownType'}}
+  void Ctor::operator+(UnknownType*) {} // \
+    // expected-error{{unknown type name 'UnknownType'}}
 }
 
 // PR11109 must appear at the end of the source file