Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie Ken Takata
Hi,

2020/5/10 Sun 6:38:41 UTC+9 John Marriott wrote:
>
>
> On 10-May-2020 07:11, Bram Moolenaar wrote: 
> > Any specified reason you exclude clang here?  I thought it was using the 
> > same runtime library. 
> > 
> > 
> Ah no. It looks like I pinched too much from stackoverflow. Whoops sorry 
> :-) 
>

 I don't think we need to use #if here.
Attached patch should be enough.

Additionally, at least Windows 7's msvcrt.dll doesn't support the "z" 
specifier.

Regards,
Ken Takata

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/ac8d33b1-f1cc-4a98-a68e-c212db0a3977%40googlegroups.com.
diff --git a/src/vim.h b/src/vim.h
--- a/src/vim.h
+++ b/src/vim.h
@@ -341,9 +341,9 @@ typedef unsigned int	int_u;
 #ifdef _WIN64
 typedef unsigned __int64	long_u;
 typedef		 __int64	long_i;
-# define SCANF_HEX_LONG_U   "%Ix"
-# define SCANF_DECIMAL_LONG_U   "%Iu"
-# define PRINTF_HEX_LONG_U  "0x%Ix"
+# define SCANF_HEX_LONG_U   "%llx"
+# define SCANF_DECIMAL_LONG_U   "%llu"
+# define PRINTF_HEX_LONG_U  "0x%llx"
 #else
   // Microsoft-specific. The __w64 keyword should be specified on any typedefs
   // that change size between 32-bit and 64-bit platforms.  For any such type,


Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie John Marriott



On 10-May-2020 07:11, Bram Moolenaar wrote:

Any specified reason you exclude clang here?  I thought it was using the
same runtime library.



Ah no. It looks like I pinched too much from stackoverflow. Whoops sorry :-)

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups "vim_dev" group.

To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/ff41f70a-4701-b214-06c5-d333ad9b6d4e%40internode.on.net.


Patch 8.2.0726

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0726
Problem:Vim9: leaking memory when calling not compiled :def function.
Solution:   Check if function is compiled earlier.
Files:  src/vim9execute.c


*** ../vim-8.2.0725/src/vim9execute.c   2020-05-09 22:50:04.755323771 +0200
--- src/vim9execute.c   2020-05-09 23:19:02.153569561 +0200
***
*** 665,674 
  // Like STACK_TV_VAR but use the outer scope
  #define STACK_OUT_TV_VAR(idx) (((typval_T *)ectx.ec_outer_stack->ga_data) + 
ectx.ec_outer_frame + STACK_FRAME_SIZE + idx)
  
- CLEAR_FIELD(ectx);
- ga_init2(_stack, sizeof(typval_T), 500);
- if (ga_grow(_stack, 20) == FAIL)
-   return FAIL;
  {
// Check the function was compiled, it is postponed in ex_vim9script().
dfunc_T *dfunc = ((dfunc_T *)def_functions.ga_data)
--- 665,670 
***
*** 676,683 
if (dfunc->df_instr == NULL)
return FAIL;
  }
- ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
  
  ga_init2(_trystack, sizeof(trycmd_T), 10);
  
  // Put arguments on the stack.
--- 672,683 
if (dfunc->df_instr == NULL)
return FAIL;
  }
  
+ CLEAR_FIELD(ectx);
+ ectx.ec_dfunc_idx = ufunc->uf_dfunc_idx;
+ ga_init2(_stack, sizeof(typval_T), 500);
+ if (ga_grow(_stack, 20) == FAIL)
+   return FAIL;
  ga_init2(_trystack, sizeof(trycmd_T), 10);
  
  // Put arguments on the stack.
*** ../vim-8.2.0725/src/version.c   2020-05-09 22:50:04.755323771 +0200
--- src/version.c   2020-05-09 23:20:07.101344125 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 726,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
85. Choice between paying Compuserve bill and paying for kids education
is a no brainer -- although a bit painful for your kids.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005092120.049LKmuK027246%40masaka.moolenaar.net.


Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> However, putting the definitions around some ifdefs works for me, like 
> so (see attached):
> 
> #ifdef _WIN64
> typedef unsigned __int64    long_u;
> typedef         __int64    long_i;
> # if defined(__GNUC__) && !defined(__clang__)

Any specified reason you exclude clang here?  I thought it was using the
same runtime library.

>      # define SCANF_HEX_LONG_U   "%zx"
>      # define SCANF_DECIMAL_LONG_U   "%zu"
>      # define PRINTF_HEX_LONG_U  "0x%zx"
> # else
>      # define SCANF_HEX_LONG_U   "%Ix"
>      # define SCANF_DECIMAL_LONG_U   "%Iu"
>      # define PRINTF_HEX_LONG_U  "0x%Ix"
> # endif

-- 
hundred-and-one symptoms of being an internet addict:
84. Books in your bookcase bear the names Bongo, WinSock and Inside OLE

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005092111.049LB2xd024498%40masaka.moolenaar.net.


Patch 8.2.0725

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0725
Problem:Vim9: cannot call a function declared later in Vim9 script.
Solution:   Make two passes through the script file.
Files:  src/scriptfile.c, src/proto/scriptfile.pro, src/vim9script.c,
src/vim9compile.c, src/vim9execute.c, src/proto/vim9compile.pro,
src/userfunc.c, src/proto/userfunc.pro, src/evalvars.c,
src/proto/evalvars.pro, src/vim.h,
src/testdir/test_vim9_disassemble.vim


*** ../vim-8.2.0724/src/scriptfile.c2020-05-03 17:01:19.842024266 +0200
--- src/scriptfile.c2020-05-09 21:52:21.128164355 +0200
***
*** 998,1003 
--- 998,1005 
  int   error;  // TRUE if LF found after CR-LF
  #endif
  #ifdef FEAT_EVAL
+ garray_T  lines_ga;   // lines read in previous pass
+ int   use_lines_ga;   // next line to get from "lines_ga"
  linenr_T  breakpoint; // next line with breakpoint or zero
  char_u*fname; // name of sourced file
  int   dbg_tick;   // debug_tick when breakpoint was set
***
*** 1017,1022 
--- 1019,1042 
  }
  
  /*
+  * Get the grow array to store script lines in.
+  */
+ garray_T *
+ source_get_line_ga(void *cookie)
+ {
+ return &((struct source_cookie *)cookie)->lines_ga;
+ }
+ 
+ /*
+  * Set the index to start reading from the grow array with script lines.
+  */
+ void
+ source_use_line_ga(void *cookie)
+ {
+ ((struct source_cookie *)cookie)->use_lines_ga = 0;
+ }
+ 
+ /*
   * Return the address holding the debug tick for a source cookie.
   */
  int *
***
*** 1235,1240 
--- 1255,1263 
  cookie.finished = FALSE;
  
  #ifdef FEAT_EVAL
+ ga_init2(_ga, sizeof(char_u *), 200);
+ cookie.use_lines_ga = -1;
+ 
  // Check if this script has a breakpoint.
  cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0);
  cookie.fname = fname_exp;
***
*** 1447,1452 
--- 1470,1478 
  vim_free(cookie.nextline);
  vim_free(firstline);
  convert_setup(, NULL, NULL);
+ #ifdef FEAT_EVAL
+ ga_clear_strings(_ga);
+ #endif
  
  if (trigger_source_post)
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf);
***
*** 1702,1707 
--- 1728,1758 
  // one now.
  if (sp->finished)
line = NULL;
+ #ifdef FEAT_EVAL
+ else if (sp->use_lines_ga >= 0)
+ {
+   // Get a line that was read in ex_vim9script().
+   for (;;)
+   {
+   if (sp->use_lines_ga >= sp->lines_ga.ga_len)
+   {
+   line = NULL;
+   break;
+   }
+   else
+   {
+   line = ((char_u **)(sp->lines_ga.ga_data))[sp->use_lines_ga];
+   ((char_u **)(sp->lines_ga.ga_data))[sp->use_lines_ga] = NULL;
+   ++sp->use_lines_ga;
+   if (line != NULL)
+   break;
+   // Skip NULL lines, they are equivalent to blank lines.
+   ++sp->sourcing_lnum;
+   }
+   }
+   SOURCING_LNUM = sp->sourcing_lnum + 1;
+ }
+ #endif
  else if (sp->nextline == NULL)
line = get_one_sourceline(sp);
  else
*** ../vim-8.2.0724/src/proto/scriptfile.pro2020-01-26 15:52:33.023833239 
+0100
--- src/proto/scriptfile.pro2020-05-09 19:28:49.405736342 +0200
***
*** 19,24 
--- 19,26 
  void ex_source(exarg_T *eap);
  void ex_options(exarg_T *eap);
  linenr_T *source_breakpoint(void *cookie);
+ garray_T *source_get_line_ga(void *cookie);
+ void source_use_line_ga(void *cookie);
  int *source_dbg_tick(void *cookie);
  int source_level(void *cookie);
  int do_source(char_u *fname, int check_other, int is_vimrc, int *ret_sid);
*** ../vim-8.2.0724/src/vim9script.c2020-04-27 22:47:45.186176148 +0200
--- src/vim9script.c2020-05-09 22:48:51.139530983 +0200
***
*** 32,38 
  void
  ex_vim9script(exarg_T *eap)
  {
! scriptitem_T *si = SCRIPT_ITEM(current_sctx.sc_sid);
  
  if (!getline_equal(eap->getline, eap->cookie, getsourceline))
  {
--- 32,42 
  void
  ex_vim9script(exarg_T *eap)
  {
! scriptitem_T*si = SCRIPT_ITEM(current_sctx.sc_sid);
! garray_T  *gap;
! garray_T  func_ga;
! int   idx;
! ufunc_T   *ufunc;
  
  if (!getline_equal(eap->getline, eap->cookie, getsourceline))
  {
***
*** 47,58 
--- 51,147 
  current_sctx.sc_version = SCRIPT_VERSION_VIM9;
  si->sn_version = SCRIPT_VERSION_VIM9;
  si->sn_had_command = TRUE;
+ ga_init2(_ga, sizeof(ufunc_T *), 20);
  
  if (STRCMP(p_cpo, CPO_VIM) != 0)
  {
si->sn_save_cpo = p_cpo;
p_cpo = vim_strsave((char_u *)CPO_VIM);
  }
+ 
+ // Make a pass through the script to find:
+ // - function declarations
+ // - variable and constant declarations
+ // - imports
+ // The types 

Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie John Marriott


On 09-May-2020 21:06, Ken Takata wrote:

Hi John,

2020/5/9 Sat 16:30:42 UTC+9 John Marriott wrote:

Hi All,

After cleaning my vim source repo and rebuilding with the brand
new gcc
10.1 (mingw64), I get these warnings:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer
-freg-struct-return main.c -o gobjnative/main.o
In file included from main.c:11:
main.c: In function 'early_arg_scan':
vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format
[-Wformat=]
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ^
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ^
vim.h:343:36: note: format string is defined here
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ^
vim.h:343:33: warning: format '%x' expects argument of type 'unsigned
int *', but argument 3 has type 'long_u *' {aka 'long lo
ng unsigned int *'} [-Wformat=]
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ^
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ^
vim.h:343:36: note: format string is defined here
   343 | # define SCANF_HEX_LONG_U "%Ix"
   | ~~^
   | |
   |    unsigned int *
   | %Illx
vim.h:344:33: warning: format '%u' expects argument of type 'unsigned
int *', but argument 3 has type 'long_u *' {aka 'long lo
ng unsigned int *'} [-Wformat=]
   344 | # define SCANF_DECIMAL_LONG_U "%Iu"
   | ^
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
   344 | # define SCANF_DECIMAL_LONG_U "%Iu"
   | ^
vim.h:344:36: note: format string is defined here
   344 | # define SCANF_DECIMAL_LONG_U "%Iu"
   | ~~^
   | |
   |    unsigned int *
   | %Illu


Unfortunately, older MSVC (e.g. VC 2010) doesn't support "z" specifier.
Do the warnings disappear if you change "%I" to "%I64"?



Hi Ken,

Changing them to "%I64" doesn't help:

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN
 -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
-freg-struct-return main.c -o gobjnative/main.o

In file included from main.c:11:
main.c: In function 'early_arg_scan':
vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format [-Wformat=]
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^~~
vim.h:343:38: note: format string is defined here
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^
vim.h:343:33: warning: format '%x' expects argument of type 'unsigned 
int *', but argument 3 has type 'long_u *' {aka 'long lo

ng unsigned int *'} [-Wformat=]
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^~~
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^~~
vim.h:343:38: note: format string is defined here
  343 | # define SCANF_HEX_LONG_U "%I64x"
  | ^
  | |
  |  unsigned int *
  | %I64llx
vim.h:344:33: warning: unknown conversion type character 'I' in format 
[-Wformat=]

  344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
  | ^~~~
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
  344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
  | ^~~~
vim.h:344:38: note: format string is defined here
  344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
  | ^
vim.h:344:33: warning: too many arguments for format [-Wformat-extra-args]
  344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
  | ^~~~
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
  344 | # define SCANF_DECIMAL_LONG_U "%I64Iu"
  | ^~~~


However, putting the definitions around some ifdefs works for me, like 
so (see attached):


#ifdef _WIN64
typedef unsigned __int64    long_u;
typedef         __int64    long_i;
# if defined(__GNUC__) && !defined(__clang__)
    # define SCANF_HEX_LONG_U   "%zx"
    # define SCANF_DECIMAL_LONG_U   "%zu"
    # define PRINTF_HEX_LONG_U  "0x%zx"
# else
    # define SCANF_HEX_LONG_U   "%Ix"
    # define SCANF_DECIMAL_LONG_U   "%Iu"
    # define PRINTF_HEX_LONG_U  "0x%Ix"
# endif
#else
  // Microsoft-specific. The __w64 keyword should be specified on any 
typedefs
  // that change size between 32-bit and 64-bit platforms.  For any 
such type,

  // __w64 should appear only on the 32-bit definition of the typedef.
  // Define __w64 as an empty token for everything but MSVC 7.x or later.
# if !defined(_MSC_VER)    || (_MSC_VER < 1300)
#  define 

Patch 8.2.0724

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0724
Problem:Vim9: appending to buffer/window/tab variable not tested
Solution:   Add a test.
Files:  src/testdir/test_vim9_script.vim


*** ../vim-8.2.0723/src/testdir/test_vim9_script.vim2020-05-07 
14:07:19.952220393 +0200
--- src/testdir/test_vim9_script.vim2020-05-09 18:42:12.562461002 +0200
***
*** 135,152 
--- 135,158 
assert_equal('yes', b:existing)
b:existing = 'no'
assert_equal('no', b:existing)
+   b:existing ..= 'NO'
+   assert_equal('noNO', b:existing)
  
w:newvar = 'new'
assert_equal('new', w:newvar)
assert_equal('yes', w:existing)
w:existing = 'no'
assert_equal('no', w:existing)
+   w:existing ..= 'NO'
+   assert_equal('noNO', w:existing)
  
t:newvar = 'new'
assert_equal('new', t:newvar)
assert_equal('yes', t:existing)
t:existing = 'no'
assert_equal('no', t:existing)
+   t:existing ..= 'NO'
+   assert_equal('noNO', t:existing)
  enddef
  call Test_assignment_local_internal()
END
*** ../vim-8.2.0723/src/version.c   2020-05-09 18:28:30.401618052 +0200
--- src/version.c   2020-05-09 18:42:55.262295780 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 724,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
82. AT names you Customer of the Month for the third consecutive time.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005091645.049GjJSv018760%40masaka.moolenaar.net.


Patch 8.2.0723

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0723
Problem:Vim9: nested constant expression not evaluated compile time.
Solution:   Use compile_expr1() for parenthesis.
Files:  src/vim9compile.c, src/testdir/test_vim9_disassemble.vim


*** ../vim-8.2.0722/src/vim9compile.c   2020-05-09 17:35:50.052198310 +0200
--- src/vim9compile.c   2020-05-09 18:17:56.599960479 +0200
***
*** 136,142 
  static char e_var_notfound[] = N_("E1001: variable not found: %s");
  static char e_syntax_at[] = N_("E1002: Syntax error at %s");
  
- static int compile_expr0(char_u **arg,  cctx_T *cctx);
  static void delete_def_function_contents(dfunc_T *dfunc);
  static void arg_type_mismatch(type_T *expected, type_T *actual, int argidx);
  static int check_type(type_T *expected, type_T *actual, int give_msg);
--- 136,141 
***
*** 2358,2368 
  // possible expressions on these constants are applied at compile time.  If
  // that is not possible, the code to push the constants needs to be generated
  // before other instructions.
  typedef struct {
! typval_T  pp_tv[10];  // stack of ppconst constants
  int   pp_used;// active entries in pp_tv[]
  } ppconst_T;
  
  /*
   * Generate a PUSH instruction for "tv".
   * "tv" will be consumed or cleared.
--- 2357,2372 
  // possible expressions on these constants are applied at compile time.  If
  // that is not possible, the code to push the constants needs to be generated
  // before other instructions.
+ // Using 50 should be more than enough of 5 levels of ().
+ #define PPSIZE 50
  typedef struct {
! typval_T  pp_tv[PPSIZE];  // stack of ppconst constants
  int   pp_used;// active entries in pp_tv[]
  } ppconst_T;
  
+ static int compile_expr0(char_u **arg,  cctx_T *cctx);
+ static int compile_expr1(char_u **arg,  cctx_T *cctx, ppconst_T *ppconst);
+ 
  /*
   * Generate a PUSH instruction for "tv".
   * "tv" will be consumed or cleared.
***
*** 3590,3595 
--- 3594,3600 
  char_u*start_leader, *end_leader;
  int   ret = OK;
  typval_T  *rettv = >pp_tv[ppconst->pp_used];
+ int   used_before = ppconst->pp_used;
  
  /*
   * Skip '!', '-' and '+' characters.  They are handled later.
***
*** 3725,3731 
 * nested expression: (expression).
 */
case '(':   *arg = skipwhite(*arg + 1);
!   ret = compile_expr0(arg, cctx); // recursive!
*arg = skipwhite(*arg);
if (**arg == ')')
++*arg;
--- 3730,3748 
 * nested expression: (expression).
 */
case '(':   *arg = skipwhite(*arg + 1);
! 
!   // recursive!
!   if (ppconst->pp_used <= PPSIZE - 10)
!   {
!   ret = compile_expr1(arg, cctx, ppconst);
!   }
!   else
!   {
!   // Not enough space in ppconst, flush constants.
!   if (generate_ppconst(cctx, ppconst) == FAIL)
!   return FAIL;
!   ret = compile_expr0(arg, cctx);
!   }
*arg = skipwhite(*arg);
if (**arg == ')')
++*arg;
***
*** 3742,3748 
  if (ret == FAIL)
return FAIL;
  
! if (rettv->v_type != VAR_UNKNOWN)
  {
// apply the '!', '-' and '+' before the constant
if (apply_leader(rettv, start_leader, end_leader) == FAIL)
--- 3759,3765 
  if (ret == FAIL)
return FAIL;
  
! if (rettv->v_type != VAR_UNKNOWN && used_before == ppconst->pp_used)
  {
// apply the '!', '-' and '+' before the constant
if (apply_leader(rettv, start_leader, end_leader) == FAIL)
*** ../vim-8.2.0722/src/testdir/test_vim9_disassemble.vim   2020-05-09 
15:43:58.322878209 +0200
--- src/testdir/test_vim9_disassemble.vim   2020-05-09 18:17:46.679995690 
+0200
***
*** 1053,1058 
--- 1053,1062 
return 2 + 3 * 4 / 6 + 7
  enddef
  
+ def s:ComputeConstParen(): number
+   return ((2 + 4) * (8 / 2)) / (3 + 4)
+ enddef
+ 
  def Test_simplify_const_expr()
let res = execute('disass s:ConcatStrings')
assert_match('\\d*_ConcatStrings.*' ..
***
*** 1065,1070 
--- 1069,1080 
  '\d PUSHNR 11.*' ..
  '\d RETURN',
  res)
+ 
+   res = execute('disass s:ComputeConstParen')
+   assert_match('\\d*_ComputeConstParen.*' ..
+ '\d PUSHNR 3\>.*' ..
+ '\d RETURN',
+ res)
  enddef
  
  " vim: ts=8 sw=2 sts=2 expandtab tw=80 fdm=marker
*** ../vim-8.2.0722/src/version.c   2020-05-09 17:35:50.052198310 +0200
--- src/version.c   2020-05-09 18:04:34.219108951 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 723,
  /**/

-- 

Patch 8.2.0722

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0722
Problem:Vim9: not handling constant expression for elseif.
Solution:   Use postponed constants.  Delete the code for evaluating a
constant expression.
Files:  src/vim9compile.c


*** ../vim-8.2.0721/src/vim9compile.c   2020-05-09 16:44:18.946423824 +0200
--- src/vim9compile.c   2020-05-09 17:30:53.357192919 +0200
***
*** 3310,3514 
  }
  }
  
- /*
-  * Evaluate an expression that is a constant:
-  *  has(arg)
-  *
-  * Also handle:
-  *  ! in frontlogical NOT
-  *
-  * Return FAIL if the expression is not a constant.
-  */
- static int
- evaluate_const_expr7(char_u **arg, cctx_T *cctx UNUSED, typval_T *tv)
- {
- typval_T  argvars[2];
- char_u*start_leader, *end_leader;
- int   has_call = FALSE;
- 
- /*
-  * Skip '!' characters.  They are handled later.
-  * TODO: '-' and '+' characters
-  */
- start_leader = *arg;
- while (**arg == '!')
-   *arg = skipwhite(*arg + 1);
- end_leader = *arg;
- 
- /*
-  * Recognize only a few types of constants for now.
-  */
- if (STRNCMP("true", *arg, 4) == 0 && !ASCII_ISALNUM((*arg)[4]))
- {
-   tv->v_type = VAR_BOOL;
-   tv->vval.v_number = VVAL_TRUE;
-   *arg += 4;
-   return OK;
- }
- if (STRNCMP("false", *arg, 5) == 0 && !ASCII_ISALNUM((*arg)[5]))
- {
-   tv->v_type = VAR_BOOL;
-   tv->vval.v_number = VVAL_FALSE;
-   *arg += 5;
-   return OK;
- }
- 
- if (STRNCMP("has(", *arg, 4) == 0)
- {
-   has_call = TRUE;
-   *arg = skipwhite(*arg + 4);
- }
- 
- if (**arg == '"')
- {
-   if (get_string_tv(arg, tv, TRUE) == FAIL)
-   return FAIL;
- }
- else if (**arg == '\'')
- {
-   if (get_lit_string_tv(arg, tv, TRUE) == FAIL)
-   return FAIL;
- }
- else
-   return FAIL;
- 
- if (has_call)
- {
-   *arg = skipwhite(*arg);
-   if (**arg != ')')
-   return FAIL;
-   *arg = *arg + 1;
- 
-   argvars[0] = *tv;
-   argvars[1].v_type = VAR_UNKNOWN;
-   tv->v_type = VAR_NUMBER;
-   tv->vval.v_number = 0;
-   f_has(argvars, tv);
-   clear_tv([0]);
- 
-   while (start_leader < end_leader)
-   {
-   if (*start_leader == '!')
-   tv->vval.v_number = !tv->vval.v_number;
-   ++start_leader;
-   }
- }
- else if (end_leader > start_leader)
- {
-   clear_tv(tv);
-   return FAIL;
- }
- 
- return OK;
- }
- 
- /*
-  **   number multiplication
-  */   number division
-  *%   number modulo
-  */
- static int
- evaluate_const_expr6(char_u **arg, cctx_T *cctx, typval_T *tv)
- {
- char_u*op;
- 
- // get the first variable
- if (evaluate_const_expr7(arg, cctx, tv) == FAIL)
-   return FAIL;
- 
- /*
-  * Repeat computing, until no "*", "/" or "%" is following.
-  */
- for (;;)
- {
-   op = skipwhite(*arg);
-   if (*op != '*' && *op != '/' && *op != '%')
-   break;
-   // TODO: not implemented yet.
-   clear_tv(tv);
-   return FAIL;
- }
- return OK;
- }
- 
- /*
-  *  + number addition
-  *  - number subtraction
-  *  ..string concatenation
-  */
- static int
- evaluate_const_expr5(char_u **arg, cctx_T *cctx, typval_T *tv)
- {
- char_u*op;
- int   oplen;
- 
- // get the first variable
- if (evaluate_const_expr6(arg, cctx, tv) == FAIL)
-   return FAIL;
- 
- /*
-  * Repeat computing, until no "+", "-" or ".." is following.
-  */
- for (;;)
- {
-   op = skipwhite(*arg);
-   if (*op != '+' && *op != '-' && !(*op == '.' && (*(*arg + 1) == '.')))
-   break;
-   oplen = (*op == '.' ? 2 : 1);
- 
-   if (!IS_WHITE_OR_NUL(**arg) || !IS_WHITE_OR_NUL(op[oplen]))
-   {
-   clear_tv(tv);
-   return FAIL;
-   }
- 
-   if (*op == '.' && tv->v_type == VAR_STRING)
-   {
-   typval_Ttv2;
-   size_t  len1;
-   char_u  *s1, *s2;
- 
-   tv2.v_type = VAR_UNKNOWN;
-   *arg = skipwhite(op + oplen);
- 
-   // TODO: what if we fail???
-   if (may_get_next_line(op + oplen, arg, cctx) == FAIL)
-   return FAIL;
- 
-   // get the second variable
-   if (evaluate_const_expr6(arg, cctx, ) == FAIL)
-   {
-   clear_tv(tv);
-   return FAIL;
-   }
-   if (tv2.v_type != VAR_STRING)
-   {
-   clear_tv(tv);
-   clear_tv();
-   return FAIL;
-   }
-   s1 = tv->vval.v_string;
-   len1 = STRLEN(s1);
-   s2 = tv2.vval.v_string;
-   tv->vval.v_string = alloc((int)(len1 + STRLEN(s2) + 1));
-   if (tv->vval.v_string == NULL)
-   {
-   vim_free(s1);
-   

Patch 8.2.0721

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0721
Problem:Vim9: leaking memory when skipping.
Solution:   Disable skipping in generate_ppconst().
Files:  src/vim9compile.c


*** ../vim-8.2.0720/src/vim9compile.c   2020-05-09 15:43:58.322878209 +0200
--- src/vim9compile.c   2020-05-09 16:43:09.214617402 +0200
***
*** 2417,2427 
--- 2417,2430 
  {
  int   i;
  int   ret = OK;
+ int   save_skip = cctx->ctx_skip;
  
+ cctx->ctx_skip = FALSE;
  for (i = 0; i < ppconst->pp_used; ++i)
if (generate_tv_PUSH(cctx, >pp_tv[i]) == FAIL)
ret = FAIL;
  ppconst->pp_used = 0;
+ cctx->ctx_skip = save_skip;
  return ret;
  }
  
***
*** 2754,2759 
--- 2757,2763 
++ppconst->pp_used;
return OK;
}
+   clear_tv([0]);
  }
  
  if (generate_ppconst(cctx, ppconst) == FAIL)
*** ../vim-8.2.0720/src/version.c   2020-05-09 16:11:30.316503475 +0200
--- src/version.c   2020-05-09 16:33:18.815976971 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 721,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
77. The phone company asks you to test drive their new PBX system

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005091444.049EilSb018384%40masaka.moolenaar.net.


Patch 8.2.0720

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0720
Problem:Occasional exit when encountering an X error. (Manfred Lotz)
Solution:   On an X error do not exit, do preserve files.
Files:  src/os_unix.c


*** ../vim-8.2.0719/src/os_unix.c   2020-04-28 21:58:25.174049447 +0200
--- src/os_unix.c   2020-05-09 16:08:34.461198762 +0200
***
*** 1544,1553 
  XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE);
  STRCAT(IObuff, _("\nVim: Got X error\n"));
  
! // We cannot print a message and continue, because no X calls are allowed
! // here (causes my system to hang).  Silently continuing might be an
! // alternative...
! preserve_exit();  // preserve files and exit
  
  return 0; // NOTREACHED
  }
--- 1544,1558 
  XGetErrorText(dpy, error_event->error_code, (char *)IObuff, IOSIZE);
  STRCAT(IObuff, _("\nVim: Got X error\n"));
  
! // In the GUI we cannot print a message and continue, because no X calls
! // are allowed here (causes my system to hang).  Silently continuing seems
! // like the best alternative.  Do preserve files, in case we crash.
! ml_sync_all(FALSE, FALSE);
! 
! #ifdef FEAT_GUI
! if (!gui.in_use)
! #endif
!   msg((char *)IObuff);
  
  return 0; // NOTREACHED
  }
*** ../vim-8.2.0719/src/version.c   2020-05-09 15:43:58.322878209 +0200
--- src/version.c   2020-05-09 16:03:01.670618000 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 720,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
76. Your ISP regards you as a business partner rather than as a customer.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005091411.049EBvxC010647%40masaka.moolenaar.net.


Patch 8.2.0719

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0719
Problem:Vim9: more expressions can be evaluated at compile time
Solution:   Recognize has('name').
Files:  src/vim9compile.c, src/testdir/test_vim9_disassemble.vim,
src/testdir/test_vim9_expr.vim


*** ../vim-8.2.0718/src/vim9compile.c   2020-05-08 19:10:30.782336716 +0200
--- src/vim9compile.c   2020-05-09 15:34:32.888630958 +0200
***
*** 136,144 
  static char e_var_notfound[] = N_("E1001: variable not found: %s");
  static char e_syntax_at[] = N_("E1002: Syntax error at %s");
  
! static int compile_expr1(char_u **arg,  cctx_T *cctx);
! static int compile_expr2(char_u **arg,  cctx_T *cctx);
! static int compile_expr3(char_u **arg,  cctx_T *cctx);
  static void delete_def_function_contents(dfunc_T *dfunc);
  static void arg_type_mismatch(type_T *expected, type_T *actual, int argidx);
  static int check_type(type_T *expected, type_T *actual, int give_msg);
--- 136,142 
  static char e_var_notfound[] = N_("E1001: variable not found: %s");
  static char e_syntax_at[] = N_("E1002: Syntax error at %s");
  
! static int compile_expr0(char_u **arg,  cctx_T *cctx);
  static void delete_def_function_contents(dfunc_T *dfunc);
  static void arg_type_mismatch(type_T *expected, type_T *actual, int argidx);
  static int check_type(type_T *expected, type_T *actual, int give_msg);
***
*** 744,767 
  }
  
  /*
!  * Generate an ISN_COMPARE* instruction with a boolean result.
   */
! static int
! generate_COMPARE(cctx_T *cctx, exptype_T exptype, int ic)
  {
  isntype_T isntype = ISN_DROP;
- isn_T *isn;
- garray_T  *stack = >ctx_type_stack;
- vartype_T type1;
- vartype_T type2;
- 
- RETURN_OK_IF_SKIP(cctx);
  
- // Get the known type of the two items on the stack.  If they are matching
- // use a type-specific instruction. Otherwise fall back to runtime type
- // checking.
- type1 = ((type_T **)stack->ga_data)[stack->ga_len - 2]->tt_type;
- type2 = ((type_T **)stack->ga_data)[stack->ga_len - 1]->tt_type;
  if (type1 == VAR_UNKNOWN)
type1 = VAR_ANY;
  if (type2 == VAR_UNKNOWN)
--- 742,755 
  }
  
  /*
!  * Get the instruction to use for comparing "type1" with "type2"
!  * Return ISN_DROP when failed.
   */
! static isntype_T
! get_compare_isn(exptype_T exptype, vartype_T type1, vartype_T type2)
  {
  isntype_T isntype = ISN_DROP;
  
  if (type1 == VAR_UNKNOWN)
type1 = VAR_ANY;
  if (type2 == VAR_UNKNOWN)
***
*** 796,802 
  {
semsg(_("E1037: Cannot use \"%s\" with %s"),
exptype == EXPR_IS ? "is" : "isnot" , vartype_name(type1));
!   return FAIL;
  }
  if (isntype == ISN_DROP
|| ((exptype != EXPR_EQUAL && exptype != EXPR_NEQUAL
--- 784,790 
  {
semsg(_("E1037: Cannot use \"%s\" with %s"),
exptype == EXPR_IS ? "is" : "isnot" , vartype_name(type1));
!   return ISN_DROP;
  }
  if (isntype == ISN_DROP
|| ((exptype != EXPR_EQUAL && exptype != EXPR_NEQUAL
***
*** 809,816 
  {
semsg(_("E1072: Cannot compare %s with %s"),
vartype_name(type1), vartype_name(type2));
!   return FAIL;
  }
  
  if ((isn = generate_instr(cctx, isntype)) == NULL)
return FAIL;
--- 797,829 
  {
semsg(_("E1072: Cannot compare %s with %s"),
vartype_name(type1), vartype_name(type2));
!   return ISN_DROP;
  }
+ return isntype;
+ }
+ 
+ /*
+  * Generate an ISN_COMPARE* instruction with a boolean result.
+  */
+ static int
+ generate_COMPARE(cctx_T *cctx, exptype_T exptype, int ic)
+ {
+ isntype_T isntype;
+ isn_T *isn;
+ garray_T  *stack = >ctx_type_stack;
+ vartype_T type1;
+ vartype_T type2;
+ 
+ RETURN_OK_IF_SKIP(cctx);
+ 
+ // Get the known type of the two items on the stack.  If they are matching
+ // use a type-specific instruction. Otherwise fall back to runtime type
+ // checking.
+ type1 = ((type_T **)stack->ga_data)[stack->ga_len - 2]->tt_type;
+ type2 = ((type_T **)stack->ga_data)[stack->ga_len - 1]->tt_type;
+ isntype = get_compare_isn(exptype, type1, type2);
+ if (isntype == ISN_DROP)
+   return FAIL;
  
  if ((isn = generate_instr(cctx, isntype)) == NULL)
return FAIL;
***
*** 2340,2345 
--- 2353,2443 
  return OK;
  }
  
+ // Structure passed between the compile_expr* functions to keep track of
+ // constants that have been parsed but for which no code was produced yet.  If
+ // possible expressions on these constants are applied at compile time.  If
+ // that is not possible, the code to push the constants needs to be generated
+ // before other instructions.
+ typedef struct {
+ typval_T  pp_tv[10];  // stack of ppconst constants
+ int   pp_used;// active entries in pp_tv[]
+ } ppconst_T;
+ 
+ /*
+  * Generate a PUSH 

Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie Bram Moolenaar


John Marriott wrote:

> After cleaning my vim source repo and rebuilding with the brand new gcc 
> 10.1 (mingw64), I get these warnings:
> 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return main.c -o gobjnative/main.o
> In file included from main.c:11:
> main.c: In function 'early_arg_scan':
> vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format [-Wformat=]
>    343 | # define SCANF_HEX_LONG_U "%Ix"
>    | ^

[...]

> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return dict.c -o gobjnative/dict.o
> In file included from dict.c:14:
> In function 'dictitem_copy',
>      inlined from 'dict_extend' at dict.c:936:9:
> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
> is out of the bounds of referenced subobject 'di_key'
>   with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
> [-Warray-bounds]
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
>    | ^~~~
> vim.h:1591:26: note: in definition of macro 'STRCPY'
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
>    | ^~
> In file included from vim.h:1815,
>   from dict.c:14:
> dict.c: In function 'dict_extend':
> structs.h:1466:12: note: subobject 'di_key' declared here
>   1466 | char_u di_key[1]; // key (actually longer!)
>    | ^~

This probably can't be avoided, the compiler doesn't see the "actually
longer" remark.  Perhaps GCC has an annotation to suppress the warning?

> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return evalvars.c -o gobjnative/evalvars.o
> evalvars.c: In function 'lookup_scriptvar':
> cc1.exe: warning: function may return address of local variable 
> [-Wreturn-local-addr]
> evalvars.c:2504:12: note: declared here
>   2504 | char_u buffer[30];
>    | ^~

I'll fix this one.
 
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return userfunc.c -o gobjnative/userfunc.o
> In file included from userfunc.c:14:
> In function 'cat_func_name',
>      inlined from 'get_user_func_name' at userfunc.c:3425:2:
> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
> is out of the bounds of referenced subobject 'uf_name
> ' with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
> [-Warray-bounds]
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
>    | ^~~~
> vim.h:1591:26: note: in definition of macro 'STRCPY'
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
>    | ^~
> In file included from vim.h:1815,
>   from userfunc.c:14:
> userfunc.c: In function 'get_user_func_name':
> structs.h:1569:12: note: subobject 'uf_name' declared here
>   1569 | char_u uf_name[1]; // name of function (actually longer); can
>    | ^~~
> 

Same reason, uf_name is used as the key in the function hashtable.

> I've had a look at the vim.h warning (the one from main.c). From what I 
> can gather the "I" in the "%Ix" and "%Iu" scan format strings is a 
> MS-specific thing. Anyhow, replacing the "I" with "z" in the format 
> strings (lines 343 to 345 in vim.h) makes the warnings go away (see the 
> attached patch).

This probably causes problems for other compilers, the format was like
this for a reason.  Is there an #ifdef we can use for gcc?

-- 
Proof techniques #2: Proof by Oddity.
SAMPLE: To prove that horses have an infinite number of legs.
(1) Horses have an even number of legs.
(2) They have two legs in back and fore legs in front.
(3) This makes a total of six legs, which certainly is an odd number of
legs for a horse.
(4) But the only number that is both odd and even is infinity.
(5) Therefore, horses must have an infinite number of legs.

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the 

Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie Ken Takata
Hi,

2020/5/9 Sat 20:06:48 UTC+9 Ken Takata wrote:
>
> Hi John,
>
> 2020/5/9 Sat 16:30:42 UTC+9 John Marriott wrote:
>>
>> Hi All, 
>>
>> After cleaning my vim source repo and rebuilding with the brand new gcc 
>> 10.1 (mingw64), I get these warnings: 
>>  
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return main.c -o gobjnative/main.o 
>> In file included from main.c:11: 
>> main.c: In function 'early_arg_scan': 
>> vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format 
>> [-Wformat=] 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ^ 
>> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ^ 
>> vim.h:343:36: note: format string is defined here 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ^ 
>> vim.h:343:33: warning: format '%x' expects argument of type 'unsigned 
>> int *', but argument 3 has type 'long_u *' {aka 'long lo 
>> ng unsigned int *'} [-Wformat=] 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ^ 
>> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ^ 
>> vim.h:343:36: note: format string is defined here 
>>343 | # define SCANF_HEX_LONG_U "%Ix" 
>>| ~~^ 
>>| | 
>>|unsigned int * 
>>| %Illx 
>> vim.h:344:33: warning: format '%u' expects argument of type 'unsigned 
>> int *', but argument 3 has type 'long_u *' {aka 'long lo 
>> ng unsigned int *'} [-Wformat=] 
>>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>| ^ 
>> vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U' 
>>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>| ^ 
>> vim.h:344:36: note: format string is defined here 
>>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>>| ~~^ 
>>| | 
>>|unsigned int * 
>>| %Illu 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return dict.c -o gobjnative/dict.o 
>> In file included from dict.c:14: 
>> In function 'dictitem_copy', 
>>  inlined from 'dict_extend' at dict.c:936:9: 
>> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
>> is out of the bounds of referenced subobject 'di_key' 
>>   with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
>> [-Warray-bounds] 
>>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>>| ^~~~ 
>> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>>| ^~ 
>> In file included from vim.h:1815, 
>>   from dict.c:14: 
>> dict.c: In function 'dict_extend': 
>> structs.h:1466:12: note: subobject 'di_key' declared here 
>>   1466 | char_u di_key[1]; // key (actually longer!) 
>>| ^~ 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return evalvars.c -o gobjnative/evalvars.o 
>> evalvars.c: In function 'lookup_scriptvar': 
>> cc1.exe: warning: function may return address of local variable 
>> [-Wreturn-local-addr] 
>> evalvars.c:2504:12: note: declared here 
>>   2504 | char_u buffer[30]; 
>>| ^~ 
>>
>> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
>> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
>> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
>> -freg-struct-return userfunc.c -o gobjnative/userfunc.o 
>> In file included from userfunc.c:14: 
>> In function 'cat_func_name', 
>>  inlined from 'get_user_func_name' at userfunc.c:3425:2: 
>> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
>> is out of the bounds of referenced subobject 'uf_name 
>> ' with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
>> [-Warray-bounds] 
>>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>>| ^~~~ 
>> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>>| ^~ 
>> In file included from vim.h:1815, 
>>   from userfunc.c:14: 
>> userfunc.c: In function 'get_user_func_name': 
>> structs.h:1569:12: note: subobject 'uf_name' declared here 
>>   1569 | char_u uf_name[1]; // name of function (actually longer); 
>> can 
>>| ^~~ 
>>  
>>
>> I've had a 

Patch 8.2.0718

2020-05-09 Fir de Conversatie Bram Moolenaar


Patch 8.2.0718
Problem:Gcc warning for returning pointer to local variable. (John
Marriott)
Solution:   Return another pointer.
Files:  src/evalvars.c


*** ../vim-8.2.0717/src/evalvars.c  2020-05-01 15:44:24.539895251 +0200
--- src/evalvars.c  2020-05-09 13:03:45.341313485 +0200
***
*** 2510,2515 
--- 2510,2516 
return NULL;
  if (len < sizeof(buffer) - 1)
  {
+   // avoid an alloc/free for short names
vim_strncpy(buffer, name, len);
p = buffer;
  }
***
*** 2529,2535 
  
  if (p != buffer)
vim_free(p);
! return res;
  }
  
  /*
--- 2530,2537 
  
  if (p != buffer)
vim_free(p);
! // Don't return "buffer", gcc complains.
! return res == NULL ? NULL : IObuff;
  }
  
  /*
*** ../vim-8.2.0717/src/version.c   2020-05-08 19:10:30.782336716 +0200
--- src/version.c   2020-05-09 13:05:30.168906376 +0200
***
*** 748,749 
--- 748,751 
  {   /* Add new patch number below this line */
+ /**/
+ 718,
  /**/

-- 
hundred-and-one symptoms of being an internet addict:
74. Your most erotic dreams are about cybersex

 /// Bram Moolenaar -- b...@moolenaar.net -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/202005091109.049B9qtK029662%40masaka.moolenaar.net.


Re: gcc 10.1 warnings

2020-05-09 Fir de Conversatie Ken Takata
Hi John,

2020/5/9 Sat 16:30:42 UTC+9 John Marriott wrote:
>
> Hi All, 
>
> After cleaning my vim source repo and rebuilding with the brand new gcc 
> 10.1 (mingw64), I get these warnings: 
>  
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return main.c -o gobjnative/main.o 
> In file included from main.c:11: 
> main.c: In function 'early_arg_scan': 
> vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format 
> [-Wformat=] 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ^ 
> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ^ 
> vim.h:343:36: note: format string is defined here 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ^ 
> vim.h:343:33: warning: format '%x' expects argument of type 'unsigned 
> int *', but argument 3 has type 'long_u *' {aka 'long lo 
> ng unsigned int *'} [-Wformat=] 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ^ 
> vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U' 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ^ 
> vim.h:343:36: note: format string is defined here 
>343 | # define SCANF_HEX_LONG_U "%Ix" 
>| ~~^ 
>| | 
>|unsigned int * 
>| %Illx 
> vim.h:344:33: warning: format '%u' expects argument of type 'unsigned 
> int *', but argument 3 has type 'long_u *' {aka 'long lo 
> ng unsigned int *'} [-Wformat=] 
>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>| ^ 
> vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U' 
>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>| ^ 
> vim.h:344:36: note: format string is defined here 
>344 | # define SCANF_DECIMAL_LONG_U "%Iu" 
>| ~~^ 
>| | 
>|unsigned int * 
>| %Illu 
>
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return dict.c -o gobjnative/dict.o 
> In file included from dict.c:14: 
> In function 'dictitem_copy', 
>  inlined from 'dict_extend' at dict.c:936:9: 
> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
> is out of the bounds of referenced subobject 'di_key' 
>   with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
> [-Warray-bounds] 
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>| ^~~~ 
> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>| ^~ 
> In file included from vim.h:1815, 
>   from dict.c:14: 
> dict.c: In function 'dict_extend': 
> structs.h:1466:12: note: subobject 'di_key' declared here 
>   1466 | char_u di_key[1]; // key (actually longer!) 
>| ^~ 
>
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return evalvars.c -o gobjnative/evalvars.o 
> evalvars.c: In function 'lookup_scriptvar': 
> cc1.exe: warning: function may return address of local variable 
> [-Wreturn-local-addr] 
> evalvars.c:2504:12: note: declared here 
>   2504 | char_u buffer[30]; 
>| ^~ 
>
> gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
> -DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
> -DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
> -freg-struct-return userfunc.c -o gobjnative/userfunc.o 
> In file included from userfunc.c:14: 
> In function 'cat_func_name', 
>  inlined from 'get_user_func_name' at userfunc.c:3425:2: 
> vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
> is out of the bounds of referenced subobject 'uf_name 
> ' with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
> [-Warray-bounds] 
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>| ^~~~ 
> vim.h:1591:26: note: in definition of macro 'STRCPY' 
>   1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s)) 
>| ^~ 
> In file included from vim.h:1815, 
>   from userfunc.c:14: 
> userfunc.c: In function 'get_user_func_name': 
> structs.h:1569:12: note: subobject 'uf_name' declared here 
>   1569 | char_u uf_name[1]; // name of function (actually longer); can 
>| ^~~ 
>  
>
> I've had a look at the vim.h warning (the one from main.c). From what I 
> can gather the "I" in the "%Ix" and "%Iu" scan format strings is a 
> MS-specific thing. Anyhow, replacing 

gcc 10.1 warnings

2020-05-09 Fir de Conversatie John Marriott

Hi All,

After cleaning my vim source repo and rebuilding with the brand new gcc 
10.1 (mingw64), I get these warnings:


gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
-freg-struct-return main.c -o gobjnative/main.o

In file included from main.c:11:
main.c: In function 'early_arg_scan':
vim.h:343:33: warning: 'I' flag used with '%x' gnu_scanf format [-Wformat=]
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ^
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ^
vim.h:343:36: note: format string is defined here
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ^
vim.h:343:33: warning: format '%x' expects argument of type 'unsigned 
int *', but argument 3 has type 'long_u *' {aka 'long lo

ng unsigned int *'} [-Wformat=]
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ^
vim.h:343:33: note: in definition of macro 'SCANF_HEX_LONG_U'
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ^
vim.h:343:36: note: format string is defined here
  343 | # define SCANF_HEX_LONG_U "%Ix"
  | ~~^
  | |
  |    unsigned int *
  | %Illx
vim.h:344:33: warning: format '%u' expects argument of type 'unsigned 
int *', but argument 3 has type 'long_u *' {aka 'long lo

ng unsigned int *'} [-Wformat=]
  344 | # define SCANF_DECIMAL_LONG_U "%Iu"
  | ^
vim.h:344:33: note: in definition of macro 'SCANF_DECIMAL_LONG_U'
  344 | # define SCANF_DECIMAL_LONG_U "%Iu"
  | ^
vim.h:344:36: note: format string is defined here
  344 | # define SCANF_DECIMAL_LONG_U "%Iu"
  | ~~^
  | |
  |    unsigned int *
  | %Illu

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
-freg-struct-return dict.c -o gobjnative/dict.o

In file included from dict.c:14:
In function 'dictitem_copy',
    inlined from 'dict_extend' at dict.c:936:9:
vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
is out of the bounds of referenced subobject 'di_key'
 with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
[-Warray-bounds]

 1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
  | ^~~~
vim.h:1591:26: note: in definition of macro 'STRCPY'
 1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
  | ^~
In file included from vim.h:1815,
 from dict.c:14:
dict.c: In function 'dict_extend':
structs.h:1466:12: note: subobject 'di_key' declared here
 1466 | char_u di_key[1]; // key (actually longer!)
  | ^~

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
-freg-struct-return evalvars.c -o gobjnative/evalvars.o

evalvars.c: In function 'lookup_scriptvar':
cc1.exe: warning: function may return address of local variable 
[-Wreturn-local-addr]

evalvars.c:2504:12: note: declared here
 2504 | char_u buffer[30];
  | ^~

gcc -c -I. -Iproto -DWIN32 -DWINVER=0x0603 -D_WIN32_WINNT=0x0603 
-DHAVE_PATHDEF -DFEAT_NORMAL -DHAVE_STDINT_H -DFEAT_GUI_MSWIN 
-DFEAT_CLIPBOARD -pipe -march=native -Wall -O3 -fomit-frame-pointer 
-freg-struct-return userfunc.c -o gobjnative/userfunc.o

In file included from userfunc.c:14:
In function 'cat_func_name',
    inlined from 'get_user_func_name' at userfunc.c:3425:2:
vim.h:1591:26: warning: 'strcpy' offset 0 from the object at '' 
is out of the bounds of referenced subobject 'uf_name
' with type 'char_u[1]' {aka 'unsigned char[1]'} at offset 0 
[-Warray-bounds]

 1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
  | ^~~~
vim.h:1591:26: note: in definition of macro 'STRCPY'
 1591 | #define STRCPY(d, s) strcpy((char *)(d), (char *)(s))
  | ^~
In file included from vim.h:1815,
 from userfunc.c:14:
userfunc.c: In function 'get_user_func_name':
structs.h:1569:12: note: subobject 'uf_name' declared here
 1569 | char_u uf_name[1]; // name of function (actually longer); can
  | ^~~


I've had a look at the vim.h warning (the one from main.c). From what I 
can gather the "I" in the "%Ix" and "%Iu" scan format strings is a 
MS-specific thing. Anyhow, replacing the "I" with "z" in the format 
strings (lines 343 to 345 in vim.h) makes the warnings go away (see the 
attached patch).


Not sure about the others at the moment.

Cheers
John

--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this