Make "bad constant expression" a warning, not an error
RFC PATCH 1/1 Make "bad constant expression" a warning, not an error
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(-)
expand.c +7 -5
@@ -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 )
Signature · 2 lines
Regards, Pavel Roskin
Christopher Li
maintainerI 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
Quoted 48 lines · Pavel Roskin
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(-)expand.c +7
-6@@ -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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html