[PATCH] D132568: [clang][Sema] check default argument promotions for printf

YingChi Long via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 26 04:31:57 PDT 2022


inclyc added inline comments.


================
Comment at: clang/lib/AST/FormatString.cpp:367
+        case BuiltinType::Char_U:
+        case BuiltinType::Bool:
+          return Match;
----------------
aaron.ballman wrote:
> inclyc wrote:
> > aaron.ballman wrote:
> > > Isn't this a match promotion as well? e.g. `printf("%hhd", (_Bool)0);` where the `_Bool` is promoted to `int` but then cast back down to a char type (which seems rather unlikely to be a type confusion issue).
> > Hmm? `_Bool` just matches `AnyCharTy` perfectly. `MatchPromotion` means the types having **different** length and they can be considered as "partially matched" because of promotions). 
> > 
> > Isn't `_Bool`  and `AnyChar`  here just have the same length?
> > Hmm? _Bool just matches AnyCharTy perfectly. MatchPromotion means the types having different length and they can be considered as "partially matched" because of promotions).
> >
> > Isn't _Bool and AnyChar here just have the same length?
> 
> `_Bool` is not a character type, so it doesn't match `AnyCharTy` perfectly. The size can be the same but they're still different types.
I've add `case BuiltinType::Bool:` back to preserve https://reviews.llvm.org/D66856


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D132568/new/

https://reviews.llvm.org/D132568



More information about the cfe-commits mailing list