diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-02-15 11:53:20 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-02-15 11:53:20 +0000 |
commit | 284bb2ec726a0e37f2ef448cd8183ea8a5f040d2 (patch) | |
tree | 4fba58ab9edb19195b8af7593222a11fa33274ae /clang/test/SemaCXX/virtual-override.cpp | |
parent | fefbff9cd854ca7fc0873fb5dada2bce55f135ff (diff) | |
download | bcm5719-llvm-284bb2ec726a0e37f2ef448cd8183ea8a5f040d2.tar.gz bcm5719-llvm-284bb2ec726a0e37f2ef448cd8183ea8a5f040d2.zip |
Defer covariance checks for dependent types. Add test cases that also ensure
they are re-checked on instantiation.
llvm-svn: 96217
Diffstat (limited to 'clang/test/SemaCXX/virtual-override.cpp')
-rw-r--r-- | clang/test/SemaCXX/virtual-override.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/virtual-override.cpp b/clang/test/SemaCXX/virtual-override.cpp index 6f1d83fd8ae..09cbfadf9b3 100644 --- a/clang/test/SemaCXX/virtual-override.cpp +++ b/clang/test/SemaCXX/virtual-override.cpp @@ -215,6 +215,29 @@ namespace PR6110 { Y1<Derived*, Base*> y; } +// Defer checking for covariance if either return type is dependent. +namespace type_dependent_covariance { + struct B {}; + template <int N> struct TD : public B {}; + template <> struct TD<1> {}; + + template <int N> struct TB {}; + struct D : public TB<0> {}; + + template <int N> struct X { + virtual B* f1(); // expected-note{{overridden virtual function is here}} + virtual TB<N>* f2(); // expected-note{{overridden virtual function is here}} + }; + template <int N, int M> struct X1 : X<N> { + virtual TD<M>* f1(); // expected-error{{return type of virtual function 'f1' is not covariant with the return type of the function it overrides ('TD<1> *'}} + virtual D* f2(); // expected-error{{return type of virtual function 'f2' is not covariant with the return type of the function it overrides ('struct type_dependent_covariance::D *' is not derived from 'TB<1> *')}} + }; + + X1<0, 0> good; + X1<0, 1> bad_derived; // expected-note{{instantiation}} + X1<1, 0> bad_base; // expected-note{{instantiation}} +} + namespace T10 { struct A { }; struct B : A { }; |