AndyG added a comment.

Yes, but only for the "data argument not used" warning.  All other warnings are 
unaffected by the change, for example:

  test.cpp:9:51: warning: format specifies type 'char *' but the argument has 
type 'int' [-Wformat]                                                  
      printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
                        ~~                          ^~~~
                        %d
  test.cpp:9:30: warning: more '%' conversions than data arguments [-Wformat]
      printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
                              ~^
  test.cpp:9:57: warning: format specifies type 'int' but the argument has type 
'const char *' [-Wformat]
      printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
                                          ~~              ^~~
                                          %s
  test.cpp:9:45: warning: more '%' conversions than data arguments [-Wformat]
      printf(minimal ? "%s %s %i\n" : "%i %i %i\n", code, msg);
                                             ~^
  4 warnings generated.

But, as you observed, for the unused argument it only warns for the first 
instance:

  test.cpp:9:53: warning: data argument not used by format string 
[-Wformat-extra-args]
      printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
                                ~~~~~~~~~             ^
  1 warning generated.

This is in comparison to the original diagnostic:

  test.cpp:9:48: warning: data argument not used by format string 
[-Wformat-extra-args]
      printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
                       ~~~~~~                    ^
  test.cpp:9:53: warning: data argument not used by format string 
[-Wformat-extra-args]
      printf(minimal ? "%i\n" : "%i %s\n", code, msg, msg);
                                ~~~~~~~~~             ^
  2 warnings generated.

However, may I ask what the specific concern is here?  If this diagnostic 
appears then the user knows that **all** the strings do not use this and any 
subsequent argument.  Effectively the original situation doesn't really tell 
the user anything more useful - it only duplicates the warning and actually, as 
can be seen above, it is potentially confusing since it suggests two positions 
for the unused argument(s).  Compare this with the new diagnostic which shows 
only one string, and this string is the first string which uses the most 
arguments, so it is very clear which arguments are not used.

What do you think?  Is this an adequate argument?


http://reviews.llvm.org/D15636



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

Reply via email to