Hans Wennborg | 37969b7 | 2012-01-12 17:11:12 +0000 | [diff] [blame^] | 1 | /* RUN: %clang_cc1 -fsyntax-only -verify -triple i386-apple-darwin9 -pedantic -std=c89 %s |
Hans Wennborg | d02deeb | 2011-12-15 10:25:47 +0000 | [diff] [blame] | 2 | */ |
| 3 | |
| 4 | int scanf(const char * restrict, ...); |
| 5 | int printf(const char *restrict, ...); |
| 6 | |
| 7 | void foo(char **sp, float *fp, int *ip) { |
| 8 | /* TODO: Warn that the 'a' length modifier is an extension. */ |
| 9 | scanf("%as", sp); |
Hans Wennborg | 28058d1 | 2012-01-12 15:07:16 +0000 | [diff] [blame] | 10 | scanf("%a[abc]", sp); |
Hans Wennborg | d02deeb | 2011-12-15 10:25:47 +0000 | [diff] [blame] | 11 | |
| 12 | /* TODO: Warn that the 'a' conversion specifier is a C99 feature. */ |
| 13 | scanf("%a", fp); |
| 14 | scanf("%afoobar", fp); |
| 15 | printf("%a", 1.0); |
| 16 | printf("%as", 1.0); |
| 17 | printf("%aS", 1.0); |
| 18 | printf("%a[", 1.0); |
| 19 | printf("%afoo", 1.0); |
| 20 | |
| 21 | scanf("%da", ip); |
Hans Wennborg | 37969b7 | 2012-01-12 17:11:12 +0000 | [diff] [blame^] | 22 | |
| 23 | /* Test argument type check for the 'a' length modifier. */ |
| 24 | scanf("%as", fp); /* expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} */ |
| 25 | scanf("%aS", fp); /* expected-warning{{conversion specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} */ |
| 26 | scanf("%a[abc]", fp); /* expected-warning{{conversion specifies type 'char **' but the argument has type 'float *'}} */ |
Hans Wennborg | d02deeb | 2011-12-15 10:25:47 +0000 | [diff] [blame] | 27 | } |