diff options
author | Marc Glisse <marc.glisse@inria.fr> | 2017-11-21 19:23:56 +0100 |
---|---|---|
committer | Marc Glisse <glisse@gcc.gnu.org> | 2017-11-21 18:23:56 +0000 |
commit | 1af4ebf5985ef2aaac13862654044d84a3cd7ae4 (patch) | |
tree | 6136f270e536b46d7d9de96d28e38794684035dd /gcc/doc | |
parent | ffb41aab7a9b8475e773b75fdebd194f4491c9db (diff) | |
download | gcc-1af4ebf5985ef2aaac13862654044d84a3cd7ae4.zip gcc-1af4ebf5985ef2aaac13862654044d84a3cd7ae4.tar.gz gcc-1af4ebf5985ef2aaac13862654044d84a3cd7ae4.tar.bz2 |
New POINTER_DIFF_EXPR
2017-11-21 Marc Glisse <marc.glisse@inria.fr>
gcc/c/
* c-fold.c (c_fully_fold_internal): Handle POINTER_DIFF_EXPR.
* c-typeck.c (pointer_diff): Use POINTER_DIFF_EXPR.
gcc/c-family/
* c-pretty-print.c (pp_c_additive_expression,
c_pretty_printer::expression): Handle POINTER_DIFF_EXPR.
gcc/cp/
* constexpr.c (cxx_eval_constant_expression,
potential_constant_expression_1): Handle POINTER_DIFF_EXPR.
* cp-gimplify.c (cp_fold): Likewise.
* error.c (dump_expr): Likewise.
* typeck.c (pointer_diff): Use POINTER_DIFF_EXPR.
gcc/
* doc/generic.texi: Document POINTER_DIFF_EXPR, update
POINTER_PLUS_EXPR.
* cfgexpand.c (expand_debug_expr): Handle POINTER_DIFF_EXPR.
* expr.c (expand_expr_real_2): Likewise.
* fold-const.c (const_binop, fold_addr_of_array_ref_difference,
fold_binary_loc): Likewise.
* match.pd (X-X, P+(Q-P), &D-P, (P+N)-P, P-(P+N), (P+M)-(P+N),
P-Q==0, -(A-B), X-Z<Y-Z, (X-Z)-(Y-Z), Z-X<Z-Y, (Z-X)-(Z-Y),
(A-B)+(C-A)): New transformations for POINTER_DIFF_EXPR, based on
MINUS_EXPR transformations.
* optabs-tree.c (optab_for_tree_code): Handle POINTER_DIFF_EXPR.
* tree-cfg.c (verify_expr, verify_gimple_assign_binary): Likewise.
* tree-inline.c (estimate_operator_cost): Likewise.
* tree-pretty-print.c (dump_generic_node, op_code_prio,
op_symbol_code): Likewise.
* tree-vect-stmts.c (vectorizable_operation): Likewise.
* vr-values.c (extract_range_from_binary_expr): Likewise.
* varasm.c (initializer_constant_valid_p_1): Likewise.
* tree.def: New tree code POINTER_DIFF_EXPR.
From-SVN: r255021
Diffstat (limited to 'gcc/doc')
-rw-r--r-- | gcc/doc/generic.texi | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/gcc/doc/generic.texi b/gcc/doc/generic.texi index a51cfd6..b03970f 100644 --- a/gcc/doc/generic.texi +++ b/gcc/doc/generic.texi @@ -1224,6 +1224,7 @@ the byte offset of the field, but should not be used directly; call @tindex TRUTH_OR_EXPR @tindex TRUTH_XOR_EXPR @tindex POINTER_PLUS_EXPR +@tindex POINTER_DIFF_EXPR @tindex PLUS_EXPR @tindex MINUS_EXPR @tindex MULT_EXPR @@ -1413,8 +1414,16 @@ always of @code{BOOLEAN_TYPE} or @code{INTEGER_TYPE}. @item POINTER_PLUS_EXPR This node represents pointer arithmetic. The first operand is always a pointer/reference type. The second operand is always an unsigned -integer type compatible with sizetype. This is the only binary -arithmetic operand that can operate on pointer types. +integer type compatible with sizetype. This and POINTER_DIFF_EXPR are +the only binary arithmetic operators that can operate on pointer types. + +@item POINTER_DIFF_EXPR +This node represents pointer subtraction. The two operands always +have pointer/reference type. It returns a signed integer of the same +precision as the pointers. The behavior is undefined if the difference +of the two pointers, seen as infinite precision non-negative integers, +does not fit in the result type. The result does not depend on the +pointer type, it is not divided by the size of the pointed-to type. @item PLUS_EXPR @itemx MINUS_EXPR |