[AArch64] Merge stores of D-register values with different modes
[official-gcc.git] / gcc / testsuite / obj-c++.dg / fsf-nsstring-format-1.mm
bloba5eaf3431f56bc532d7a6dd8bb8230995249a1bc
1 /* Check NSString format extensions.  */
2 /* { dg-do compile { target *-*-darwin* } } */
3 /* { dg-skip-if "" { *-*-* } { "-fgnu-runtime" } { "" } } */
4 /* { dg-options "-Wall" } */
6 #ifndef __CONSTANT_CFSTRINGS__
7 #error requires CFString
8 #endif
10 #ifdef __cplusplus
11 extern "C" {
12 #endif
13 extern int printf (const char *fmt, ...);
14 typedef const struct __CFString * CFStringRef;
16 #ifdef __cplusplus
18 #endif
20 @class NSString;
22 int s1 (NSString *fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */
23 /* A CFString can represent an NSString.  */
24 int s1a (CFStringRef fmt, ...) __attribute__((format(NSString, 1, 2))) ; /* OK */
25 /* But... it is possible that a CFString format might imply functionality that
26    is not present in objective-c.  */
27 int s1b (NSString *fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference" } */
29 int s2 (int a, NSString *fmt, ... ) __attribute__((format(__NSString__, 2, 3))) ; /* OK */
31 int s2a (int a, NSString *fmt, ... ) __attribute__((format(NSString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */
33 int s3 (const char *fmt, ... ) __attribute__((format(__NSString__, 1, 2))) ; /* { dg-error "format argument should be a .NSString. reference but a string was found" } */
34 int s4 (NSString *fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .NSString. reference but the format argument should be a string" } */
36 char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
37 NSString *s6 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
39 char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */
40 int s8 (NSString *dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */
42 char *s9 (int dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
43 NSString *s10 (int dum, NSString *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
45 void foo (void)
47   s1 (@"this format not checked %d %s", 3, 4);
48   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'" } */
49                         /* { dg-warning "too many arguments for format" "" { target *-*-* } .-1 } */
50   printf(s9 (1, (char *)"and so is this %d %d %s" , 3, 4, "hm"), 5, 6, 12); /* { dg-warning "format '%s' expects argument of type 'char.', but argument 4 has type 'int'" } */