66//
77// ===----------------------------------------------------------------------===//
88
9+ // UNSUPPORTED: c++03
10+
11+ // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_ENABLE_CXX20_REMOVED_SHARED_PTR_UNIQUE
12+
913// <memory>
1014
1115// Check that functions are marked [[nodiscard]]
@@ -44,19 +48,22 @@ void test() {
4448 sPtr .get (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
4549 *sPtr ; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
4650 sPtr .use_count (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
51+ #if TEST_STD_VER <= 20
52+ sPtr .unique (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
53+ #endif
4754 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
4855 sPtr .owner_before (std::shared_ptr<int >());
4956 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
5057 sPtr .owner_before (std::weak_ptr<int >());
51- #if TEST_STD_VER >= 17
58+ # if TEST_STD_VER >= 17
5259 sPtr [0 ]; // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
53- #endif
60+ # endif
5461
5562 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
5663 std::allocate_shared<int >(std::allocator<int >(), 5 );
5764 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
5865 std::make_shared<int >();
59- #if TEST_STD_VER >= 20
66+ # if TEST_STD_VER >= 20
6067 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
6168 std::allocate_shared_for_overwrite<int >(std::allocator<int >());
6269 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
@@ -89,38 +96,30 @@ void test() {
8996 std::make_shared<int []>(5 , 82 );
9097 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
9198 std::make_shared_for_overwrite<int []>(5 );
92- #endif
99+ # endif
93100
94101 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
95102 std::static_pointer_cast<int []>(sPtr );
96- #if TEST_STD_VER >= 20
97103 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
98104 std::static_pointer_cast<int []>(std::move (sPtr ));
99- #endif
100105 class Empty {};
101106 std::shared_ptr<Empty> dsPtr;
102107 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
103108 std::dynamic_pointer_cast<Empty>(dsPtr);
104- #if TEST_STD_VER >= 20
105109 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
106110 std::dynamic_pointer_cast<Empty>(std::move (dsPtr));
107- #endif
108111 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
109112 std::const_pointer_cast<int []>(sPtr );
110- #if TEST_STD_VER >= 20
111113 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
112114 std::const_pointer_cast<int []>(std::move (sPtr ));
113- #endif
114115 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
115116 std::reinterpret_pointer_cast<int []>(sPtr );
116- #if TEST_STD_VER >= 20
117117 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
118118 std::reinterpret_pointer_cast<int []>(std::move (sPtr ));
119- #endif
120- #if !defined(TEST_HAS_NO_RTTI)
119+ # if !defined(TEST_HAS_NO_RTTI)
121120 // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
122121 std::get_deleter<int []>(sPtr );
123- #endif
122+ # endif
124123 }
125124 { // [util.smartptr.weak]
126125 std::weak_ptr<int > wPtr;
@@ -140,18 +139,18 @@ void test() {
140139
141140 es.shared_from_this (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
142141 ces.shared_from_this (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
143- #if TEST_STD_VER >= 17
142+ # if TEST_STD_VER >= 17
144143 es.weak_from_this (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
145144 ces.weak_from_this (); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
146- #endif
145+ # endif
147146 }
148- #if TEST_STD_VER >= 23
147+ # if TEST_STD_VER >= 23
149148 { // [smartptr.adapt]
150149 std::unique_ptr<int > uPtr;
151150 // [inout.ptr]
152151 std::inout_ptr (uPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
153152 // [out.ptr]
154153 std::out_ptr (uPtr); // expected-warning {{ignoring return value of function declared with 'nodiscard' attribute}}
155154 }
156- #endif
155+ # endif
157156}
0 commit comments