================
@@ -2069,14 +2070,19 @@ int* static_array() {
   return &a[1];
 }
 
-// FIXME: Pointer arithmetic is not yet tracked.
 void pointer_arithmetic_use_after_scope() {
   int* p;
+  int* p2;
+  int* p3;
   {
     int a[10]{};
-    p = a + 5;
-  }
-  (void)*p; // Should warn.
+    p = a + 5;  // expected-warning {{object whose reference is captured does 
not live long enough}}
+    p2 = a - 5; // expected-warning {{object whose reference is captured does 
not live long enough}}
+    p3 = 5 + a; // expected-warning {{object whose reference is captured does 
not live long enough}}
+  }             // expected-note 3 {{destroyed here}}
+  (void)*p;     // expected-note {{later used here}}
+  (void)*p2;    // expected-note {{later used here}}
+  (void)*p3;    // expected-note {{later used here}}
----------------
NeKon69 wrote:

I wonder if it makes sense to write variables on the single line. like this
```
(void)*p; (void)*p2; (void)*p3;
```
So you don't have to write expected-note/expected-warning 3 times

https://github.com/llvm/llvm-project/pull/189546
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to