analyzer: Fix tests for glibc 2.35 [PR101081]

In recent versions of glibc fopen has __attribute__((malloc)).
Since we can not detect wether this attribute is present or not,
we avoid including stdio.h and instead forward declare what we
need in each test.

Signed-off-by: Joel Teichroeb <joel@teichroeb.net>

gcc/testsuite/ChangeLog:
	PR analyzer/101081
	* gcc.dg/analyzer/analyzer-verbosity-2a.c: Replace #include of
	stdio.h with declarations needed by the test.
	* gcc.dg/analyzer/analyzer-verbosity-3a.c: Likewise.
	* gcc.dg/analyzer/edges-1.c: Likewise.
	* gcc.dg/analyzer/file-1.c: Likewise.
	* gcc.dg/analyzer/file-2.c: Likewise.
	* gcc.dg/analyzer/file-paths-1.c: Likewise.
	* gcc.dg/analyzer/file-pr58237.c: Likewise.
	* gcc.dg/analyzer/pr99716-1.c: Likewise.

Signed-off-by: David Malcolm <dmalcolm@redhat.com>
This commit is contained in:
Joel Teichroeb 2022-02-04 11:35:08 -05:00 committed by David Malcolm
parent 391512ade5
commit e52a683170
8 changed files with 44 additions and 9 deletions

View file

@ -1,6 +1,9 @@
/* { dg-additional-options "-fanalyzer-verbosity=2" } */
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
extern int foo ();
extern void bar ();

View file

@ -1,6 +1,9 @@
/* { dg-additional-options "-fanalyzer-verbosity=3" } */
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
extern int foo ();
extern void bar ();

View file

@ -1,4 +1,7 @@
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
extern int foo ();
extern void bar ();

View file

@ -1,4 +1,9 @@
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
#define SEEK_SET 0
int fseek (FILE *, long int, int);
void
test_1 (const char *path)

View file

@ -1,4 +1,7 @@
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
struct foo
{

View file

@ -1,6 +1,13 @@
/* { dg-additional-options "-fanalyzer-verbosity=3" } */
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
char *fgets (char *, int, FILE *);
#define NULL ((void *)0)
/* Verify that we correctly emit CFG events in the face of buffers
being clobbered in these leak reports. */

View file

@ -1,4 +1,10 @@
#include <stdio.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
char *fgets (char *, int, FILE *);
#define NULL ((void *)0)
void f0(const char *str)
{

View file

@ -1,5 +1,10 @@
#include <stdio.h>
#include <stdlib.h>
typedef struct FILE FILE;
FILE* fopen (const char*, const char*);
int fclose (FILE*);
int fprintf (FILE *, const char *, ...);
#define NULL ((void *)0)
void
test_1 (void)