aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/format/c90-scanf-3.c
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gcc.dg/format/c90-scanf-3.c')
-rw-r--r--gcc/testsuite/gcc.dg/format/c90-scanf-3.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.dg/format/c90-scanf-3.c b/gcc/testsuite/gcc.dg/format/c90-scanf-3.c
new file mode 100644
index 0000000..147a222
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/format/c90-scanf-3.c
@@ -0,0 +1,21 @@
+/* Test for scanf formats. Formats using extensions to the standard
+ should be rejected in strict pedantic mode.
+*/
+/* Origin: Joseph Myers <jsm28@cam.ac.uk> */
+/* { dg-do compile } */
+/* { dg-options "-std=iso9899:1990 -pedantic -Wformat" } */
+
+typedef __WCHAR_TYPE__ wchar_t;
+
+extern int scanf (const char *, ...);
+
+void
+foo (char **sp, wchar_t **lsp)
+{
+ /* %a formats for allocation, only recognised in C90 mode, are a
+ GNU extension.
+ */
+ scanf ("%as", sp); /* { dg-warning "C" "%as" } */
+ scanf ("%aS", lsp); /* { dg-warning "C" "%aS" } */
+ scanf ("%a[bcd]", sp); /* { dg-warning "C" "%a[]" } */
+}