@@ -35,6 +35,21 @@ namespace std {
35
35
// expected-error@-1 {{no member named 'moveable' in 'C'}}
36
36
return static_cast<T&&>(x);
37
37
}
38
+
39
+ template<typename T> CONSTEXPR const T &as_const(T &x) {
40
+ static_assert(T::moveable, "instantiated as_const"); // expected-error {{no member named 'moveable' in 'B'}}
41
+ return x;
42
+ }
43
+
44
+ template<typename T> CONSTEXPR T *addressof(T &x) {
45
+ static_assert(T::moveable, "instantiated addressof"); // expected-error {{no member named 'moveable' in 'B'}}
46
+ return __builtin_addressof(x);
47
+ }
48
+
49
+ template<typename T> CONSTEXPR T *__addressof(T &x) {
50
+ static_assert(T::moveable, "instantiated __addressof"); // expected-error {{no member named 'moveable' in 'B'}}
51
+ return __builtin_addressof(x);
52
+ }
38
53
}
39
54
40
55
// Note: this doesn't have a 'moveable' member. Instantiation of the above
@@ -45,9 +60,13 @@ constexpr bool f(A a) { // #f
45
60
A &&move_if_noexcept = std::move_if_noexcept(a);
46
61
A &&forward1 = std::forward<A>(a);
47
62
A &forward2 = std::forward<A&>(a);
63
+ const A &as_const = std::as_const(a);
64
+ A *addressof = std::addressof(a);
65
+ A *addressof2 = std::__addressof(a);
48
66
return &move == &a && &move_if_noexcept == &a &&
49
67
&forward1 == &a && &forward2 == &a &&
50
- std::move(a, a) == 5;
68
+ &as_const == &a && addressof == &a &&
69
+ addressof2 == &a && std::move(a, a) == 5;
51
70
}
52
71
53
72
#ifndef NO_CONSTEXPR
@@ -61,11 +80,14 @@ struct B {};
61
80
B &&(*pMove)(B&) = std::move; // #1 expected-note {{instantiation of}}
62
81
B &&(*pMoveIfNoexcept)(B&) = &std::move_if_noexcept; // #2 expected-note {{instantiation of}}
63
82
B &&(*pForward)(B&) = &std::forward<B>; // #3 expected-note {{instantiation of}}
83
+ const B &(*pAsConst)(B&) = &std::as_const; // #4 expected-note {{instantiation of}}
84
+ B *(*pAddressof)(B&) = &std::addressof; // #5 expected-note {{instantiation of}}
85
+ B *(*pUnderUnderAddressof)(B&) = &std::__addressof; // #6 expected-note {{instantiation of}}
64
86
int (*pUnrelatedMove)(B, B) = std::move;
65
87
66
88
struct C {};
67
- C &&(&rMove)(C&) = std::move; // #4 expected-note {{instantiation of}}
68
- C &&(&rForward)(C&) = std::forward<C>; // #5 expected-note {{instantiation of}}
89
+ C &&(&rMove)(C&) = std::move; // #7 expected-note {{instantiation of}}
90
+ C &&(&rForward)(C&) = std::forward<C>; // #8 expected-note {{instantiation of}}
69
91
int (&rUnrelatedMove)(B, B) = std::move;
70
92
71
93
#if __cplusplus <= 201703L
@@ -74,17 +96,31 @@ int (&rUnrelatedMove)(B, B) = std::move;
74
96
// expected-warning@#3 {{non-addressable}}
75
97
// expected-warning@#4 {{non-addressable}}
76
98
// expected-warning@#5 {{non-addressable}}
99
+ // expected-warning@#6 {{non-addressable}}
100
+ // expected-warning@#7 {{non-addressable}}
101
+ // expected-warning@#8 {{non-addressable}}
77
102
#else
78
103
// expected-error@#1 {{non-addressable}}
79
104
// expected-error@#2 {{non-addressable}}
80
105
// expected-error@#3 {{non-addressable}}
81
106
// expected-error@#4 {{non-addressable}}
82
107
// expected-error@#5 {{non-addressable}}
108
+ // expected-error@#6 {{non-addressable}}
109
+ // expected-error@#7 {{non-addressable}}
110
+ // expected-error@#8 {{non-addressable}}
83
111
#endif
84
112
85
113
void attribute_const() {
86
114
int n;
87
115
std::move(n); // expected-warning {{ignoring return value}}
88
116
std::move_if_noexcept(n); // expected-warning {{ignoring return value}}
89
117
std::forward<int>(n); // expected-warning {{ignoring return value}}
118
+ std::addressof(n); // expected-warning {{ignoring return value}}
119
+ std::__addressof(n); // expected-warning {{ignoring return value}}
120
+ std::as_const(n); // expected-warning {{ignoring return value}}
121
+ }
122
+
123
+ namespace std {
124
+ template<typename T> int move(T);
90
125
}
126
+ int bad_signature = std::move(0); // expected-error {{unsupported signature for 'std::move<int>'}}
0 commit comments