return false;
}
+/* Return true if this is a "pipe" call. */
+
+bool
+is_pipe_call_p (const_tree fndecl, const char *funcname,
+ const gcall *call, unsigned int num_args)
+{
+ if (!is_named_call_p (fndecl, funcname, call, num_args))
+ return false;
+
+ /* We require a pointer for the initial argument. */
+ if (!POINTER_TYPE_P (TREE_TYPE (gimple_call_arg (call, 0))))
+ return false;
+
+ return true;
+}
+
/* For a CALL that matched is_special_named_call_p or is_named_call_p for
some name, return a name for the called function suitable for use in
diagnostics (stripping the leading underscores). */
const gcall *call, unsigned int num_args);
extern bool is_setjmp_call_p (const gcall *call);
extern bool is_longjmp_call_p (const gcall *call);
+extern bool is_pipe_call_p (const_tree fndecl, const char *funcname,
+ const gcall *call, unsigned int num_args);
extern const char *get_user_facing_name (const gcall *call);
impl_call_memset (cd);
return false;
}
- else if (is_named_call_p (callee_fndecl, "pipe", call, 1)
- || is_named_call_p (callee_fndecl, "pipe2", call, 2))
+ else if (is_pipe_call_p (callee_fndecl, "pipe", call, 1)
+ || is_pipe_call_p (callee_fndecl, "pipe2", call, 2))
{
/* Handle in "on_call_post"; bail now so that fd array
is left untouched so that we can detect use-of-uninit
impl_call_operator_delete (cd);
return;
}
- else if (is_named_call_p (callee_fndecl, "pipe", call, 1)
- || is_named_call_p (callee_fndecl, "pipe2", call, 2))
+ else if (is_pipe_call_p (callee_fndecl, "pipe", call, 1)
+ || is_pipe_call_p (callee_fndecl, "pipe2", call, 2))
{
impl_call_pipe (cd);
return;
--- /dev/null
+void pipe(int);
+
+void f1(void) {
+ pipe(1);
+}
--- /dev/null
+extern void pipe(int pipefd[2]);
+extern int close(int fd);
+
+void
+test_unchecked (void)
+{
+ int fds[2];
+ pipe (fds); /* { dg-message "when 'pipe' fails" } */
+ close (fds[0]); /* { dg-warning "use of uninitialized value 'fds\\\[0\\\]'" } */
+ close (fds[1]); /* { dg-warning "use of uninitialized value 'fds\\\[1\\\]'" } */
+}