Javier =?utf-8?q?Mu=C3=B1oz?= Kirschberg
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/[email protected]>
================
@@ -0,0 +1,41 @@
+// RUN: %clang -std=c23 -Wnrvo -Xclang -verify %s
+// expected-no-diagnostics
+
+#include <stdlib.h>
+
+#define SIZE 20
+
+typedef struct String_s {
+ char* buf;
+ size_t len;
+} String;
+
+
+void clean(String* s) {
+ free(s->buf);
+}
+
+String randomString() {
+ String s = {};
+
+ s.buf = malloc(SIZE);
+ s.len = SIZE;
+
+ if (!s.buf) {
+ goto fail;
+ }
+
+ return s;
+
+fail:
+ clean(&s);
+ return (String){};
----------------
shafik wrote:
Can we also try returning from the body of an `if` statement as well.
https://github.com/llvm/llvm-project/pull/157059
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits