aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format/c90-scanf-4.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/c90-scanf-4.c')
-rw-r--r--gcc/testsuite/gcc.dg/format/c90-scanf-4.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-4.c b/gcc/testsuite/gcc.dg/format/c90-scanf-4.c
new file mode 100644
index 0000000..3bbe66e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format/c90-scanf-4.c
@@ -0,0 +1,51 @@
+/* Test for scanf formats. Test that the C90 functions get their default
+ attributes in strict C90 mode, but the C99 and gettext functions
+ do not.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { 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);
+
+void
+foo (int *ip, char *s, va_list v0, va_list v1, va_list v2, va_list v3,
+ va_list v4, va_list v5)
+{
+ fscanf (stdin, "%d", ip);
+ fscanf (stdin, "%ld", ip); /* { dg-warning "format" "fscanf" } */
+ scanf ("%d", ip);
+ scanf ("%ld", ip); /* { dg-warning "format" "scanf" } */
+ sscanf (s, "%d", ip);
+ sscanf (s, "%ld", ip); /* { dg-warning "format" "sscanf" } */
+ vfscanf (stdin, "%d", v0);
+ vfscanf (stdin, "%Y", v1);
+ vscanf ("%d", v2);
+ vscanf ("%Y", v3);
+ vsscanf (s, "%d", v4);
+ vsscanf (s, "%Y", v5);
+ scanf (gettext ("%d"), ip);
+ scanf (gettext ("%ld"), ip);
+ scanf (dgettext ("", "%d"), ip);
+ scanf (dgettext ("", "%ld"), ip);
+ scanf (dcgettext ("", "%d", 0), ip);
+ scanf (dcgettext ("", "%ld", 0), ip);
+}