aboutsummaryrefslogtreecommitdiffstats
path: root/src/intervals.h
diff options
context:
space:
mode:
authorPaul Eggert2020-03-04 13:48:26 -0800
committerPaul Eggert2020-03-04 13:48:58 -0800
commitdc3006cf1419e5b22c35fa36d79ba029d0482df1 (patch)
treeef5581855ed15eafedc296c767f1addcd5f9c13a /src/intervals.h
parentd1bbd32dba392f2fb4548d892354e78ff8df4451 (diff)
downloademacs-dc3006cf1419e5b22c35fa36d79ba029d0482df1.tar.gz
emacs-dc3006cf1419e5b22c35fa36d79ba029d0482df1.zip
Pacify GCC 9.2.1 20190927 -O3
Original problem report by N. Jackson in: https://lists.gnu.org/r/emacs-devel/2020-03/msg00047.html I found some other warnings when I used gcc, and fixed them with this patch. * lib-src/etags.c: Include verify.h. (xnmalloc, xnrealloc): Tell the compiler that NITEMS is nononnegative and ITEM_SIZE is positive. * src/conf_post.h (__has_attribute_returns_nonnull) (ATTRIBUTE_RETURNS_NONNULL): New macros. * src/editfns.c (Fuser_full_name): Don’t assume Fuser_login_name returns non-nil. * src/intervals.c (rotate_right, rotate_left, update_interval): * src/intervals.h (LENGTH, LEFT_TOTAL_LENGTH, RIGHT_TOTAL_LENGTH): Use TOTAL_LENGTH0 or equivalent on intervals that might be null. * src/intervals.h (TOTAL_LENGTH): Assume arg is nonnull. (TOTAL_LENGTH0): New macro, with the old TOTAL_LENGTH meaning. (make_interval, split_interval_right): Add ATTRIBUTE_RETURNS_NONNULL. * src/pdumper.c (dump_check_dump_off): Now returns void, since no caller uses the return value. Redo assert to pacify GCC. (decode_emacs_reloc): Add a seemingly-random eassume to pacify GCC. Ugly, and I suspect due to a bug in GCC.
Diffstat (limited to 'src/intervals.h')
-rw-r--r--src/intervals.h24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/intervals.h b/src/intervals.h
index a93b10e9fff..9a7ba910a10 100644
--- a/src/intervals.h
+++ b/src/intervals.h
@@ -96,24 +96,27 @@ struct interval
96/* True if this interval has both left and right children. */ 96/* True if this interval has both left and right children. */
97#define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL) 97#define BOTH_KIDS_P(i) ((i)->left != NULL && (i)->right != NULL)
98 98
99/* The total size of all text represented by this interval and all its 99/* The total size of all text represented by the nonnull interval I
100 children in the tree. This is zero if the interval is null. */ 100 and all its children in the tree. */
101#define TOTAL_LENGTH(i) ((i) == NULL ? 0 : (i)->total_length) 101#define TOTAL_LENGTH(i) ((i)->total_length)
102
103/* Likewise, but also defined to be zero if I is null. */
104#define TOTAL_LENGTH0(i) ((i) ? TOTAL_LENGTH (i) : 0)
102 105
103/* The size of text represented by this interval alone. */ 106/* The size of text represented by this interval alone. */
104#define LENGTH(i) ((i)->total_length \ 107#define LENGTH(i) (TOTAL_LENGTH (i) \
105 - TOTAL_LENGTH ((i)->right) \ 108 - RIGHT_TOTAL_LENGTH (i) \
106 - TOTAL_LENGTH ((i)->left)) 109 - LEFT_TOTAL_LENGTH (i))
107 110
108/* The position of the character just past the end of I. Note that 111/* The position of the character just past the end of I. Note that
109 the position cache i->position must be valid for this to work. */ 112 the position cache i->position must be valid for this to work. */
110#define INTERVAL_LAST_POS(i) ((i)->position + LENGTH (i)) 113#define INTERVAL_LAST_POS(i) ((i)->position + LENGTH (i))
111 114
112/* The total size of the left subtree of this interval. */ 115/* The total size of the left subtree of this interval. */
113#define LEFT_TOTAL_LENGTH(i) ((i)->left ? (i)->left->total_length : 0) 116#define LEFT_TOTAL_LENGTH(i) TOTAL_LENGTH0 ((i)->left)
114 117
115/* The total size of the right subtree of this interval. */ 118/* The total size of the right subtree of this interval. */
116#define RIGHT_TOTAL_LENGTH(i) ((i)->right ? (i)->right->total_length : 0) 119#define RIGHT_TOTAL_LENGTH(i) TOTAL_LENGTH0 ((i)->right)
117 120
118/* These macros are for dealing with the interval properties. */ 121/* These macros are for dealing with the interval properties. */
119 122
@@ -234,7 +237,7 @@ set_interval_plist (INTERVAL i, Lisp_Object plist)
234 237
235/* Declared in alloc.c. */ 238/* Declared in alloc.c. */
236 239
237extern INTERVAL make_interval (void); 240extern INTERVAL make_interval (void) ATTRIBUTE_RETURNS_NONNULL;
238 241
239/* Declared in intervals.c. */ 242/* Declared in intervals.c. */
240 243
@@ -246,7 +249,8 @@ extern void traverse_intervals (INTERVAL, ptrdiff_t,
246 Lisp_Object); 249 Lisp_Object);
247extern void traverse_intervals_noorder (INTERVAL, 250extern void traverse_intervals_noorder (INTERVAL,
248 void (*) (INTERVAL, void *), void *); 251 void (*) (INTERVAL, void *), void *);
249extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t); 252extern INTERVAL split_interval_right (INTERVAL, ptrdiff_t)
253 ATTRIBUTE_RETURNS_NONNULL;
250extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t); 254extern INTERVAL split_interval_left (INTERVAL, ptrdiff_t);
251extern INTERVAL find_interval (INTERVAL, ptrdiff_t); 255extern INTERVAL find_interval (INTERVAL, ptrdiff_t);
252extern INTERVAL next_interval (INTERVAL); 256extern INTERVAL next_interval (INTERVAL);