Skip to content

Commit b4221ce

Browse files
committed
[clang] Move the tests for https://cplusplus.github.io/CWG/issues/960.html to clang/test/CXX/drs/cwg9xx.cpp.
1 parent b1ffbf6 commit b4221ce

File tree

2 files changed

+32
-20
lines changed

2 files changed

+32
-20
lines changed

clang/test/CXX/drs/cwg9xx.cpp

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,38 @@ struct B : A {
9393
} // namespace example2
9494
} // namespace cwg952
9595

96+
namespace cwg960 { // cwg960: 2.8
97+
struct a {};
98+
class A {
99+
#if __cplusplus >= 201103L
100+
// Check lvalue ref vs rvalue ref vs pointer.
101+
virtual a& rvalue_ref();
102+
virtual a&& lvalue_ref();
103+
virtual a& rvalue_vs_lvalue_ref(); // expected-note{{overridden virtual function is here}}
104+
virtual a&& lvalue_vs_rvalue_ref(); // expected-note{{overridden virtual function is here}}
105+
virtual a& rvalue_ref_vs_pointer(); // expected-note{{overridden virtual function is here}}
106+
virtual a* pointer_vs_rvalue_ref(); // expected-note{{overridden virtual function is here}}
107+
virtual a&& lvalue_ref_vs_pointer(); // expected-note{{overridden virtual function is here}}
108+
virtual a* pointer_vs_lvalue_ref(); // expected-note{{overridden virtual function is here}}
109+
#endif
110+
};
111+
112+
class B : A {
113+
#if __cplusplus >= 201103L
114+
// Check lvalue ref vs rvalue ref vs pointer.
115+
a& rvalue_ref() override;
116+
a&& lvalue_ref() override;
117+
a&& rvalue_vs_lvalue_ref() override; // expected-error{{virtual function 'rvalue_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a &')}}
118+
a& lvalue_vs_rvalue_ref() override; // expected-error{{virtual function 'lvalue_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a &&')}}
119+
a* rvalue_ref_vs_pointer() override; // expected-error{{virtual function 'rvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &')}}
120+
a& pointer_vs_rvalue_ref() override; // expected-error{{virtual function 'pointer_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a *')}}
121+
a* lvalue_ref_vs_pointer() override; // expected-error{{virtual function 'lvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &&')}}
122+
a&& pointer_vs_lvalue_ref() override; // expected-error{{virtual function 'pointer_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a *')}}
123+
#endif
124+
};
125+
126+
} // namespace cwg960
127+
96128
namespace cwg974 { // cwg974: yes
97129
#if __cplusplus >= 201103L
98130
void test() {

clang/test/SemaCXX/virtual-override.cpp

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -102,16 +102,6 @@ class A {
102102
virtual const volatile a* const_volatile_vs_unualified_class();
103103
virtual a* unqualified_vs_const_volatile_class(); // expected-note{{overridden virtual function is here}}
104104

105-
// Check lvalue ref vs rvalue ref vs pointer.
106-
virtual a& rvalue_ref();
107-
virtual a&& lvalue_ref();
108-
virtual a& rvalue_vs_lvalue_ref(); // expected-note{{overridden virtual function is here}}
109-
virtual a&& lvalue_vs_rvalue_ref(); // expected-note{{overridden virtual function is here}}
110-
virtual a& rvalue_ref_vs_pointer(); // expected-note{{overridden virtual function is here}}
111-
virtual a* pointer_vs_rvalue_ref(); // expected-note{{overridden virtual function is here}}
112-
virtual a&& lvalue_ref_vs_pointer(); // expected-note{{overridden virtual function is here}}
113-
virtual a* pointer_vs_lvalue_ref(); // expected-note{{overridden virtual function is here}}
114-
115105
// Check non class.
116106
virtual const int* const_vs_unqualified_non_class(); // expected-note{{overridden virtual function is here}}
117107
virtual int* unqualified_vs_const_non_class(); // expected-note{{overridden virtual function is here}}
@@ -137,16 +127,6 @@ class B : A {
137127
a* const_volatile_vs_unualified_class() override;
138128
const volatile a* unqualified_vs_const_volatile_class() override; // expected-error{{return type of virtual function 'unqualified_vs_const_volatile_class' is not covariant with the return type of the function it overrides (class type 'const volatile a *' does not have the same cv-qualification as or less cv-qualification than class type 'a *')}}
139129

140-
// Check lvalue ref vs rvalue ref vs pointer.
141-
a& rvalue_ref() override;
142-
a&& lvalue_ref() override;
143-
a&& rvalue_vs_lvalue_ref() override; // expected-error{{virtual function 'rvalue_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a &')}}
144-
a& lvalue_vs_rvalue_ref() override; // expected-error{{virtual function 'lvalue_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a &&')}}
145-
a* rvalue_ref_vs_pointer() override; // expected-error{{virtual function 'rvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &')}}
146-
a& pointer_vs_rvalue_ref() override; // expected-error{{virtual function 'pointer_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a *')}}
147-
a* lvalue_ref_vs_pointer() override; // expected-error{{virtual function 'lvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &&')}}
148-
a&& pointer_vs_lvalue_ref() override; // expected-error{{virtual function 'pointer_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a *')}}
149-
150130
// Check non class.
151131
int* const_vs_unqualified_non_class() override; // expected-error{{virtual function 'const_vs_unqualified_non_class' has a different return type ('int *') than the function it overrides (which has return type 'const int *')}}
152132
const int* unqualified_vs_const_non_class() override; // expected-error{{virtual function 'unqualified_vs_const_non_class' has a different return type ('const int *') than the function it overrides (which has return type 'int *')}}

0 commit comments

Comments
 (0)