linux-sparse.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH] Make "bad constant expression" a warning, not an error
@ 2008-06-20 15:08 Pavel Roskin
  2008-06-20 22:52 ` Christopher Li
  0 siblings, 1 reply; 2+ messages in thread
From: Pavel Roskin @ 2008-06-20 15:08 UTC (permalink / raw)
  To: linux-sparse

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [RFC PATCH] Make "bad constant expression" a warning, not an error
  2008-06-20 15:08 [RFC PATCH] Make "bad constant expression" a warning, not an error Pavel Roskin
@ 2008-06-20 22:52 ` Christopher Li
  0 siblings, 0 replies; 2+ messages in thread
From: Christopher Li @ 2008-06-20 22:52 UTC (permalink / raw)
  To: Pavel Roskin; +Cc: linux-sparse

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@gnu.org> 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@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-06-20 22:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-20 15:08 [RFC PATCH] Make "bad constant expression" a warning, not an error Pavel Roskin
2008-06-20 22:52 ` Christopher Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).