OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [gcc.dg/] [darwin-cfstring-format-1.c] - Blame information for rev 749

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 689 jeremybenn
/* Check CFString format extensions.  */
2
/* { dg-do compile { target *-*-darwin* } } */
3
/* { dg-options "-Wall" } */
4
 
5
extern int printf (const char *fmt, ...);
6
 
7
typedef const struct __CFString * CFStringRef;
8
 
9
#ifdef __CONSTANT_CFSTRINGS__
10
#define CFSTR(cStr)  ((CFStringRef) __builtin___CFStringMakeConstantString ("" cStr ""))
11
#else
12
#error requires CFString
13
#endif
14
 
15
int s1 (CFStringRef fmt, ...) __attribute__((format(CFString, 1, 2))) ; /* OK */
16
int s2 (int a, CFStringRef fmt, ... ) __attribute__((format(__CFString__, 2, 3))) ; /* OK */
17
 
18
int s2a (int a, CFStringRef fmt, ... ) __attribute__((format(CFString, 2, 2))) ; /* { dg-error "format string argument follows the args to be formatted" } */
19
 
20
int s3 (const char *fmt, ... ) __attribute__((format(__CFString__, 1, 2))) ; /* { dg-error "format argument should be a .CFString. reference but a string was found" } */
21
int s4 (CFStringRef fmt, ... ) __attribute__((format(printf, 1, 2))) ; /* { dg-error "found a .CFStringRef. but the format argument should be a string" } */
22
 
23
char *s5 (char dum, char *fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
24
CFStringRef s6 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* OK */
25
 
26
char *s7 (int dum, void *fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "format string argument is not a string type" } */
27
int s8 (CFStringRef dum, CFStringRef fmt1, ... ) __attribute__((format_arg(2))) ; /* { dg-error "function does not return string type" } */
28
 
29
void foo (void)
30
{
31
  CFStringRef notchk = CFSTR ("here is an unchecked %d %s string");
32
  s1 (notchk, 5, 6, 7);
33
  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." } */
34
                        /* { dg-warning "too many arguments for format" "" { target *-*-* } 33 } */
35
  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." } */
36
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.