aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Eggert2020-05-11 17:41:16 -0700
committerPaul Eggert2020-05-11 17:54:24 -0700
commit4645430b9287c3f5ae9863d465a5dd4158e313a9 (patch)
tree6c1ca7b2cc52909d0de38ad650569352c511d948
parent00f0ad55cd7cbb71e42de0d52b7607ffb6a3c220 (diff)
downloademacs-4645430b9287c3f5ae9863d465a5dd4158e313a9.tar.gz
emacs-4645430b9287c3f5ae9863d465a5dd4158e313a9.zip
Pacify GCC 10.1.0
Pacify GCC 10.1.0 so that it does not issue false alarms when Emacs is configured with --enable-gcc-warnings. * src/dispnew.c (clear_glyph_row): * src/fns.c (hash_clear): * src/keyboard.c (append_tab_bar_item): * src/lisp.h (vcopy): * src/xfaces.c (get_lface_attributes_no_remap) (Finternal_copy_lisp_face, realize_default_face): * src/xmenu.c (set_frame_menubar): Work around -Warray-bounds false alarm in GCC 10.1.0. * src/intervals.c (copy_properties): Avoid -Wnull-dereference false alarm in GCC 10.1.0. * src/lisp.h (xvector_contents_addr, xvector_contents): New functions, useful for working around GCC bug 95072.
-rw-r--r--src/dispnew.c2
-rw-r--r--src/fns.c2
-rw-r--r--src/intervals.c3
-rw-r--r--src/keyboard.c4
-rw-r--r--src/lisp.h23
-rw-r--r--src/xfaces.c6
-rw-r--r--src/xmenu.c2
7 files changed, 32 insertions, 10 deletions
diff --git a/src/dispnew.c b/src/dispnew.c
index 5b6fa51a563..1ae59e3ff2b 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -881,7 +881,7 @@ clear_glyph_row (struct glyph_row *row)
881 enum { off = offsetof (struct glyph_row, used) }; 881 enum { off = offsetof (struct glyph_row, used) };
882 882
883 /* Zero everything except pointers in `glyphs'. */ 883 /* Zero everything except pointers in `glyphs'. */
884 memset (row->used, 0, sizeof *row - off); 884 memset ((char *) row + off, 0, sizeof *row - off);
885} 885}
886 886
887 887
diff --git a/src/fns.c b/src/fns.c
index d6808aa1280..301bd59ab90 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4392,7 +4392,7 @@ hash_clear (struct Lisp_Hash_Table *h)
4392 { 4392 {
4393 ptrdiff_t size = HASH_TABLE_SIZE (h); 4393 ptrdiff_t size = HASH_TABLE_SIZE (h);
4394 if (!hash_rehash_needed_p (h)) 4394 if (!hash_rehash_needed_p (h))
4395 memclear (XVECTOR (h->hash)->contents, size * word_size); 4395 memclear (xvector_contents (h->hash), size * word_size);
4396 for (ptrdiff_t i = 0; i < size; i++) 4396 for (ptrdiff_t i = 0; i < size; i++)
4397 { 4397 {
4398 set_hash_next_slot (h, i, i < size - 1 ? i + 1 : -1); 4398 set_hash_next_slot (h, i, i < size - 1 ? i + 1 : -1);
diff --git a/src/intervals.c b/src/intervals.c
index d4a734c923c..0257591a142 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -117,10 +117,11 @@ create_root_interval (Lisp_Object parent)
117/* Make the interval TARGET have exactly the properties of SOURCE. */ 117/* Make the interval TARGET have exactly the properties of SOURCE. */
118 118
119void 119void
120copy_properties (register INTERVAL source, register INTERVAL target) 120copy_properties (INTERVAL source, INTERVAL target)
121{ 121{
122 if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target)) 122 if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target))
123 return; 123 return;
124 eassume (source && target);
124 125
125 COPY_INTERVAL_CACHE (source, target); 126 COPY_INTERVAL_CACHE (source, target);
126 set_interval_plist (target, Fcopy_sequence (source->plist)); 127 set_interval_plist (target, Fcopy_sequence (source->plist));
diff --git a/src/keyboard.c b/src/keyboard.c
index c94d794b013..f9b9399d502 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8302,7 +8302,7 @@ append_tab_bar_item (void)
8302 /* Append entries from tab_bar_item_properties to the end of 8302 /* Append entries from tab_bar_item_properties to the end of
8303 tab_bar_items_vector. */ 8303 tab_bar_items_vector. */
8304 vcopy (tab_bar_items_vector, ntab_bar_items, 8304 vcopy (tab_bar_items_vector, ntab_bar_items,
8305 XVECTOR (tab_bar_item_properties)->contents, TAB_BAR_ITEM_NSLOTS); 8305 xvector_contents (tab_bar_item_properties), TAB_BAR_ITEM_NSLOTS);
8306 ntab_bar_items += TAB_BAR_ITEM_NSLOTS; 8306 ntab_bar_items += TAB_BAR_ITEM_NSLOTS;
8307} 8307}
8308 8308
@@ -8779,7 +8779,7 @@ append_tool_bar_item (void)
8779 /* Append entries from tool_bar_item_properties to the end of 8779 /* Append entries from tool_bar_item_properties to the end of
8780 tool_bar_items_vector. */ 8780 tool_bar_items_vector. */
8781 vcopy (tool_bar_items_vector, ntool_bar_items, 8781 vcopy (tool_bar_items_vector, ntool_bar_items,
8782 XVECTOR (tool_bar_item_properties)->contents, TOOL_BAR_ITEM_NSLOTS); 8782 xvector_contents (tool_bar_item_properties), TOOL_BAR_ITEM_NSLOTS);
8783 ntool_bar_items += TOOL_BAR_ITEM_NSLOTS; 8783 ntool_bar_items += TOOL_BAR_ITEM_NSLOTS;
8784} 8784}
8785 8785
diff --git a/src/lisp.h b/src/lisp.h
index b4ac017dcf5..a55fa32950d 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3350,6 +3350,27 @@ struct frame;
3350#define HAVE_EXT_TOOL_BAR true 3350#define HAVE_EXT_TOOL_BAR true
3351#endif 3351#endif
3352 3352
3353/* Return the address of vector A's element at index I. */
3354
3355INLINE Lisp_Object *
3356xvector_contents_addr (Lisp_Object a, ptrdiff_t i)
3357{
3358 /* This should return &XVECTOR (a)->contents[i], but that would run
3359 afoul of GCC bug 95072. */
3360 void *v = XVECTOR (a);
3361 char *p = v;
3362 void *w = p + header_size + i * word_size;
3363 return w;
3364}
3365
3366/* Return the address of vector A's elements. */
3367
3368INLINE Lisp_Object *
3369xvector_contents (Lisp_Object a)
3370{
3371 return xvector_contents_addr (a, 0);
3372}
3373
3353/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */ 3374/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */
3354 3375
3355INLINE void 3376INLINE void
@@ -3357,7 +3378,7 @@ vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object const *args,
3357 ptrdiff_t count) 3378 ptrdiff_t count)
3358{ 3379{
3359 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v)); 3380 eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
3360 memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args); 3381 memcpy (xvector_contents_addr (v, offset), args, count * sizeof *args);
3361} 3382}
3362 3383
3363/* Functions to modify hash tables. */ 3384/* Functions to modify hash tables. */
diff --git a/src/xfaces.c b/src/xfaces.c
index bab142ade0f..7d7aff95c11 100644
--- a/src/xfaces.c
+++ b/src/xfaces.c
@@ -1888,7 +1888,7 @@ get_lface_attributes_no_remap (struct frame *f, Lisp_Object face_name,
1888 lface = lface_from_face_name_no_resolve (f, face_name, signal_p); 1888 lface = lface_from_face_name_no_resolve (f, face_name, signal_p);
1889 1889
1890 if (! NILP (lface)) 1890 if (! NILP (lface))
1891 memcpy (attrs, XVECTOR (lface)->contents, 1891 memcpy (attrs, xvector_contents (lface),
1892 LFACE_VECTOR_SIZE * sizeof *attrs); 1892 LFACE_VECTOR_SIZE * sizeof *attrs);
1893 1893
1894 return !NILP (lface); 1894 return !NILP (lface);
@@ -2860,7 +2860,7 @@ The value is TO. */)
2860 f = XFRAME (new_frame); 2860 f = XFRAME (new_frame);
2861 } 2861 }
2862 2862
2863 vcopy (copy, 0, XVECTOR (lface)->contents, LFACE_VECTOR_SIZE); 2863 vcopy (copy, 0, xvector_contents (lface), LFACE_VECTOR_SIZE);
2864 2864
2865 /* Changing a named face means that all realized faces depending on 2865 /* Changing a named face means that all realized faces depending on
2866 that face are invalid. Since we cannot tell which realized faces 2866 that face are invalid. Since we cannot tell which realized faces
@@ -5598,7 +5598,7 @@ realize_default_face (struct frame *f)
5598 /* Realize the face; it must be fully-specified now. */ 5598 /* Realize the face; it must be fully-specified now. */
5599 eassert (lface_fully_specified_p (XVECTOR (lface)->contents)); 5599 eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
5600 check_lface (lface); 5600 check_lface (lface);
5601 memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs); 5601 memcpy (attrs, xvector_contents (lface), sizeof attrs);
5602 struct face *face = realize_face (c, attrs, DEFAULT_FACE_ID); 5602 struct face *face = realize_face (c, attrs, DEFAULT_FACE_ID);
5603 5603
5604#ifndef HAVE_WINDOW_SYSTEM 5604#ifndef HAVE_WINDOW_SYSTEM
diff --git a/src/xmenu.c b/src/xmenu.c
index 9201a283b47..dba7e88f486 100644
--- a/src/xmenu.c
+++ b/src/xmenu.c
@@ -763,7 +763,7 @@ set_frame_menubar (struct frame *f, bool first_time, bool deep_p)
763 763
764 /* Save the frame's previous menu bar contents data. */ 764 /* Save the frame's previous menu bar contents data. */
765 if (previous_menu_items_used) 765 if (previous_menu_items_used)
766 memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents, 766 memcpy (previous_items, xvector_contents (f->menu_bar_vector),
767 previous_menu_items_used * word_size); 767 previous_menu_items_used * word_size);
768 768
769 /* Fill in menu_items with the current menu bar contents. 769 /* Fill in menu_items with the current menu bar contents.