================
@@ -51,6 +51,17 @@ void check_freopen(void) {
   if (errno) {} // expected-warning{{An undefined value may be read from 
'errno'}}
 }
 
+void check_popen(void) {
+  FILE *F = popen("xxx", "r");
+  if (!F) {
+    clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+    if (errno) {}                    // no-warning
+  } else {
+    if (errno) {} // expected-warning{{An undefined value may be read from 
'errno' [unix.Errno]}}
+    pclose(F);
+  }
+}
+
----------------
balazske wrote:

I like more if these new tests go into file 
**std-c-library-functions-POSIX.c**, unless the functions will be added to 
`StreamChecker` too. It looks like that the API has the same usage for files 
returned by `popen`, so `popen` (and `pclose`) can be added to `StreamChecker`.

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

Reply via email to