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]

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


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.

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]