================
@@ -331,3 +331,16 @@ void dangling_through_calls() {
// expected-warning@-1 {{Use of 'local' after its lifetime ended}}
// expected-note@-2 {{Use of 'local' after its lifetime ended}}
}
+
+// If the same variable is dereferenced multiple times then only
+// report for the first dereference.
+void multiple_deref() {
+ int *ptr = nullptr;
+ {
+ int a = 5; // expected-note {{'a' initialized to 5}}
+ ptr = &a; // expected-note {{Value assigned to 'ptr'}}
+ } // expected-note {{'a' is destroyed here}}
+ *ptr = 6; // expected-note {{Use of 'a' after its lifetime ended}}
+ // expected-warning@-1 {{Use of 'a' after its lifetime ended}}
+ *ptr = 7;
----------------
benedekaibas wrote:
Applied changes here:
[a44befc](https://github.com/llvm/llvm-project/pull/215409/commits/a44befc77019d7a6fa68bd071a0a9e0deb05d70d)
I did not bring the `// no-warning` line aligned with the expected warning and
notes because I think it is more clear this way that it is different from them.
https://github.com/llvm/llvm-project/pull/215409
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits