summaryrefslogtreecommitdiff
path: root/test/Sema/format-strings-enum.c
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:08 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:08 +0000
commitbab175ec4b075c8076ba14c762900392533f6ee4 (patch)
tree01f4f29419a2cb10abe13c1e63cd2a66068b0137 /test/Sema/format-strings-enum.c
parent8b7a8012d223fac5d17d16a66bb39168a9a1dfc0 (diff)
Notes
Diffstat (limited to 'test/Sema/format-strings-enum.c')
-rw-r--r--test/Sema/format-strings-enum.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/test/Sema/format-strings-enum.c b/test/Sema/format-strings-enum.c
index e79f8598ab473..ba077a887e011 100644
--- a/test/Sema/format-strings-enum.c
+++ b/test/Sema/format-strings-enum.c
@@ -11,6 +11,7 @@
#endif
EXTERN_C int printf(const char *,...);
+EXTERN_C int scanf(const char *, ...);
typedef enum { Constant = 0 } TestEnum;
// Note that in C, the type of 'Constant' is 'int'. In C++ it is 'TestEnum'.
@@ -34,3 +35,18 @@ void testLong(LongEnum input) {
printf("%lu", input);
printf("%lu", LongConstant);
}
+
+#ifndef __cplusplus
+// GNU C allows forward declaring enums.
+extern enum forward_declared *fwd;
+
+void forward_enum() {
+ printf("%u", fwd); // expected-warning{{format specifies type 'unsigned int' but the argument has type 'enum forward_declared *}}
+ printf("%p", fwd);
+
+ scanf("%c", fwd); // expected-warning{{format specifies type 'char *' but the argument has type 'enum forward_declared *}}
+ scanf("%u", fwd);
+ scanf("%lu", fwd); // expected-warning{{format specifies type 'unsigned long *' but the argument has type 'enum forward_declared *}}
+ scanf("%p", fwd); // expected-warning{{format specifies type 'void **' but the argument has type 'enum forward_declared *}}
+}
+#endif