File tree Expand file tree Collapse file tree 4 files changed +33
-0
lines changed
libcxx/test/libcxx/utilities/expected Expand file tree Collapse file tree 4 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -122,5 +122,13 @@ void test() {
122
122
// expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(value())) must have the same error_type as this expected}}
123
123
}
124
124
}
125
+
126
+ // Test nodiscard
127
+ {
128
+ const std::expected<int , int > f1 (std::unexpected<int >(1 ));
129
+
130
+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
131
+ f1.and_then ([](int &){ return 1 ; });
132
+ }
125
133
}
126
134
// clang-format on
Original file line number Diff line number Diff line change @@ -121,5 +121,13 @@ void test() {
121
121
// expected-error-re@*:* {{static assertion failed {{.*}}The result of f(std::move(error())) must have the same value_type as this expected}}
122
122
}
123
123
}
124
+
125
+ // Test nodiscard
126
+ {
127
+ const std::expected<int , int > f1 (std::unexpected<int >(1 ));
128
+
129
+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
130
+ f1.or_else ([](int &){ return 1 ; });
131
+ }
124
132
}
125
133
// clang-format on
Original file line number Diff line number Diff line change @@ -121,5 +121,13 @@ void test() {
121
121
// expected-error-re@*:* {{static assertion failed {{.*}}The result of f() must have the same error_type as this expected}}
122
122
}
123
123
}
124
+
125
+ // Test nodiscard
126
+ {
127
+ const std::expected<int , int > f1 (std::unexpected<int >(1 ));
128
+
129
+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
130
+ f1.and_then ([](int &){ return 1 ; });
131
+ }
124
132
}
125
133
// clang-format on
Original file line number Diff line number Diff line change @@ -117,5 +117,14 @@ void test() {
117
117
// expected-error-re@*:* {{static assertion failed {{.*}}The result of f((void)std::move(error())) must have the same value_type as this expected}}
118
118
}
119
119
}
120
+
121
+
122
+ // Test nodiscard
123
+ {
124
+ const std::expected<int , int > f1 (std::unexpected<int >(1 ));
125
+
126
+ // expected-warning@+1 {{ignoring return value of function declared with 'nodiscard' attribute}}
127
+ f1.or_else ([](int &){ return 1 ; });
128
+ }
120
129
}
121
130
// clang-format on
You can’t perform that action at this time.
0 commit comments