Re: [RFC PATCH] Make "bad constant expression" a warning, not an error

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

 



I object.

You should fix it in the parser side. When the parser call get expression
value, it really expect to get back a constant value. Make it return the
largest value on error is just wrong.

Chris

On Fri, Jun 20, 2008 at 8:08 AM, Pavel Roskin <proski@xxxxxxx> wrote:
> Do the same to "bad integer constant expression".  It's still possible
> to continue parsing the code if those are not constant.  To be on the
> safe side, assume the actual value to be the largest value for the
> type.
> ---
>
>  expand.c |   12 +++++++-----
>  1 files changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/expand.c b/expand.c
> index 032f0c5..12a8989 100644
> --- a/expand.c
> +++ b/expand.c
> @@ -1201,18 +1201,20 @@ static long long __get_expression_value(struct expression *expr, int strict)
>                expression_error(expr, "bad constant expression type");
>                return 0;
>        }
> +
> +       mask = 1ULL << (ctype->bit_size-1);
> +
>        expand_expression(expr);
>        if (expr->type != EXPR_VALUE) {
> -               expression_error(expr, "bad constant expression");
> -               return 0;
> +               warning(expr->pos, "bad constant expression");
> +               return mask;
>        }
>        if (strict && bad_integer_constant_expression(expr)) {
> -               expression_error(expr, "bad integer constant expression");
> -               return 0;
> +               warning(expr->pos, "bad integer constant expression");
> +               return mask;
>        }
>
>        value = expr->value;
> -       mask = 1ULL << (ctype->bit_size-1);
>
>        if (value & mask) {
>                while (ctype->type != SYM_BASETYPE)
>
> --
> Regards,
> Pavel Roskin
> --
> 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
>
--
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