summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-29 01:46:00 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-29 01:46:00 +0000
commit0191023b5ab5127abfa657ee996ec2daaed2d26e (patch)
treebfd7bc72e282531a5c4f99eaf42fe3992dd98598
parent39d0ab32438910a0e11a64687146e2023835a93c (diff)
downloadbcm5719-llvm-0191023b5ab5127abfa657ee996ec2daaed2d26e.tar.gz
bcm5719-llvm-0191023b5ab5127abfa657ee996ec2daaed2d26e.zip
Don't try to parse a malformed parameter list after a constructor or operator
name as a direct initializer. llvm-svn: 153628
-rw-r--r--clang/include/clang/Sema/DeclSpec.h4
-rw-r--r--clang/test/Parser/cxx-class.cpp9
2 files changed, 8 insertions, 5 deletions
diff --git a/clang/include/clang/Sema/DeclSpec.h b/clang/include/clang/Sema/DeclSpec.h
index 49460a55243..f147950f18e 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -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:
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
index 8b8caa585f7..1b3dd41ee82 100644
--- a/clang/test/Parser/cxx-class.cpp
+++ b/clang/test/Parser/cxx-class.cpp
@@ -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
OpenPOWER on IntegriCloud