Arithmetic constant expressions may be either of (6.6(8)): - integer constant expressions - floating point constants or any arithmetic expression build up from them. Furthermore, casts with arithmetic destination types preserve arithmetic constness. Arithmetic constant expressions may be used as initializers for objects of static storage duration. Introduce a new constexpr_flag CONSTEXPR_FLAG_ARITH_CONST_EXPR. Modify CONSTEXPR_FLAG_INT_CONST_EXPR_SET_MASK and CONSTEXPR_FLAG_FP_CONST_SET_MASK to also include that new bit. Thus, whenever an integer constant expression or a floating point constant is recognized, it is automatically tagged as an arithmetic constant expression. Note that everything has already been set up such that the new CONSTEXPR_FLAG_ARITH_CONST_EXPR flag propagates nicely from subexpressions to parent expressions at evaluation. Signed-off-by: Nicolai Stange <nicstange@xxxxxxxxx> --- expression.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/expression.h b/expression.h index 408382e..b85f1b1 100644 --- a/expression.h +++ b/expression.h @@ -96,19 +96,23 @@ enum constexpr_flag { /* * A constant expression in the sense of [6.6]: * - integer constant expression [6.6(6)] + * - arithmetic constant expression [6.6(8)] */ CONSTEXPR_FLAG_INT_CONST_EXPR = (1 << 4), + CONSTEXPR_FLAG_ARITH_CONST_EXPR = (1 << 5), }; -#define CONSTEXPR_FLAG_INT_CONST_EXPR_SET_MASK \ - (CONSTEXPR_FLAG_INT_CONST_EXPR) +/* integer constant expression => arithmetic constant expression */ +#define CONSTEXPR_FLAG_INT_CONST_EXPR_SET_MASK \ + (CONSTEXPR_FLAG_INT_CONST_EXPR | CONSTEXPR_FLAG_ARITH_CONST_EXPR) /* integer constant => integer constant expression */ #define CONSTEXPR_FLAG_INT_CONST_SET_MASK \ (CONSTEXPR_FLAG_INT_CONST | CONSTEXPR_FLAG_INT_CONST_EXPR_SET_MASK) -#define CONSTEXPR_FLAG_FP_CONST_SET_MASK \ - (CONSTEXPR_FLAG_FP_CONST) +/* floating point constant => arithmetic constant expression */ +#define CONSTEXPR_FLAG_FP_CONST_SET_MASK \ + (CONSTEXPR_FLAG_FP_CONST | CONSTEXPR_FLAG_ARITH_CONST_EXPR) /* enumeration constant => integer constant expression */ #define CONSTEXPR_FLAG_ENUM_CONST_SET_MASK \ -- 2.7.0 -- 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