aaron.ballman added a comment.

In D132266#3740013 <https://reviews.llvm.org/D132266#3740013>, @inclyc wrote:

> If some one use `%hhd` with an unmatched type argument. Should we emit 
> diagnose like
>
>   format specifies type 'int' but the argument has type 'WhateverType'
>
> instead of
>
>   format specifies type 'char' but the argument has type 'WhateverType'
>
> ?
>
> It's seems that there are many regression tests about this. Should we keep 
> the legacy behaviour?

I think we want the diagnostic to identify the target type from the format 
specifier along with the actual and promoted type (if relevant) of the argument 
that mismatches. e.g.,

  float f = 1.0f;
  printf("%hd", f);

I would expect this to say something like `format specifies type 'short' but 
the argument has type 'double' (promoted from 'float')`.

This way users know 1) what the type of the source argument is without hunting 
for it, 2) what the target type of the format specifier is without hunting down 
what the specifiers mean, 3) what the actual mismatching type is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132266

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to