This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: C++: is there a good way to check for a valid no-op conversion?


On 10/17/18, Martin Sebor <msebor@gmail.com> wrote:
> On 10/16/2018 02:06 PM, David Malcolm wrote:
>> I've been extending -fopt-info to cover inlining, and I added a %S
>> format code to dump_printf which accepts a symtab_node *.
>>
>> Unfortunately, -Wformat doesn't like the fact that I'm passing in a
>> subclass pointer (cgraph_node *), e.g.:
>>
>> ipa-inline.c: In function ‘unsigned int early_inliner(function*)’:
>> ipa-inline.c:2769:21: error: format ‘%S’ expects argument of type
>> ‘symtab_node*’,
>> but argument 3 has type ‘cgraph_node*’ [-Werror=format=]
>> 2769 |        "Flattening %S\n", node);
>>       |                    ~^     ~~~~
>>       |                     |     |
>>       |                     |     cgraph_node*
>>       |                     symtab_node*
>>
>> I could fix this by changing my format converter so that explicitly
>> takes a cgraph_node *, but I wondered if it would be better to instead
>> teach -Wformat to accept non-virtual subclass pointers, so that %S can
>> handle symtab_node * and its two subclasses.
>
> It would have helped in the gcall* vs gimple* case as well.  It
> would be nice to teach -Wformat about these conversions in general.
> (on a somewhat related note, other than pedantic conformance, I
> don't think there is value in -Wformat complaining about %p with
> non-void* object pointer arguments either).

That sounds like something worth splitting out once there's a separate
-Wformat-pedantic flag as per bug 67479:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67479

>
> Martin
>
>>
>> Does this sound sane, and is there a conversion function I can call for
>> this case?  cp_convert_to_pointer seemed the closest match.
>>
>> Thanks
>> Dave
>>
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]