Commit 42110e7b by Joseph Myers Committed by Joseph Myers

format.h: New file.

	* gcc.dg/format/format.h: New file.
	* gcc.dg/format/array-1.c, gcc.dg/format/attr-1.c,
	gcc.dg/format/branch-1.c, gcc.dg/format/c90-printf-1.c,
	gcc.dg/format/c90-printf-2.c, gcc.dg/format/c90-printf-3.c,
	gcc.dg/format/c90-scanf-1.c, gcc.dg/format/c90-scanf-2.c,
	gcc.dg/format/c90-scanf-3.c, gcc.dg/format/c90-scanf-4.c,
	gcc.dg/format/c90-strftime-1.c, gcc.dg/format/c90-strftime-2.c,
	gcc.dg/format/c94-printf-1.c, gcc.dg/format/c94-scanf-1.c,
	gcc.dg/format/c99-printf-1.c, gcc.dg/format/c99-printf-2.c,
	gcc.dg/format/c99-printf-3.c, gcc.dg/format/c99-scanf-1.c,
	gcc.dg/format/c99-scanf-2.c, gcc.dg/format/c99-scanf-3.c,
	gcc.dg/format/c99-strftime-1.c, gcc.dg/format/c99-strftime-2.c,
	gcc.dg/format/diag-1.c, gcc.dg/format/errmk-1.c,
	gcc.dg/format/ext-1.c, gcc.dg/format/ext-2.c,
	gcc.dg/format/ext-3.c, gcc.dg/format/ext-4.c,
	gcc.dg/format/ext-5.c, gcc.dg/format/miss-1.c,
	gcc.dg/format/miss-2.c, gcc.dg/format/no-exargs-1.c,
	gcc.dg/format/no-y2k-1.c, gcc.dg/format/nonlit-1.c,
	gcc.dg/format/nonlit-2.c, gcc.dg/format/nonlit-3.c,
	gcc.dg/format/sec-1.c, gcc.dg/format/strfmon-1.c,
	gcc.dg/format/va-1.c, gcc.dg/format/warnll-1.c,
	gcc.dg/format/xopen-1.c, gcc.dg/format/z-1.c: Include "format.h"
	instead of declaring standard types, macros and functions in each
	test.

From-SVN: r38767
parent 96a45535
2001-01-07 Joseph S. Myers <jsm28@cam.ac.uk>
* gcc.dg/format/format.h: New file.
* gcc.dg/format/array-1.c, gcc.dg/format/attr-1.c,
gcc.dg/format/branch-1.c, gcc.dg/format/c90-printf-1.c,
gcc.dg/format/c90-printf-2.c, gcc.dg/format/c90-printf-3.c,
gcc.dg/format/c90-scanf-1.c, gcc.dg/format/c90-scanf-2.c,
gcc.dg/format/c90-scanf-3.c, gcc.dg/format/c90-scanf-4.c,
gcc.dg/format/c90-strftime-1.c, gcc.dg/format/c90-strftime-2.c,
gcc.dg/format/c94-printf-1.c, gcc.dg/format/c94-scanf-1.c,
gcc.dg/format/c99-printf-1.c, gcc.dg/format/c99-printf-2.c,
gcc.dg/format/c99-printf-3.c, gcc.dg/format/c99-scanf-1.c,
gcc.dg/format/c99-scanf-2.c, gcc.dg/format/c99-scanf-3.c,
gcc.dg/format/c99-strftime-1.c, gcc.dg/format/c99-strftime-2.c,
gcc.dg/format/diag-1.c, gcc.dg/format/errmk-1.c,
gcc.dg/format/ext-1.c, gcc.dg/format/ext-2.c,
gcc.dg/format/ext-3.c, gcc.dg/format/ext-4.c,
gcc.dg/format/ext-5.c, gcc.dg/format/miss-1.c,
gcc.dg/format/miss-2.c, gcc.dg/format/no-exargs-1.c,
gcc.dg/format/no-y2k-1.c, gcc.dg/format/nonlit-1.c,
gcc.dg/format/nonlit-2.c, gcc.dg/format/nonlit-3.c,
gcc.dg/format/sec-1.c, gcc.dg/format/strfmon-1.c,
gcc.dg/format/va-1.c, gcc.dg/format/warnll-1.c,
gcc.dg/format/xopen-1.c, gcc.dg/format/z-1.c: Include "format.h"
instead of declaring standard types, macros and functions in each
test.
2001-01-06 Alexandre Oliva <aoliva@redhat.com>
* gcc.c-torture/execute/20010106-1.c: New test.
......
......@@ -3,7 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat=2" } */
extern int printf (const char *, ...);
#include "format.h"
const char a1[] = "foo";
const char a2[] = "foo%d";
......
......@@ -3,5 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
#include "format.h"
extern void foo0 (const char *) __attribute__((__format__(__strftime__, 1, 0)));
extern void foo1 (const char *, ...) __attribute__((__format__(__strftime__, 1, 2))); /* { dg-error "cannot format" "strftime first_arg_num != 0" } */
......@@ -3,9 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
#define NULL ((void *)0)
extern int printf (const char *, ...);
#include "format.h"
void
foo (long l, int nfoo)
......@@ -25,5 +23,5 @@ foo (long l, int nfoo)
printf ((nfoo > 1) ? "%d foos" : ((nfoo > 0) ? "%ld foo" : "%d foos"), nfoo); /* { dg-warning "long int format" "wrong type" } */
/* Extra arguments to NULL should be complained about. */
printf (NULL, "foo"); /* { dg-warning "too many" "NULL extra args" } */
/* { dg-warning "null" "null format arg" { target *-*-* } 27 } */
/* { dg-warning "null" "null format arg" { target *-*-* } 25 } */
}
......@@ -6,19 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned int
#endif
typedef __WINT_TYPE__ wint_t;
__extension__ typedef long long int llong;
__extension__ typedef unsigned long long int ullong;
extern int printf (const char *, ...);
#define NULL ((void *)0)
#include "format.h"
void
foo (int i, int i1, int i2, unsigned int u, double d, char *s, void *p,
......
......@@ -5,33 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
__extension__ typedef long long int llong;
/* This next definition is a kludge. When GCC has a <stdint.h> it
should be used.
*/
/* (T *) if E is zero, (void *) otherwise. */
#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
/* (T *) if E is nonzero, (void *) otherwise. */
#define type_if(T, E) type_if_not(T, !(E))
/* Combine pointer types, all but one (void *). */
#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
extern int printf (const char *, ...);
#include "format.h"
void
foo (int i, double d, llong ll, intmax_t j, size_t z, ptrdiff_t t)
......
......@@ -6,28 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
/* This may not be correct in the particular case, but allows the
prototypes to be declared, and we don't try to link.
*/
typedef struct _FILE FILE;
extern FILE *stdout;
typedef __SIZE_TYPE__ size_t;
typedef __builtin_va_list va_list;
extern int fprintf (FILE *, const char *, ...);
extern int printf (const char *, ...);
extern int sprintf (char *, const char *, ...);
extern int vfprintf (FILE *, const char *, va_list);
extern int vprintf (const char *, va_list);
extern int vsprintf (char *, const char *, va_list);
extern int snprintf (char *, size_t, const char *, ...);
extern int vsnprintf (char *, size_t, const char *, va_list);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
#include "format.h"
void
foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
......
......@@ -6,14 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
__extension__ typedef long long int llong;
__extension__ typedef unsigned long long int ullong;
extern int scanf (const char *, ...);
#define NULL ((void *)0)
#include "format.h"
void
foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
......
......@@ -5,33 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
__extension__ typedef long long int llong;
/* This next definition is a kludge. When GCC has a <stdint.h> it
should be used.
*/
/* (T *) if E is zero, (void *) otherwise. */
#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
/* (T *) if E is nonzero, (void *) otherwise. */
#define type_if(T, E) type_if_not(T, !(E))
/* Combine pointer types, all but one (void *). */
#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (signed char *hhp, float *fp, llong *llp, intmax_t *jp,
......
......@@ -5,9 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (char **sp, wchar_t **lsp)
......
......@@ -6,25 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
/* This may not be correct in the particular case, but allows the
prototypes to be declared, and we don't try to link.
*/
typedef struct _FILE FILE;
extern FILE *stdin;
typedef __builtin_va_list va_list;
extern int fscanf (FILE *, const char *, ...);
extern int scanf (const char *, ...);
extern int sscanf (const char *, const char *, ...);
extern int vfscanf (FILE *, const char *, va_list);
extern int vscanf (const char *, va_list);
extern int vsscanf (const char *, const char *, va_list);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
#include "format.h"
void
foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
......
......@@ -4,22 +4,18 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
{
strftime (s, m, "%C", tp); /* { dg-warning "C" "%C not in C90" } */
strftime (s, m, "%D", tp); /* { dg-warning "C" "%D not in C90" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 17 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 13 } */
strftime (s, m, "%e", tp); /* { dg-warning "C" "%e not in C90" } */
strftime (s, m, "%F", tp); /* { dg-warning "C" "%F not in C90" } */
strftime (s, m, "%g", tp); /* { dg-warning "C" "%g not in C90" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 21 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 17 } */
strftime (s, m, "%G", tp); /* { dg-warning "C" "%G not in C90" } */
strftime (s, m, "%h", tp); /* { dg-warning "C" "%h not in C90" } */
strftime (s, m, "%n", tp); /* { dg-warning "C" "%n not in C90" } */
......
......@@ -3,14 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned int
#endif
typedef __WINT_TYPE__ wint_t;
extern int printf (const char *, ...);
#include "format.h"
void
foo (wint_t lc, wchar_t *ls)
......
......@@ -3,9 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:199409 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (wchar_t *ls)
......
......@@ -6,38 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
typedef __WINT_TYPE__ wint_t;
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
/* Kludge to get signed type corresponding to size_t. */
#define unsigned signed
typedef __SIZE_TYPE__ signed_size_t;
#undef unsigned
/* These next definitions are kludges. When GCC has a <stdint.h> it
should be used.
*/
#include <limits.h>
#if INT_MAX == LLONG_MAX
typedef int intmax_t;
#elif LONG_MAX == LLONG_MAX
typedef long intmax_t;
#else
typedef long long intmax_t;
#endif
#if UINT_MAX == ULLONG_MAX
typedef unsigned int uintmax_t;
#elif ULONG_MAX == ULLONG_MAX
typedef unsigned long uintmax_t;
#else
typedef unsigned long long uintmax_t;
#endif
extern int printf (const char *, ...);
#define NULL ((void *)0)
#include "format.h"
void
foo (int i, unsigned int u, double d, char *s, void *p, int *n,
......
......@@ -5,11 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
typedef __WCHAR_TYPE__ wchar_t;
typedef __WINT_TYPE__ wint_t;
extern int printf (const char *, ...);
#include "format.h"
void
foo (int i, long long ll, size_t z, wint_t lc, wchar_t *ls)
......
......@@ -5,27 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
/* This may not be correct in the particular case, but allows the
prototypes to be declared, and we don't try to link.
*/
typedef struct _FILE FILE;
extern FILE *stdout;
typedef __SIZE_TYPE__ size_t;
typedef __builtin_va_list va_list;
extern int fprintf (FILE *restrict, const char *restrict, ...);
extern int printf (const char *restrict, ...);
extern int sprintf (char *restrict, const char *restrict, ...);
extern int vfprintf (FILE *restrict, const char *restrict, va_list);
extern int vprintf (const char *restrict, va_list);
extern int vsprintf (char *restrict, const char *restrict, va_list);
extern int snprintf (char *restrict, size_t, const char *restrict, ...);
extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
#include "format.h"
void
foo (int i, char *s, size_t n, va_list v0, va_list v1, va_list v2, va_list v3,
......
......@@ -6,38 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
typedef __SIZE_TYPE__ size_t;
typedef __PTRDIFF_TYPE__ ptrdiff_t;
/* Kludges to get types corresponding to size_t and ptrdiff_t. */
#define unsigned signed
typedef __SIZE_TYPE__ signed_size_t;
#undef unsigned
#define signed /* Type might or might not have explicit 'signed'. */
typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
#undef signed
/* These next definitions are kludges. When GCC has a <stdint.h> it
should be used.
*/
#include <limits.h>
#if INT_MAX == LLONG_MAX
typedef int intmax_t;
#elif LONG_MAX == LLONG_MAX
typedef long intmax_t;
#else
typedef long long intmax_t;
#endif
#if UINT_MAX == ULLONG_MAX
typedef unsigned int uintmax_t;
#elif ULONG_MAX == ULLONG_MAX
typedef unsigned long uintmax_t;
#else
typedef unsigned long long uintmax_t;
#endif
extern int scanf (const char *, ...);
#include "format.h"
void
foo (int *ip, unsigned int *uip, short int *hp, unsigned short int *uhp,
......
......@@ -5,9 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (int *ip, long long int *llp, wchar_t *ls)
......
......@@ -5,24 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
/* This may not be correct in the particular case, but allows the
prototypes to be declared, and we don't try to link.
*/
typedef struct _FILE FILE;
extern FILE *stdin;
typedef __builtin_va_list va_list;
extern int fscanf (FILE *restrict, const char *restrict, ...);
extern int scanf (const char *restrict, ...);
extern int sscanf (const char *restrict, const char *restrict, ...);
extern int vfscanf (FILE *restrict, const char *restrict, va_list);
extern int vscanf (const char *restrict, va_list);
extern int vsscanf (const char *restrict, const char *restrict, va_list);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
#include "format.h"
void
foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
......@@ -35,19 +31,19 @@ foo (char *s, size_t m, const struct tm *tp)
strftime (s, m, "%EOy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
strftime (s, m, "%OEy", tp); /* { dg-warning "multiple|together" "multiple %E/%O" } */
strftime (s, m, "%OOV", tp); /* { dg-warning "multiple|repeated" "multiple %E/%O" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 35 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 36 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 31 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 32 } */
strftime (s, m, "%Ea", tp); /* { dg-warning "flag|modifier" "bad %Ea" } */
strftime (s, m, "%EA", tp); /* { dg-warning "flag|modifier" "bad %EA" } */
strftime (s, m, "%Eb", tp); /* { dg-warning "flag|modifier" "bad %Eb" } */
strftime (s, m, "%EB", tp); /* { dg-warning "flag|modifier" "bad %EB" } */
strftime (s, m, "%Ed", tp); /* { dg-warning "flag|modifier" "bad %Ed" } */
strftime (s, m, "%ED", tp); /* { dg-warning "flag|modifier" "bad %ED" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 45 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 41 } */
strftime (s, m, "%Ee", tp); /* { dg-warning "flag|modifier" "bad %Ee" } */
strftime (s, m, "%EF", tp); /* { dg-warning "flag|modifier" "bad %EF" } */
strftime (s, m, "%Eg", tp); /* { dg-warning "flag|modifier" "bad %Eg" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 49 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 45 } */
strftime (s, m, "%EG", tp); /* { dg-warning "flag|modifier" "bad %EG" } */
strftime (s, m, "%Eh", tp); /* { dg-warning "flag|modifier" "bad %Eh" } */
strftime (s, m, "%EH", tp); /* { dg-warning "flag|modifier" "bad %EH" } */
......@@ -75,13 +71,13 @@ foo (char *s, size_t m, const struct tm *tp)
strftime (s, m, "%Ob", tp); /* { dg-warning "flag|modifier" "bad %Ob" } */
strftime (s, m, "%OB", tp); /* { dg-warning "flag|modifier" "bad %OB" } */
strftime (s, m, "%Oc", tp); /* { dg-warning "flag|modifier" "bad %Oc" } */
/* { dg-warning "in some locales" "2-digit year" { target *-*-* } 77 } */
/* { dg-warning "in some locales" "2-digit year" { target *-*-* } 73 } */
strftime (s, m, "%OC", tp); /* { dg-warning "flag|modifier|C" "bad %OC" } */
strftime (s, m, "%OD", tp); /* { dg-warning "flag|modifier" "bad %OD" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 80 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 76 } */
strftime (s, m, "%OF", tp); /* { dg-warning "flag|modifier" "bad %OF" } */
strftime (s, m, "%Og", tp); /* { dg-warning "flag|modifier|C" "bad %Og" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 83 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 79 } */
strftime (s, m, "%OG", tp); /* { dg-warning "flag|modifier|C" "bad %OG" } */
strftime (s, m, "%Oh", tp); /* { dg-warning "flag|modifier" "bad %Oh" } */
strftime (s, m, "%Oj", tp); /* { dg-warning "flag|modifier|C" "bad %Oj" } */
......@@ -92,7 +88,7 @@ foo (char *s, size_t m, const struct tm *tp)
strftime (s, m, "%Ot", tp); /* { dg-warning "flag|modifier" "bad %Ot" } */
strftime (s, m, "%OT", tp); /* { dg-warning "flag|modifier" "bad %OT" } */
strftime (s, m, "%Ox", tp); /* { dg-warning "flag|modifier" "bad %Ox" } */
/* { dg-warning "in some locales" "2-digit year" { target *-*-* } 94 } */
/* { dg-warning "in some locales" "2-digit year" { target *-*-* } 90 } */
strftime (s, m, "%OX", tp); /* { dg-warning "flag|modifier" "bad %OX" } */
strftime (s, m, "%OY", tp); /* { dg-warning "flag|modifier|C" "bad %OY" } */
strftime (s, m, "%Oz", tp); /* { dg-warning "flag|modifier|C" "bad %Oz" } */
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1999 -pedantic -Wformat" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
......
......@@ -3,7 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (double d)
......
......@@ -3,7 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-Wformat" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (int t)
......
......@@ -5,15 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
/* %q formats want a "quad"; GCC considers this to be a long long. */
typedef long long int quad_t;
typedef unsigned long long int u_quad_t;
typedef __WCHAR_TYPE__ wchar_t;
typedef __WINT_TYPE__ wint_t;
typedef __SIZE_TYPE__ size_t;
extern int printf (const char *, ...);
#include "format.h"
void
foo (quad_t q, u_quad_t uq, quad_t *qn, size_t z, size_t *zn, long long int ll,
......
......@@ -5,13 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
/* %q formats want a "quad"; GCC considers this to be a long long. */
typedef long long int quad_t;
typedef unsigned long long int u_quad_t;
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (quad_t *qp, u_quad_t *uqp, quad_t *qn, long long int *llp,
......
......@@ -5,11 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
......@@ -102,6 +98,10 @@ foo (char *s, size_t m, const struct tm *tp)
strftime (s, m, "%-x", tp); /* { dg-warning "flag" "bad %x" } */
strftime (s, m, "%_x", tp); /* { dg-warning "flag" "bad %x" } */
strftime (s, m, "%0x", tp); /* { dg-warning "flag" "bad %x" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 89 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 90 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 91 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 92 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 93 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 94 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 95 } */
......@@ -110,10 +110,6 @@ foo (char *s, size_t m, const struct tm *tp)
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 98 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 99 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 100 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 101 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 102 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 103 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 104 } */
/* Incorrect usages with GNU extension conversion characters. */
strftime (s, m, "%5P", tp); /* { dg-warning "width" "bad %P" } */
strftime (s, m, "%-P", tp); /* { dg-warning "flag" "bad %P" } */
......@@ -193,16 +189,16 @@ foo (char *s, size_t m, const struct tm *tp)
strftime (s, m, "%#x", tp); /* { dg-warning "flag" "bad %x" } */
strftime (s, m, "%^y", tp); /* { dg-warning "flag" "bad %y" } */
strftime (s, m, "%#y", tp); /* { dg-warning "flag" "bad %y" } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 182 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 183 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 184 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 185 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 186 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 187 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 188 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 189 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 190 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 191 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 192 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 193 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 194 } */
/* { dg-warning "only last 2" "2-digit year" { target *-*-* } 195 } */
/* GCC also accepts the glibc format extensions %P, %k, %l, %s. */
strftime (s, m, "%P%k%l%s", tp);
/* GCC also accepts the glibc extension of the "O" modifier on some
......
......@@ -3,9 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu89 -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
extern int scanf (const char *, ...);
#include "format.h"
void
foo (char **sp, wchar_t **lsp)
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
extern int printf (const char *, ...);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
#include "format.h"
void
foo (int i, long l)
......
/* Format checking tests: common header. */
/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
#include <stdarg.h>
#include <stddef.h>
#ifndef _WINT_T
#ifndef __WINT_TYPE__
#define __WINT_TYPE__ unsigned int
#endif
typedef __WINT_TYPE__ wint_t;
#endif
/* Kludges to get types corresponding to size_t and ptrdiff_t. */
#define unsigned signed
typedef __SIZE_TYPE__ signed_size_t;
/* We also use this type to approximate ssize_t. */
typedef __SIZE_TYPE__ ssize_t;
#undef unsigned
#define signed /* Type might or might not have explicit 'signed'. */
typedef unsigned __PTRDIFF_TYPE__ unsigned_ptrdiff_t;
#undef signed
__extension__ typedef long long int llong;
__extension__ typedef unsigned long long int ullong;
/* %q formats want a "quad"; GCC considers this to be a long long. */
typedef llong quad_t;
typedef ullong u_quad_t;
/* This next definition is a kludge. When GCC has a <stdint.h> it
should be used.
*/
/* (T *) if E is zero, (void *) otherwise. */
#define type_if_not(T, E) __typeof__(0 ? (T *)0 : (void *)(E))
/* (T *) if E is nonzero, (void *) otherwise. */
#define type_if(T, E) type_if_not(T, !(E))
/* Combine pointer types, all but one (void *). */
#define type_comb2(T1, T2) __typeof__(0 ? (T1)0 : (T2)0)
#define type_comb3(T1, T2, T3) type_comb2(T1, type_comb2(T2, T3))
#define maybe_int_ptr type_if(int, sizeof(int) == sizeof(llong))
#define maybe_uint_ptr type_if(unsigned int, sizeof(unsigned int) == sizeof(ullong))
#define maybe_long_ptr type_if(long, sizeof(long) == sizeof(llong) && sizeof(long) > sizeof(int))
#define maybe_ulong_ptr type_if(unsigned long, sizeof(unsigned long) == sizeof(ullong) && sizeof(unsigned long) > sizeof(unsigned int))
#define maybe_long_long_ptr type_if(llong, sizeof(llong) > sizeof(long))
#define maybe_ulong_long_ptr type_if(ullong, sizeof(ullong) > sizeof(unsigned long))
#define intmax_type_ptr type_comb3(maybe_int_ptr, maybe_long_ptr, maybe_long_long_ptr)
#define uintmax_type_ptr type_comb3(maybe_uint_ptr, maybe_ulong_ptr, maybe_ulong_long_ptr)
typedef __typeof__(*((intmax_type_ptr)0)) intmax_t;
typedef __typeof__(*((uintmax_type_ptr)0)) uintmax_t;
#if __STDC_VERSION__ < 199901L
#define restrict /* "restrict" not in old C standard. */
#endif
/* This may not be correct in the particular case, but allows the
prototypes to be declared, and we don't try to link.
*/
typedef struct _FILE FILE;
extern FILE *stdin;
extern FILE *stdout;
extern int fprintf (FILE *restrict, const char *restrict, ...);
extern int printf (const char *restrict, ...);
extern int sprintf (char *restrict, const char *restrict, ...);
extern int vfprintf (FILE *restrict, const char *restrict, va_list);
extern int vprintf (const char *restrict, va_list);
extern int vsprintf (char *restrict, const char *restrict, va_list);
extern int snprintf (char *restrict, size_t, const char *restrict, ...);
extern int vsnprintf (char *restrict, size_t, const char *restrict, va_list);
extern int fscanf (FILE *restrict, const char *restrict, ...);
extern int scanf (const char *restrict, ...);
extern int sscanf (const char *restrict, const char *restrict, ...);
extern int vfscanf (FILE *restrict, const char *restrict, va_list);
extern int vscanf (const char *restrict, va_list);
extern int vsscanf (const char *restrict, const char *restrict, va_list);
extern char *gettext (const char *);
extern char *dgettext (const char *, const char *);
extern char *dcgettext (const char *, const char *, int);
struct tm;
extern size_t strftime (char *restrict, size_t, const char *restrict,
const struct tm *restrict);
extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
......@@ -3,10 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
#include <stdarg.h>
extern int vprintf (const char *restrict, va_list);
extern int vscanf (const char *restrict, va_list);
#include "format.h"
void
foo (const char *fmt, ...)
......
......@@ -4,9 +4,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wmissing-format-attribute" } */
#include <stdarg.h>
extern int vprintf (const char *restrict, va_list);
#include "format.h"
void
foo (int i, ...)
......
......@@ -4,7 +4,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wno-format-extra-args" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (int i)
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wno-format-y2k" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp)
......
......@@ -3,10 +3,10 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (char *s, __SIZE_TYPE__ i)
foo (char *s, size_t i)
{
printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
printf (s, i); /* { dg-warning "argument types" "non-literal" } */
......
......@@ -3,10 +3,10 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat=2" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (char *s, __SIZE_TYPE__ i)
foo (char *s, size_t i)
{
printf ((const char *)i, i); /* { dg-warning "argument types" "non-literal" } */
printf (s, i); /* { dg-warning "argument types" "non-literal" } */
......
......@@ -3,11 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wformat-nonliteral" } */
typedef __SIZE_TYPE__ size_t;
struct tm;
extern size_t strftime (char *, size_t, const char *, const struct tm *);
#include "format.h"
void
foo (char *s, size_t m, const struct tm *tp, char *fmt)
......
......@@ -3,7 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat -Wformat-security" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (char *s)
......
......@@ -3,16 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
typedef __SIZE_TYPE__ size_t;
/* Kludge to get something that may be ssize_t. */
#define unsigned signed
typedef __SIZE_TYPE__ ssize_t;
#undef unsigned
#define NULL ((void *)0)
extern ssize_t strfmon (char *restrict, size_t, const char *restrict, ...);
#include "format.h"
void
foo (char *s, size_t m, double d, long double ld)
......
......@@ -3,7 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-Wformat" } */
extern int printf (const char *, ...);
#include "format.h"
void
foo (void *p)
......
......@@ -5,8 +5,7 @@
/* { dg-do compile } */
/* { dg-options "-std=iso9899:1990 -pedantic -Wformat -Wno-long-long" } */
extern int printf (const char *, ...);
extern int scanf (const char *, ...);
#include "format.h"
void
foo (long long ll, unsigned long long ull, long long *lln,
......
......@@ -6,13 +6,7 @@
/* { dg-do compile } */
/* { dg-options "-std=gnu99 -Wformat" } */
typedef __WCHAR_TYPE__ wchar_t;
typedef __WINT_TYPE__ wint_t;
typedef __builtin_va_list va_list;
extern int printf (const char *, ...);
extern int vprintf (const char *, va_list);
extern int scanf (const char *, ...);
#include "format.h"
void
foo (int i, unsigned int u, wint_t lc, wchar_t *ls, int *ip, double d,
......
......@@ -3,10 +3,7 @@
/* { dg-do compile } */
/* { dg-options "-Wformat" } */
typedef __SIZE_TYPE__ size_t;
extern int printf (const char *, ...);
extern int scanf (const char *, ...);
#include "format.h"
size_t
foo (void)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment