|
| 1 | +// UNSUPPORTED: !darwin |
| 2 | + |
| 3 | +// Test calls to variadic functions in checked scopes. |
| 4 | +// Some -Wformat error messages are different between Linux, Windows |
| 5 | +// and MacOS. This file contains MacOS specific ests. The common |
| 6 | +// tests are in variadic-functions.c. |
| 7 | + |
| 8 | +// RUN: %clang_cc1 -fcheckedc-extension -verify \ |
| 9 | +// RUN: -verify-ignore-unexpected=note %s |
| 10 | + |
| 11 | +int printf(const char *format : itype(_Nt_array_ptr<const char>), ...); |
| 12 | +int MyPrintf(const char *format : itype(_Nt_array_ptr<const char>), ...) |
| 13 | + __attribute__((format(printf, 1, 2))); |
| 14 | + |
| 15 | +int scanf(const char *format : itype(_Nt_array_ptr<const char>), ...); |
| 16 | +int MyScanf(const char *format : itype(_Nt_array_ptr<const char>), ...) |
| 17 | + __attribute__((format(scanf, 1, 2))); |
| 18 | + |
| 19 | +void f1 (_Nt_array_ptr<char> p) { |
| 20 | +_Checked { |
| 21 | + printf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} |
| 22 | + MyPrintf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} |
| 23 | + scanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} |
| 24 | + MyScanf("%Z", p); // expected-error {{invalid conversion specifier 'Z'}} |
| 25 | + |
| 26 | + printf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} |
| 27 | + MyPrintf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} |
| 28 | + scanf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} expected-error {{format specifies type 'long long *' but the argument has type 'long long'}} |
| 29 | + MyScanf("%Li", (long long) 42); // expected-error {{length modifier 'L' results in undefined behavior or no effect with 'i' conversion specifier}} expected-error {{format specifies type 'long long *' but the argument has type 'long long'}} |
| 30 | +} |
| 31 | +} |
0 commit comments