diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-27 00:56:56 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-03-27 00:56:56 +0000 |
commit | 412e0cc52ea644d804dcfa87194800371f91a977 (patch) | |
tree | 7c9a8dca0fd0aeb248eda1974a9499c6c0edc355 /test/Parser/cxx-class.cpp | |
parent | 3f718609f41921180f09ccc6e73fe8742667608e (diff) |
When we see 'Class(X' or 'Class::Class(X' and we suspect that it names a
constructor, but X is not a known typename, check whether the tokens could
possibly match the syntax of a declarator before concluding that it isn't
a constructor. If it's definitely ill-formed, assume it is a constructor.
Empirical evidence suggests that this pattern is much more often a
constructor with a typoed (or not-yet-declared) type name than any of the
other possibilities, so the extra cost of the check is not expected to be
problematic.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@153488 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Parser/cxx-class.cpp')
-rw-r--r-- | test/Parser/cxx-class.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/Parser/cxx-class.cpp b/test/Parser/cxx-class.cpp index 36f08d52d5..8b8caa585f 100644 --- a/test/Parser/cxx-class.cpp +++ b/test/Parser/cxx-class.cpp @@ -61,6 +61,30 @@ class F { typedef void F4() {} // expected-error{{function definition declared 'typedef'}} }; +namespace ctor_error { + class Foo {}; + // By [class.qual]p2, this is a constructor declaration. + Foo::Foo (F) = F(); // expected-error{{does not match any declaration in 'ctor_error::Foo'}} + + class Ctor { // expected-note{{not complete until the closing '}'}} + Ctor(f)(int); // ok + Ctor(g(int)); // ok + Ctor(x[5]); // expected-error{{incomplete type}} + + Ctor(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}} +} + // PR11109 must appear at the end of the source file class pr11109r3 { // expected-note{{to match this '{'}} public // expected-error{{expected ':'}} expected-error{{expected '}'}} expected-error{{expected ';' after class}} |