[cfe-commits] [Patch] -Wformat: properly handle length modifiers used with %n (Was: -Wformat: warn about using length modifiers with %n)

Peter Cooper peter_cooper at apple.com
Tue Aug 7 10:12:54 PDT 2012


Hi Hans,

This series of commits seems to be breaking the gcc test suite.  Could you please investigate?

The output we have is

gcc.dg/format/c90-printf-1.c   bad argument types (test for warnings, line 200)
gcc.dg/format/c90-printf-1.c  -DWIDE  bad argument types (test for warnings, line 200)
gcc.dg/format/c99-printf-1.c   %hhn plain char (test for warnings, line 195)
gcc.dg/format/c99-printf-1.c   %hhn unsigned char (test for warnings, line 196)
gcc.dg/format/c99-printf-1.c  -DWIDE  %hhn plain char (test for warnings, line 195)
gcc.dg/format/c99-printf-1.c  -DWIDE  %hhn unsigned char (test for warnings, line 196)

Please let me know if there's anything else you need for this.

Thanks,
Pete
On Aug 7, 2012, at 2:19 AM, Hans Wennborg <hans at chromium.org> wrote:

> On Mon, Aug 6, 2012 at 6:39 PM, Ted Kremenek <kremenek at apple.com> wrote:
>> This looks great.  One comment:
>> 
>>> std::string ArgType::getRepresentativeTypeName(ASTContext &C) const {
>>>   std::string S = getRepresentativeType(C).getAsString();
>>> -  if (Name && S != Name)
>>> -    return std::string("'") + Name + "' (aka '" + S + "')";
>>> +  std::string Alias;
>>> +  if (Name) {
>>> +    Alias = Name;
>>> +    if (Ptr)
>>> +      Alias += (Alias[Alias.size()-1] == '*') ? "*" : " *";
>>> +    if (S == Alias)
>>> +      Alias.clear();
>>> +  }
>>> +
>>> +  if (!Alias.empty())
>>> +    return std::string("'") + Alias + "' (aka '" + S + "')";
>>>   return std::string("'") + S + "'";
>>> }
>> 
>> Can you add some comments here, specifically around the string construction, that says what it is trying to accomplish?
>> 
>> Overall, the rest of it looks pretty obvious.  Nice clean refactoring, with a bunch of the expected checking logic.
> 
> Thanks! Landed r161403, r161407 (with extra comments) and r161408.
> 
> - Hans
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list