aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames McCoy <jamessan@jamessan.com>2019-04-07 19:50:54 -0400
committerJames McCoy <jamessan@jamessan.com>2019-04-07 20:00:28 -0400
commitb8df2c6ebd96f2cb06e19da909623085d7b23932 (patch)
treece03dcbca31b5023d23ef0f66ff3fe36c1981348
parentc5e8924f4e72f46679cff52ac075e3eb023883d5 (diff)
downloadrneovim-b8df2c6ebd96f2cb06e19da909623085d7b23932.tar.gz
rneovim-b8df2c6ebd96f2cb06e19da909623085d7b23932.tar.bz2
rneovim-b8df2c6ebd96f2cb06e19da909623085d7b23932.zip
Make SHM_ALL to a variable instead of a compound literal #define
gcc-9 has [improved compliance] with the C spec for lifetime of compound literals, tying their lifetime to block scope instead of function scope. This makes the behavior comparable to all other automatic variables. Using the SHM_ALL #define instantiated a compound literal local to an if clause and assigned the address to a "char_u *". Since the pointer was then being used outside of the if clause, it was using an invalid address. [improved compliance]: https://gcc.gnu.org/gcc-9/porting_to.html#complit Closes #9855
-rw-r--r--src/nvim/option.c9
-rw-r--r--src/nvim/option_defs.h8
2 files changed, 9 insertions, 8 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 3486490366..30dabcdd7d 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -310,6 +310,15 @@ static char *(p_scl_values[]) = { "yes", "no", "auto", "auto:1", "auto:2",
"yes:1", "yes:2", "yes:3", "yes:4", "yes:5", "yes:6", "yes:7", "yes:8",
"yes:9", NULL };
+/// All possible flags for 'shm'.
+static char_u SHM_ALL[] = {
+ SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI,
+ SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER,
+ SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU,
+ SHM_RECORDING, SHM_FILEINFO,
+ 0,
+};
+
#ifdef INCLUDE_GENERATED_DECLARATIONS
# include "option.c.generated.h"
#endif
diff --git a/src/nvim/option_defs.h b/src/nvim/option_defs.h
index c71ce9175b..2075d2819c 100644
--- a/src/nvim/option_defs.h
+++ b/src/nvim/option_defs.h
@@ -179,14 +179,6 @@ enum {
SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
0, \
})
-/// All possible flags for 'shm'.
-#define SHM_ALL ((char_u[]) { \
- SHM_RO, SHM_MOD, SHM_FILE, SHM_LAST, SHM_TEXT, SHM_LINES, SHM_NEW, SHM_WRI, \
- SHM_ABBREVIATIONS, SHM_WRITE, SHM_TRUNC, SHM_TRUNCALL, SHM_OVER, \
- SHM_OVERALL, SHM_SEARCH, SHM_ATTENTION, SHM_INTRO, SHM_COMPLETIONMENU, \
- SHM_RECORDING, SHM_FILEINFO, \
- 0, \
-})
/* characters for p_go: */
#define GO_ASEL 'a' /* autoselect */