summaryrefslogtreecommitdiffstats
path: root/clang/test
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2012-03-27 00:56:56 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2012-03-27 00:56:56 +0000
commitefd009de1c1ff206d32aa2b9db96bfc6a25d5256 (patch)
tree30b4983961c7c0fb9ca5880a780421029e595a43 /clang/test
parent551662bf5da58dc040eaafe5fa9417c28bf868fe (diff)
downloadbcm5719-llvm-efd009de1c1ff206d32aa2b9db96bfc6a25d5256.tar.gz
bcm5719-llvm-efd009de1c1ff206d32aa2b9db96bfc6a25d5256.zip
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. llvm-svn: 153488
Diffstat (limited to 'clang/test')
-rw-r--r--clang/test/Parser/cxx-class.cpp24
-rw-r--r--clang/test/SemaCXX/copy-assignment.cpp9
2 files changed, 26 insertions, 7 deletions
diff --git a/clang/test/Parser/cxx-class.cpp b/clang/test/Parser/cxx-class.cpp
index 36f08d52d5d..8b8caa585f7 100644
--- a/clang/test/Parser/cxx-class.cpp
+++ b/clang/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}}
diff --git a/clang/test/SemaCXX/copy-assignment.cpp b/clang/test/SemaCXX/copy-assignment.cpp
index 7aca9d6a80a..798582c149c 100644
--- a/clang/test/SemaCXX/copy-assignment.cpp
+++ b/clang/test/SemaCXX/copy-assignment.cpp
@@ -98,18 +98,13 @@ void test() {
}
// <rdar://problem/8315440>: Don't crash
-// FIXME: the recovery here is really bad.
namespace test1 {
template<typename T> class A : public unknown::X { // expected-error {{undeclared identifier 'unknown'}} expected-error {{expected class name}}
- A(UndeclaredType n) : X(n) {} // expected-error{{expected ')'}} expected-note{{to match this '('}} \
- // expected-error{{use of undeclared identifier 'n'}} \
- // expected-error{{expected ';' at end of declaration list}} \
- // expected-error{{field has incomplete type 'test1::A<char>'}}
+ A(UndeclaredType n) : X(n) {} // expected-error {{unknown type name 'UndeclaredType'}}
};
template<typename T> class B : public A<T> {
virtual void foo() {}
};
- extern template class A<char>; // expected-note {{in instantiation of template class 'test1::A<char>' requested here}} \
- // expected-note {{definition of 'test1::A<char>' is not complete until the closing '}'}}
+ extern template class A<char>;
extern template class B<char>;
}
OpenPOWER on IntegriCloud