From 554fd8c5195424bdbcabf5de30fdc183aba391bd Mon Sep 17 00:00:00 2001 From: upstream source tree Date: Sun, 15 Mar 2015 20:14:05 -0400 Subject: obtained gcc-4.6.4.tar.bz2 from upstream website; verified gcc-4.6.4.tar.bz2.sig; imported gcc-4.6.4 source tree from verified upstream tarball. downloading a git-generated archive based on the 'upstream' tag should provide you with a source tree that is binary identical to the one extracted from the above tarball. if you have obtained the source via the command 'git clone', however, do note that line-endings of files in your working directory might differ from line-endings of the respective files in the upstream repository. --- gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c (limited to 'gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c') diff --git a/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c b/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c new file mode 100644 index 000000000..6eec43876 --- /dev/null +++ b/gcc/testsuite/gcc.dg/darwin-cfstring-format-1.c @@ -0,0 +1,36 @@ +/* Check CFString format extensions. */ +/* { dg-do compile { target *-*-darwin* } } */ +/* { dg-options "-Wall" } */ + +extern int printf (const char *fmt, ...); + +typedef const struct __CFString * CFStringRef; + +#ifdef __CONSTANT_CFSTRINGS__ +#define CFSTR(cStr) ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr "")) +#else +#error requires CFString +#endif + +int s1 (CFStringRef fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* OK */ +int s2 (int a, CFStringRef fmt, ... ) __attribute__((format(__CFString__, 2, 3))) ; /* OK */ + +int s2a (int a, CFStringRef fmt, ... ) __attribute__((format(CFString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */ + +int s3 (const char *fmt, ... ) __attribute__((format(__CFString__, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference but a string was found" } */ +int s4 (CFStringRef fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .CFStringRef. but the format argument should be a string" } */ + +char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ +CFStringRef s6 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */ + +char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */ +int s8 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */ + +void foo (void) +{ + CFStringRef notchk = CFSTR ("here is an unchecked %d %s string"); + s1 (notchk, 5, 6, 7); + printf("this one is checked %d %s", 3, 4, 5); /* { dg-warning "format .%s. expects argument of type .char .., but argument 3 has type .int." } */ + /* { dg-warning "too many arguments for format" "" { target *-*-* } 33 } */ + printf(s5 (1, "and so is this %d %d %s", 3, 4, "hey", 6), 5, 6, 12);/* { dg-warning "format .%s. expects argument of type .char .., but argument 4 has type .int." } */ +} -- cgit v1.2.3