From 00f5f2cd8556eed4f6ae41a59e51f0ec8360f17d Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 4 Sep 2015 17:24:06 -0400 Subject: [PATCH 39/56] FIXME: undo the ' Enough hacking on SOURCE_RANGE folding to get format strings to be able to parse ' --- gcc/c-family/c-common.c | 6 +----- gcc/tree.h | 36 +++++++++++++++++++++++++----------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/gcc/c-family/c-common.c b/gcc/c-family/c-common.c index 1cb576a..a430bee 100644 --- a/gcc/c-family/c-common.c +++ b/gcc/c-family/c-common.c @@ -1605,10 +1605,6 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, appropriate in any particular case. */ gcc_unreachable (); - case SOURCE_RANGE: - ret = TREE_OPERAND (expr, 0); - goto out; - default: /* Various codes may appear through folding built-in functions and their arguments. */ @@ -1629,7 +1625,7 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, if (ret != expr) { protected_set_expr_location (ret, loc); - if (CAN_HAVE_RANGE_P (ret)) + if (IS_EXPR_CODE_CLASS (kind)) set_source_range (&ret, old_range.m_start, old_range.m_finish); } return ret; diff --git a/gcc/tree.h b/gcc/tree.h index 18c9648..3e1191c 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -453,11 +453,11 @@ extern void omp_clause_range_check_failed (const_tree, const char *, int, #define STRIP_TYPE_NOPS(EXP) \ while ((CONVERT_EXPR_P (EXP) \ - || TREE_CODE (EXP) == NON_LVALUE_EXPR \ - || is_redundant_source_range (EXP)) \ + || TREE_CODE (EXP) == NON_LVALUE_EXPR) \ && TREE_OPERAND (EXP, 0) != error_mark_node \ && (TREE_TYPE (EXP) \ - == TREE_TYPE (TREE_OPERAND (EXP, 0)))) \ + == TREE_TYPE (TREE_OPERAND (EXP, 0))) \ + && (is_redundant_nop_range (EXP))) \ (EXP) = TREE_OPERAND (EXP, 0) /* Remove unnecessary type conversions according to @@ -5169,20 +5169,34 @@ set_source_range (tree *expr, source_range src_range); /* FIXME. */ inline bool -is_redundant_source_range (tree outer) +is_redundant_nop_range (tree outer) { - if (TREE_CODE (outer) == SOURCE_RANGE) + if (CONVERT_EXPR_P (outer)) { +#if 0 tree inner = TREE_OPERAND (outer, 0); - if (EXPR_HAS_LOCATION (inner)) - /* The inner can express a range; outer is redundant. */ - return true; - - return false; + if (!EXPR_HAS_LOCATION (inner)) + /* The NOP_EXPR expresses a source location range. */ + return false; + + if (CONVERT_EXPR_P (inner)) + { + /* Don't strip non-equal ranges. */ + if (EXPR_LOCATION_RANGE (outer).m_start + != EXPR_LOCATION_RANGE (inner).m_start) + return false; + if (EXPR_LOCATION_RANGE (outer).m_finish + != EXPR_LOCATION_RANGE (inner).m_finish) + return false; + } + else + /* Preserve the location. */ + return false; +#endif } - return false; + return true; } extern void gt_ggc_mx (tree &); -- 1.8.5.3