| 1 |
//RUN: %clang_cc1 -fsyntax-only -verify %s |
| 2 |
|
| 3 |
int printf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"))); // no-error |
| 4 |
int myprintf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"))); // expected-error {{'modular_format' attribute requires 'format' attribute}} |
| 5 |
|
| 6 |
int string_impl_fn(const char *fmt, ...) __attribute__((modular_format("__modular_printf", "__printf", "float"), format(printf, 1, 2))); // expected-error {{'modular_format' attribute requires parameter 1 to be an identifier}} |
| 7 |
|
| 8 |
int lprintf(const char *fmt, ...) __attribute__((modular_format(__modular_printf, L"__printf", L"float"), format(printf, 1, 2))); |
| 9 |
// expected-warning@-1 2{{encoding prefix 'L' on an unevaluated string literal has no effect}} |
| 10 |
|
| 11 |
int dupe(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float", "int", "float"), format(printf, 1, 2))); // expected-error {{duplicate aspect 'float' in 'modular_format' attribute}} |
| 12 |
int multi_dupe(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float", "int", "float", "int"), format(printf, 1, 2))); // expected-error {{duplicate aspect 'float' in 'modular_format' attribute}} \ |
| 13 |
// expected-error {{duplicate aspect 'int' in 'modular_format' attribute}} |
| 14 |
|
| 15 |
// Test with multiple identical attributes on the same declaration. |
| 16 |
int same_attr(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"), modular_format(__modular_printf, "__printf", "float"), format(printf, 1, 2))); // no-warning |
| 17 |
|
| 18 |
// Test with multiple different attributes on the same declaration. |
| 19 |
int diff_attr(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"), format(printf, 1, 2), modular_format(__modular_printf, "__printf", "int"))); // expected-error {{attribute 'modular_format' is already applied with different arguments}} expected-note {{conflicting attribute is here}} |
| 20 |
|
| 21 |
int diff_attr2(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"), format(printf, 1, 2), modular_format(__modular_printf, "__other", "float"))); // expected-error {{attribute 'modular_format' is already applied with different arguments}} expected-note {{conflicting attribute is here}} |
| 22 |
|
| 23 |
int diff_attr3(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"), format(printf, 1, 2), modular_format(__other, "__printf", "float"))); // expected-error {{attribute 'modular_format' is already applied with different arguments}} expected-note {{conflicting attribute is here}} |
| 24 |
|
| 25 |
// Test with same attributes but different aspect order. |
| 26 |
int diff_order(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float", "int"), format(printf, 1, 2), modular_format(__modular_printf, "__printf", "int", "float"))); // no-error |
| 27 |
|
| 28 |
// Test with multiple different attributes on a declaration and a redeclaration |
| 29 |
int redecl(const char *fmt, ...) __attribute__((format(printf, 1, 2))); // no-error |
| 30 |
int redecl(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "float"))); // expected-note {{conflicting attribute is here}} |
| 31 |
int redecl(const char *fmt, ...) __attribute__((modular_format(__modular_printf, "__printf", "int"))); // expected-error {{attribute 'modular_format' is already applied with different arguments}} |