File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -143,6 +143,20 @@ void use() {
143
143
}
144
144
} // namespace this_is_captured
145
145
146
+ namespace temporary_capturing_object {
147
+ struct S {
148
+ void add (const int & x [[clang::lifetime_capture_by(this )]]);
149
+ };
150
+
151
+ void test () {
152
+ // We still give an warning even the capturing object is a temoprary.
153
+ // It is possible that the capturing object uses the captured object in its
154
+ // destructor.
155
+ S ().add (1 ); // expected-warning {{object whose reference is captured}}
156
+ S{}.add (1 ); // expected-warning {{object whose reference is captured}}
157
+ }
158
+ } // namespace ignore_temporary_class_object
159
+
146
160
// ****************************************************************************
147
161
// Capture by Global and Unknown.
148
162
// ****************************************************************************
You can’t perform that action at this time.
0 commit comments