From 088e46b8d4d81e429f78ca75b47a179f489be16d Mon Sep 17 00:00:00 2001
From: Alexandre Oliva <oliva@adacore.com>
Date: Thu, 14 Jan 2021 16:12:19 -0300
Subject: [PATCH] declare getpass in analyzer/sensitive-1.c test

The getpass function is not available on all systems; and not
necessarily declared in unistd.h, as expected by the sensitive-1
analyzer test.

Since this is a compile-only test, it doesn't really matter if the
function is defined in the system libraries.  All we need is a
declaration, to avoid warnings from calling an undeclared function.
This patch adds the declaration, in a way that is most unlikely to
conflict with any existing declaration.


for  gcc/testsuite/ChangeLog

	* gcc.dg/analyzer/sensitive-1.c: Declare getpass.
---
 gcc/testsuite/gcc.dg/analyzer/sensitive-1.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
index 81144af620ed..c66af9276174 100644
--- a/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
+++ b/gcc/testsuite/gcc.dg/analyzer/sensitive-1.c
@@ -6,6 +6,11 @@
 
 #include <string.h>
 
+/* Declare getpass, in case unistd doesn't declare it.
+   Parenthesize it, in case it's a macro.
+   Don't use a prototype, to avoid const mismatches.  */
+extern char *(getpass) ();
+
 char test_1 (FILE *logfile)
 {
   char *password = getpass (">"); /* { dg-message "\\(1\\) sensitive value acquired here" } */
-- 
GitLab