[Bug preprocessor/71102] New: _Pragma("GCC warning ...") should concatenate string literals
zackw at panix dot com
gcc-bugzilla@gcc.gnu.org
Fri May 13 12:31:00 GMT 2016
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=71102
Bug ID: 71102
Summary: _Pragma("GCC warning ...") should concatenate string
literals
Product: gcc
Version: 6.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: preprocessor
Assignee: unassigned at gcc dot gnu.org
Reporter: zackw at panix dot com
Target Milestone: ---
Consider
#define warn1(msg) _Pragma (#msg)
#define warn(msg) warn1 (GCC warning msg)
#define lengthy_explanation(name) \
"This is a long explanation about why `" #name "' is deprecated."
#define SYMBOL warn(lengthy_explanation(SYMBOL)) 1
int main(void) { return SYMBOL; }
With gcc (5 and 6), the warning message printed is
test.c:9:13: warning: This is a long explanation about why `
which is obviously not what was wanted. (The column position of the diagnostic
is also wrong, but that's secondary.) One could theoretically work around this
by not using string literals in lengthy_explanation() but that risks blowing up
in one's face if any of the words in the explanation happen to be macros (and
also I'm not sure how I would get the quotation marks in there).
n.b. clang gets this right:
test.c:9:25: warning: This is a long explanation about why `SYMBOL' is
deprecated. [-W#pragma-messages]
More information about the Gcc-bugs
mailing list