Nathan-Huckleberry added a comment.

In D66186#1630427 <>, @aaron.ballman 

> There was a request in the linked bug for some code archaeology to see why 
> this behavior exists in the first place. What were the results of that? I'm 
> not opposed to the patch, but I would like to understand why it behaves the 
> way it does.

Since printf is a variadic function, integral argument types are promoted to 
int. The warning code runs the matchesType check twice, once to check if the 
promoted type (int) is able to be printed with the format and once to check if 
the original type (char) is able to be printed with the format.

`printf("%d", [char])` is caught by the first case
`printf("%hhd", [char])` is caught by the second case.

`printf("%hd", [char])` is a warning because an exception has not been made for 
that case.

  rG LLVM Github Monorepo


cfe-commits mailing list

Reply via email to