From 17d23165ffa88ad006418be8e1dcf5f649c6ff91 Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sat, 10 May 2008 12:18:24 +0000 Subject: tree-cfg.c (valid_fixed_convert_types_p): New function. gcc/ * tree-cfg.c (valid_fixed_convert_types_p): New function. (verify_gimple_expr): Handle FIXED_CONVERT_EXPR. From-SVN: r135143 --- gcc/tree-cfg.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'gcc/tree-cfg.c') diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 340c7a2..ed52826 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -3598,6 +3598,18 @@ one_pointer_to_useless_type_conversion_p (tree dest, tree src_obj) return false; } +/* Return true if TYPE1 is a fixed-point type and if conversions to and + from TYPE2 can be handled by FIXED_CONVERT_EXPR. */ + +static bool +valid_fixed_convert_types_p (tree type1, tree type2) +{ + return (FIXED_POINT_TYPE_P (type1) + && (INTEGRAL_TYPE_P (type2) + || SCALAR_FLOAT_TYPE_P (type2) + || FIXED_POINT_TYPE_P (type2))); +} + /* Verify the GIMPLE expression EXPR. Returns true if there is an error, otherwise false. */ @@ -3654,6 +3666,27 @@ verify_gimple_expr (tree expr) return false; } + case FIXED_CONVERT_EXPR: + { + tree op = TREE_OPERAND (expr, 0); + if (!is_gimple_val (op)) + { + error ("invalid operand in conversion"); + return true; + } + + if (!valid_fixed_convert_types_p (type, TREE_TYPE (op)) + && !valid_fixed_convert_types_p (TREE_TYPE (op), type)) + { + error ("invalid types in fixed-point conversion"); + debug_generic_expr (type); + debug_generic_expr (TREE_TYPE (op)); + return true; + } + + return false; + } + case FLOAT_EXPR: { tree op = TREE_OPERAND (expr, 0); -- cgit v1.1