[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 4645430 2/2: Pacify GCC 10.1.0
From: |
Paul Eggert |
Subject: |
master 4645430 2/2: Pacify GCC 10.1.0 |
Date: |
Mon, 11 May 2020 20:54:30 -0400 (EDT) |
branch: master
commit 4645430b9287c3f5ae9863d465a5dd4158e313a9
Author: Paul Eggert <address@hidden>
Commit: Paul Eggert <address@hidden>
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.
---
src/dispnew.c | 2 +-
src/fns.c | 2 +-
src/intervals.c | 3 ++-
src/keyboard.c | 4 ++--
src/lisp.h | 23 ++++++++++++++++++++++-
src/xfaces.c | 6 +++---
src/xmenu.c | 2 +-
7 files changed, 32 insertions(+), 10 deletions(-)
diff --git a/src/dispnew.c b/src/dispnew.c
index 5b6fa51..1ae59e3 100644
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -881,7 +881,7 @@ clear_glyph_row (struct glyph_row *row)
enum { off = offsetof (struct glyph_row, used) };
/* Zero everything except pointers in `glyphs'. */
- memset (row->used, 0, sizeof *row - off);
+ memset ((char *) row + off, 0, sizeof *row - off);
}
diff --git a/src/fns.c b/src/fns.c
index d6808aa..301bd59 100644
--- a/src/fns.c
+++ b/src/fns.c
@@ -4392,7 +4392,7 @@ hash_clear (struct Lisp_Hash_Table *h)
{
ptrdiff_t size = HASH_TABLE_SIZE (h);
if (!hash_rehash_needed_p (h))
- memclear (XVECTOR (h->hash)->contents, size * word_size);
+ memclear (xvector_contents (h->hash), size * word_size);
for (ptrdiff_t i = 0; i < size; i++)
{
set_hash_next_slot (h, i, i < size - 1 ? i + 1 : -1);
diff --git a/src/intervals.c b/src/intervals.c
index d4a734c..0257591 100644
--- a/src/intervals.c
+++ b/src/intervals.c
@@ -117,10 +117,11 @@ create_root_interval (Lisp_Object parent)
/* Make the interval TARGET have exactly the properties of SOURCE. */
void
-copy_properties (register INTERVAL source, register INTERVAL target)
+copy_properties (INTERVAL source, INTERVAL target)
{
if (DEFAULT_INTERVAL_P (source) && DEFAULT_INTERVAL_P (target))
return;
+ eassume (source && target);
COPY_INTERVAL_CACHE (source, target);
set_interval_plist (target, Fcopy_sequence (source->plist));
diff --git a/src/keyboard.c b/src/keyboard.c
index c94d794..f9b9399 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -8302,7 +8302,7 @@ append_tab_bar_item (void)
/* Append entries from tab_bar_item_properties to the end of
tab_bar_items_vector. */
vcopy (tab_bar_items_vector, ntab_bar_items,
- XVECTOR (tab_bar_item_properties)->contents, TAB_BAR_ITEM_NSLOTS);
+ xvector_contents (tab_bar_item_properties), TAB_BAR_ITEM_NSLOTS);
ntab_bar_items += TAB_BAR_ITEM_NSLOTS;
}
@@ -8779,7 +8779,7 @@ append_tool_bar_item (void)
/* Append entries from tool_bar_item_properties to the end of
tool_bar_items_vector. */
vcopy (tool_bar_items_vector, ntool_bar_items,
- XVECTOR (tool_bar_item_properties)->contents, TOOL_BAR_ITEM_NSLOTS);
+ xvector_contents (tool_bar_item_properties), TOOL_BAR_ITEM_NSLOTS);
ntool_bar_items += TOOL_BAR_ITEM_NSLOTS;
}
diff --git a/src/lisp.h b/src/lisp.h
index b4ac017..a55fa32 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -3350,6 +3350,27 @@ struct frame;
#define HAVE_EXT_TOOL_BAR true
#endif
+/* Return the address of vector A's element at index I. */
+
+INLINE Lisp_Object *
+xvector_contents_addr (Lisp_Object a, ptrdiff_t i)
+{
+ /* This should return &XVECTOR (a)->contents[i], but that would run
+ afoul of GCC bug 95072. */
+ void *v = XVECTOR (a);
+ char *p = v;
+ void *w = p + header_size + i * word_size;
+ return w;
+}
+
+/* Return the address of vector A's elements. */
+
+INLINE Lisp_Object *
+xvector_contents (Lisp_Object a)
+{
+ return xvector_contents_addr (a, 0);
+}
+
/* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET. */
INLINE void
@@ -3357,7 +3378,7 @@ vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object const
*args,
ptrdiff_t count)
{
eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
- memcpy (XVECTOR (v)->contents + offset, args, count * sizeof *args);
+ memcpy (xvector_contents_addr (v, offset), args, count * sizeof *args);
}
/* Functions to modify hash tables. */
diff --git a/src/xfaces.c b/src/xfaces.c
index bab142a..7d7aff9 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,
lface = lface_from_face_name_no_resolve (f, face_name, signal_p);
if (! NILP (lface))
- memcpy (attrs, XVECTOR (lface)->contents,
+ memcpy (attrs, xvector_contents (lface),
LFACE_VECTOR_SIZE * sizeof *attrs);
return !NILP (lface);
@@ -2860,7 +2860,7 @@ The value is TO. */)
f = XFRAME (new_frame);
}
- vcopy (copy, 0, XVECTOR (lface)->contents, LFACE_VECTOR_SIZE);
+ vcopy (copy, 0, xvector_contents (lface), LFACE_VECTOR_SIZE);
/* Changing a named face means that all realized faces depending on
that face are invalid. Since we cannot tell which realized faces
@@ -5598,7 +5598,7 @@ realize_default_face (struct frame *f)
/* Realize the face; it must be fully-specified now. */
eassert (lface_fully_specified_p (XVECTOR (lface)->contents));
check_lface (lface);
- memcpy (attrs, XVECTOR (lface)->contents, sizeof attrs);
+ memcpy (attrs, xvector_contents (lface), sizeof attrs);
struct face *face = realize_face (c, attrs, DEFAULT_FACE_ID);
#ifndef HAVE_WINDOW_SYSTEM
diff --git a/src/xmenu.c b/src/xmenu.c
index 9201a28..dba7e88 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)
/* Save the frame's previous menu bar contents data. */
if (previous_menu_items_used)
- memcpy (previous_items, XVECTOR (f->menu_bar_vector)->contents,
+ memcpy (previous_items, xvector_contents (f->menu_bar_vector),
previous_menu_items_used * word_size);
/* Fill in menu_items with the current menu bar contents.