From e60365b7b5c79536084e99fbea19c91170a41349 Mon Sep 17 00:00:00 2001 From: Anders Carlsson Date: Thu, 31 Dec 2009 18:34:24 +0000 Subject: Make sure that an overriding return type is complete before checking if it's covariant. Fixes PR5920. llvm-svn: 92365 --- clang/test/SemaCXX/virtual-override.cpp | 47 +++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'clang/test/SemaCXX/virtual-override.cpp') diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp index 503245dcfd8..4fdac85040b 100644 --- a/clang/test/SemaCXX/virtual-override.cpp +++ b/clang/test/SemaCXX/virtual-override.cpp @@ -104,6 +104,35 @@ namespace T7 { }; } +namespace T8 { + struct a { }; + struct b; // expected-note {{forward declaration of 'struct T8::b'}} + + class A { + virtual a *f(); + }; + + class B : A { + b* f(); // expected-error {{return type of virtual function 'f' is not covariant with the return type of the function it overrides ('struct T8::b' is incomplete)}} + }; +} + +namespace T9 { + struct a { }; + + template struct b : a { + int a[sizeof(T) ? -1 : -1]; // expected-error {{array size is negative}} + }; + + class A { + virtual a *f(); + }; + + class B : A { + virtual b *f(); // expected-note {{in instantiation of template class 'struct T9::b' requested here}} + }; +} + // PR5656 class X0 { virtual void f0(); @@ -150,3 +179,21 @@ void test3() { Bar3 b3i; // okay Bar3 b3f; // expected-error{{is an abstract class}} } + +// 5920 +namespace PR5920 { + class Base {}; + + template + class Derived : public Base {}; + + class Foo { + public: + virtual Base* Method(); + }; + + class Bar : public Foo { + public: + virtual Derived* Method(); + }; +} -- cgit v1.2.3