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) { |
Hans Wennborg | f856264 | 2012-03-09 10:10:54 +0000 | [diff] [blame^] | 8 | scanf("%as", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */ |
| 9 | scanf("%a[abc]", sp); /* expected-warning{{'a' length modifier is not supported by ISO C}} */ |
Hans Wennborg | d02deeb | 2011-12-15 10:25:47 +0000 | [diff] [blame] | 10 | |
| 11 | /* TODO: Warn that the 'a' conversion specifier is a C99 feature. */ |
| 12 | scanf("%a", fp); |
| 13 | scanf("%afoobar", fp); |
| 14 | printf("%a", 1.0); |
| 15 | printf("%as", 1.0); |
| 16 | printf("%aS", 1.0); |
| 17 | printf("%a[", 1.0); |
| 18 | printf("%afoo", 1.0); |
| 19 | |
| 20 | scanf("%da", ip); |
Hans Wennborg | 37969b7 | 2012-01-12 17:11:12 +0000 | [diff] [blame] | 21 | |
| 22 | /* Test argument type check for the 'a' length modifier. */ |
Hans Wennborg | 7651742 | 2012-02-22 10:17:01 +0000 | [diff] [blame] | 23 | scanf("%as", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} |
Hans Wennborg | f856264 | 2012-03-09 10:10:54 +0000 | [diff] [blame^] | 24 | expected-warning{{'a' length modifier is not supported by ISO C}} */ |
Hans Wennborg | 7651742 | 2012-02-22 10:17:01 +0000 | [diff] [blame] | 25 | scanf("%aS", fp); /* expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}} |
Hans Wennborg | f856264 | 2012-03-09 10:10:54 +0000 | [diff] [blame^] | 26 | expected-warning{{'a' length modifier is not supported by ISO C}} |
| 27 | expected-warning{{'S' conversion specifier is not supported by ISO C}} */ |
Hans Wennborg | 7651742 | 2012-02-22 10:17:01 +0000 | [diff] [blame] | 28 | scanf("%a[abc]", fp); /* expected-warning{{format specifies type 'char **' but the argument has type 'float *'}} |
Hans Wennborg | f856264 | 2012-03-09 10:10:54 +0000 | [diff] [blame^] | 29 | expected-warning{{'a' length modifier is not supported by ISO C}} */ |
Hans Wennborg | d02deeb | 2011-12-15 10:25:47 +0000 | [diff] [blame] | 30 | } |