All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cocci] coccinelle to rescue for "C++11 requires a space between literal and string macro"
@ 2018-08-28 21:18 Felix Blyakher
  2018-08-28 22:19 ` Julia Lawall
  0 siblings, 1 reply; 5+ messages in thread
From: Felix Blyakher @ 2018-08-28 21:18 UTC (permalink / raw)
  To: cocci

Hello coccinelle experts,

I'm working with the legacy code and with newish gcc 7.3 hit the following warning:

warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
 #define PADARG64 "0x%016"QUAD"x"
                  ^

where QUAD is a platform dependent string, thus the macro.

The string concatenation works in C OK for this code, though, gcc rightfully complains
about required space and wants it to be:

 #define PADARG64 "0x%016" QUAD "x"

The code like this is sprinkled across huge code base, mostly in printf-like statements,
and some in defines like above to be used in printf-like statements.

I'd like to use coccinelle to change the code globally.
I was trying something like (I know it may have false positive, just need to get something for starter):


@@
Identifier I;
@@

-"I"
+" I "

but spatch complains and doesn't seem is going to do what I need:

""
init_defs_builtins: /usr/lib/coccinelle/standard.h
@rule starting on line 1@
Identifier  I;
@@

-"I"
  >>> " I "



grep tokens
No query
No query
warning: rule starting on line 1: metavariable I not used in the - or context code
""

Any good hint on how to approach this issue.

Thanks,
Felix
The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Quantum. Quantum reserves the right to have electronic communications, including email and attachments, sent across its networks filtered through security software programs and retain such messages in order to comply with applicable data security and retention requirements. Quantum is not responsible for the proper and complete transmission of the substance of this communication or for any delay in its receipt.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-08-30 16:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-28 21:18 [Cocci] coccinelle to rescue for "C++11 requires a space between literal and string macro" Felix Blyakher
2018-08-28 22:19 ` Julia Lawall
2018-08-29 16:25   ` Felix Blyakher
2018-08-29 16:32     ` Julia Lawall
     [not found]   ` <c78ab16d-c26b-9a90-1989-c5a91e276e67@users.sourceforge.net>
2018-08-30 16:51     ` [Cocci] Checking support for the analysis of preprocessor definitions Julia Lawall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.