================
@@ -791,3 +791,58 @@ void global_ptr_to_ptr() {
   *global_pp = nullptr;
 }
 } // namespace leaking_via_indirect_global_invalidated
+
+namespace not_leaking_via_simple_ptr {
+void simple_ptr(const char *p) {
+  char tmp;
+  p = &tmp; // no-warning
+}
+
+void ref_ptr(const char *&p) {
+  char tmp;
+  p = &tmp; // expected-warning{{variable 'tmp' is still referred to by the 
caller variable 'p'}}
+}
+
+struct S {
+  const char *p;
----------------
necto wrote:

I do not understand what you mean.

My best interpretation
```C++
struct Ref {
  char &p;
};
void struct_ref(Ref s) {
  char tmp;
  s = {tmp}; // no-warning
}
```
does not compile

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

Reply via email to