[RFC PATCH 1/2] Allow casting to a restricted type if !restricted_value

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

 



If the operand of a cast to a restricted type is an unrestricted value,
 the cast should not produce a warning, since an equivalent implied cast
 (e.g. in an initialiser) would not do so.

Signed-off-by: Edward Cree <ecree@xxxxxxxxxxxxxx>
---
 evaluate.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/evaluate.c b/evaluate.c
index e350c0c..8e855b1 100644
--- a/evaluate.c
+++ b/evaluate.c
@@ -2771,7 +2771,7 @@ static struct symbol *evaluate_cast(struct expression *expr)
                t2 = unfoul(t2);

        if (t1 != t2) {
-               if (class1 & TYPE_RESTRICT)
+               if ((class1 & TYPE_RESTRICT) && restricted_value(target, t1))
                        warning(expr->pos, "cast to %s",
                                show_typename(t1));
                if (class2 & TYPE_RESTRICT)

The information contained in this message is confidential and is intended for the addressee(s) only. If you have received this message in error, please notify the sender immediately and delete the message. Unless you are an addressee (or authorized to receive for an addressee), you may not use, copy or disclose to anyone this message or any information contained in this message. The unauthorized use, disclosure, copying or alteration of this message is strictly prohibited.
--
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