You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[Sema] Warning for _Float16 passed to format specifier '%f'
According to https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2844.pdf,
there are no default argument promotions for _FloatN types.
A warning is needed to notice user to promote _Float16 to double
explicitly, and then pass it to format specifier '%f', which is
consistent with GCC.
voidl(char*a, _Float16b) __attribute__((format(printf, 1, 2))); // expected-warning {{GCC requires a function with the 'format' attribute to be variadic}}
voidz(char*str, intc, ...) __attribute__((format(strftime, 1, 2))); // expected-error {{strftime format attribute requires 3rd parameter to be 0}}
21
23
@@ -93,6 +95,11 @@ void call_nonvariadic(void) {
93
95
d3("%s", 123); // expected-warning{{format specifies type 'char *' but the argument has type 'int'}}
94
96
}
95
97
98
+
voidcall_no_default_promotion(void) {
99
+
a("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}}
100
+
l("%f", (_Float16)1.0); // expected-warning{{format specifies type 'double' but the argument has type '_Float16'}}
101
+
}
102
+
96
103
__attribute__((format(printf, 1, 2)))
97
104
voidforward_fixed(constchar*fmt, _Boolb, chari, shortj, intk, floatl, doublem) { // expected-warning{{GCC requires a function with the 'format' attribute to be variadic}}
0 commit comments