summaryrefslogtreecommitdiff
path: root/gcc/tree.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/tree.h')
-rw-r--r--gcc/tree.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/gcc/tree.h b/gcc/tree.h
index c8d292a3d4f..820431fae0b 100644
--- a/gcc/tree.h
+++ b/gcc/tree.h
@@ -5313,6 +5313,25 @@ truth_value_p (enum tree_code code)
|| code == TRUTH_XOR_EXPR || code == TRUTH_NOT_EXPR);
}
+/* Return whether TYPE is a type suitable for an offset for
+ a POINTER_PLUS_EXPR. */
+static inline bool
+ptrofftype_p (tree type)
+{
+ return (INTEGRAL_TYPE_P (type)
+ && TYPE_PRECISION (type) == TYPE_PRECISION (sizetype)
+ && TYPE_UNSIGNED (type) == TYPE_UNSIGNED (sizetype));
+}
+
+/* Return OFF converted to a pointer offset type suitable as offset for
+ POINTER_PLUS_EXPR. Use location LOC for this conversion. */
+static inline tree
+convert_to_ptrofftype_loc (location_t loc, tree off)
+{
+ return fold_convert_loc (loc, sizetype, off);
+}
+#define convert_to_ptrofftype(t) convert_to_ptrofftype_loc (UNKNOWN_LOCATION, t)
+
/* Build and fold a POINTER_PLUS_EXPR at LOC offsetting PTR by OFF. */
static inline tree
fold_build_pointer_plus_loc (location_t loc, tree ptr, tree off)