[cfe-commits] [patch] Warn in string literal + integral
Jeff Walden
jwalden+clang at mit.edu
Fri Mar 2 20:12:56 PST 2012
For what it's worth, this warning triggers twice when building the SpiderMonkey JavaScript compiler, in two bits of near-adjacent code that look like this:
> if (attrs) {
> int first = 1;
> fputs("(", fp);
> #define DUMP_ATTR(name, display) if (attrs & JSPROP_##name) fputs(" " #display + first, fp), first = 0
> DUMP_ATTR(ENUMERATE, enumerate);
> DUMP_ATTR(READONLY, readonly);
> DUMP_ATTR(PERMANENT, permanent);
> DUMP_ATTR(GETTER, getter);
> DUMP_ATTR(SETTER, setter);
> DUMP_ATTR(SHARED, shared);
> #undef DUMP_ATTR
> fputs(") ", fp);
> }
(the idea being to print "(enumerate)", "(enumerate readonly)", or whatever depending on attrs; the other instance does likewise for a flags field)
I'm not inclined to defend this technique, although it's not too bad as tricks go. I think the new warning is a good thing, and I'm perfectly happy to switch those two instances to use &()[] instead. But it seems worth mentioning here as another data point.
Jeff
More information about the cfe-commits
mailing list