In the case that `win_t` is an `unsigned short` (e.g. on Windows), we would
previously incorrectly diagnose the conversion because we would immediately
promote the argument type from `wint_t` (aka `unsigned short`) to `int` before
checking if the type matched. This should repair the Windows hosted bots.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@342565
91177308-0d34-0410-b5e6-
96231b3b80d8
}
case WIntTy: {
+ QualType WInt = C.getCanonicalType(C.getWIntType()).getUnqualifiedType();
- QualType PromoArg =
- argTy->isPromotableIntegerType()
- ? C.getPromotedIntegerType(argTy) : argTy;
+ if (C.getCanonicalType(argTy).getUnqualifiedType() == WInt)
+ return Match;
- QualType WInt = C.getCanonicalType(C.getWIntType()).getUnqualifiedType();
+ QualType PromoArg = argTy->isPromotableIntegerType()
+ ? C.getPromotedIntegerType(argTy)
+ : argTy;
PromoArg = C.getCanonicalType(PromoArg).getUnqualifiedType();
// If the promoted argument is the corresponding signed type of the
printf("%I32d", i32); // expected-warning{{'I32' length modifier is not supported by ISO C}}
printf("%I64d", i64); // expected-warning{{'I64' length modifier is not supported by ISO C}}
printf("%wc", c); // expected-warning{{'w' length modifier is not supported by ISO C}}
- // expected-warning@-1{{format specifies type 'wint_t' (aka 'unsigned short') but the argument has type 'wchar_t' (aka 'unsigned short')}}
printf("%Z", p); // expected-warning{{'Z' conversion specifier is not supported by ISO C}}
}
}
void w_test(wchar_t c, wchar_t *s) {
- printf("%wc", c); // expected-warning{{format specifies type 'wint_t' (aka 'unsigned short') but the argument has type 'wchar_t' (aka 'unsigned short')}}
+ printf("%wc", c);
printf("%wC", c);
printf("%C", c);
printf("%ws", s);
void pr7981(wint_t c, wchar_t c2) {
printf("%lc", c); // no-warning
printf("%lc", 1.0); // expected-warning{{the argument has type 'double'}}
+#if __WINT_WIDTH__ == 4
printf("%lc", (char) 1); // no-warning
+#else
+ printf("%lc", (char) 1); // expected-warning{{the argument has type 'char'}}
+#endif
printf("%lc", &c); // expected-warning{{the argument has type 'wint_t *'}}
// If wint_t and wchar_t are the same width and wint_t is signed where
// wchar_t is unsigned, an implicit conversion isn't possible.