Re: [PATCH v6] sparse: add support for _Static_assert

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 9, 2017 at 10:42 AM, Lance Richardson <lrichard@xxxxxxxxxx> wrote:
>>             if (cond && cond->type == EXPR_VALUE &&
>> !const_expression_value(cond))
>
> This doesn't work for some cases.  E.g. for an expression like
> "sizeof(struct s) == 16", cond->type is EXPR_COMPARE before
> const_expression_value(cond) is called and is only set to EXPR_VALUE after
> the call has reduced the expression to a value. I was looking at this test
> as a way to verify that const_expression_value() was successful.


OK. That make sense.


>>
>> > +               sparse_error(cond->pos, "static assertion failed: %s",
>> > +                            show_string(message->string));
>>
>> Then there:
>>            message ?  show_string(message->string) : "");
>>
>> I think the assert failed without message string, we already report
>> the error on empty string
>> expression. Raising the assert here might be acceptable?
>>
>
> I was taking the more conservative approach of not assuming anything
> about the interpretation of the two expressions if the assertion is not
> syntactically correct. This seems like a better way to go.

That is fine you chose that way.

Chris
--
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Newbies FAQ]     [LKML]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Trinity Fuzzer Tool]

  Powered by Linux