[cfe-dev] Static Analysis Warning?
Bill Wendling
wendling at apple.com
Fri Aug 27 15:52:22 PDT 2010
On Aug 27, 2010, at 3:46 PM, Jordy Rose wrote:
> On Fri, 27 Aug 2010 17:39:12 -0500, Michael Price - Dev
> <michael.b.price.dev at gmail.com> wrote:
>> Consider:
>>
>> #define FLOOR 1
>> #define CEILING 1
>>
>> int main (int argc, const char * argc[])
>> {
>> printf("Hello, World! %d\n", useFloor() ? FLOOR : CEILING);
>>
>> return 0;
>> }
>>
>> where useFloor() returns a bool.
>>
>> I would NOT want that flagged with a warning.
>
> Good point, Michael. I think this would be more useful as a Sema warning
> about identical expressions for both results of a ?:, not a value-sensitive
> analyzer report. (Taking macros into account, of course; only warn if
> neither expression involves a macro or both use identical macros.)
I agree that it's a good point. I don't thinks that this would make a good compiler warning, but would be limited to the static analyzer. The analyzer has information about whether something comes from a macro, enum, inlined function, etc. I would vote for it emitting a warning for the same enums coming from the same enum type.
-bw
More information about the cfe-dev
mailing list