]> granicus.if.org Git - clang/commitdiff
Don't try to parse a malformed parameter list after a constructor or operator
authorRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 29 Mar 2012 01:46:00 +0000 (01:46 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Thu, 29 Mar 2012 01:46:00 +0000 (01:46 +0000)
name as a direct initializer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153628 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Sema/DeclSpec.h
test/Parser/cxx-class.cpp

index 49460a5524319e630ef39e80a2b6dbaa0b5646dc..f147950f18e3eac069753f4aaf6bc31ef4f5b60f 100644 (file)
@@ -1655,6 +1655,10 @@ public:
         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:
index 8b8caa585f7b242b39d625d0ad017008d683d527..1b3dd41ee829e3f1e716937949c6bbc43c20d40d 100644 (file)
@@ -72,17 +72,16 @@ namespace ctor_error {
     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