================
@@ -339,6 +339,59 @@ void loop_with_break_gsl(bool cond) {
v.use(); // expected-note {{later used here}}
}
+void infinite_for_loop() {
+ MyObj safe;
+ MyObj* p = &safe;
+ {
+ MyObj s;
+ p = &s; // expected-warning {{local variable 's' does not live long
enough}}
+ } // expected-note {{local variable 's' is destroyed here}}
+ for (;;)
+ use(*p); // expected-note {{later used here}}
+}
+
+// GH222273
+void infinite_while_loop(bool cond) {
+ while (true) {
+ MyObj* p;
+ if (cond) {
+ MyObj s;
+ p = &s; // expected-warning {{local variable 's' does not live long
enough}}
+ } // expected-note {{local variable 's' is destroyed here}}
+ use(*p); // expected-note {{later used here}}
+ }
----------------
usx95 wrote:
Idea for test with two or more infinite loops:
```cpp
if (condition) { for(;;) {/*uas*/} }
else { for(;;) {/*uas*/} }
```
https://github.com/llvm/llvm-project/pull/240890
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits