From d20188f3657465cf77dc8a8bd26b219022896a2f Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Wed, 29 May 2013 12:32:22 +0200 Subject: [PATCH] tree-cfg.c (verify_expr): Verify that BIT_FIELD_REF... 2013-05-29 Martin Jambor * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REF, REALPART_EXPR and IMAGPART_EXPR do not occur within other handled_components. From-SVN: r199405 --- gcc/ChangeLog | 5 +++++ gcc/tree-cfg.c | 59 +++++++++++++++++++++++++++++--------------------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 012c7c4af65..0e41fc2c15c 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2013-05-29 Martin Jambor + + * tree-cfg.c (verify_expr): Verify that BIT_FIELD_REF, REALPART_EXPR + and IMAGPART_EXPR do not occur within other handled_components. + 2013-05-29 Richard Biener * tree-vect-slp.c (vect_bb_slp_scalar_cost): Guard vinfo diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index fe76a8c3c2a..4b91a35f17d 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -2675,6 +2675,34 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) return t; } + if (TREE_CODE (t) == BIT_FIELD_REF) + { + if (!host_integerp (TREE_OPERAND (t, 1), 1) + || !host_integerp (TREE_OPERAND (t, 2), 1)) + { + error ("invalid position or size operand to BIT_FIELD_REF"); + return t; + } + if (INTEGRAL_TYPE_P (TREE_TYPE (t)) + && (TYPE_PRECISION (TREE_TYPE (t)) + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) + { + error ("integral result type precision does not match " + "field size of BIT_FIELD_REF"); + return t; + } + else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) + && TYPE_MODE (TREE_TYPE (t)) != BLKmode + && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) + != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) + { + error ("mode precision of non-integral result does not " + "match field size of BIT_FIELD_REF"); + return t; + } + } + t = TREE_OPERAND (t, 0); + /* Fall-through. */ case COMPONENT_REF: case ARRAY_REF: @@ -2697,32 +2725,13 @@ verify_expr (tree *tp, int *walk_subtrees, void *data ATTRIBUTE_UNUSED) if (TREE_OPERAND (t, 3)) CHECK_OP (3, "invalid array stride"); } - else if (TREE_CODE (t) == BIT_FIELD_REF) + else if (TREE_CODE (t) == BIT_FIELD_REF + || TREE_CODE (t) == REALPART_EXPR + || TREE_CODE (t) == IMAGPART_EXPR) { - if (!host_integerp (TREE_OPERAND (t, 1), 1) - || !host_integerp (TREE_OPERAND (t, 2), 1)) - { - error ("invalid position or size operand to BIT_FIELD_REF"); - return t; - } - if (INTEGRAL_TYPE_P (TREE_TYPE (t)) - && (TYPE_PRECISION (TREE_TYPE (t)) - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) - { - error ("integral result type precision does not match " - "field size of BIT_FIELD_REF"); - return t; - } - else if (!INTEGRAL_TYPE_P (TREE_TYPE (t)) - && !AGGREGATE_TYPE_P (TREE_TYPE (t)) - && TYPE_MODE (TREE_TYPE (t)) != BLKmode - && (GET_MODE_PRECISION (TYPE_MODE (TREE_TYPE (t))) - != TREE_INT_CST_LOW (TREE_OPERAND (t, 1)))) - { - error ("mode precision of non-integral result does not " - "match field size of BIT_FIELD_REF"); - return t; - } + error ("non-top-level BIT_FIELD_REF, IMAGPART_EXPR or " + "REALPART_EXPR"); + return t; } t = TREE_OPERAND (t, 0); -- 2.30.2