================
@@ -40,6 +40,12 @@ namespace usage_ok {
   int *p = A().class_member(); // expected-warning {{temporary whose address 
is used as value of local variable 'p' will be destroyed at the end of the 
full-expression}}
   int *q = A(); // expected-warning {{temporary whose address is used as value 
of local variable 'q' will be destroyed at the end of the full-expression}}
   int *r = A(1); // expected-warning {{temporary whose address is used as 
value of local variable 'r' will be destroyed at the end of the 
full-expression}}
+
+  void test_assignment() {
----------------
hokein wrote:

Good point, thanks for catching it.

The reason is that we pass the `false` to the `RevisitSubinits` parameter of 
`visitLocalsRetainedByInitializer` in `checkExprLifeTime`, and we bail out the 
analysis at 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/CheckExprLifetime.cpp#L728-L729.
 For the assignment case, we should pass `true`. Fixed and added a testcase. 

https://github.com/llvm/llvm-project/pull/96475
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to