Resolve unused-result warnings for alloca(0)

* src/makeint.h (free_alloca): New macro to defeat warn_unused_result.
* src/read.c (eval_makefile): Call it.
(eval_buffer): Ditto.
* src/remake.c (update_file): Ditto.
This commit is contained in:
Paul Smith 2020-11-29 14:28:29 -05:00
parent cc20f90507
commit b262ea5d8f
3 changed files with 10 additions and 3 deletions

View File

@ -41,6 +41,13 @@ char *alloca ();
# endif
#endif
/* Some versions of GCC (e.g., 10.x) set the warn_unused_result attribute on
__builtin_alloca. This causes alloca(0) to fail and is not easily worked
around so make a helper.
See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98055 */
#define free_alloca() do{ void *__p = alloca (0); (void)__p; }while(0)
/* Disable assert() unless we're a maintainer.
Some asserts are compute-intensive. */
#ifndef MAKE_MAINTAINER_MODE

View File

@ -432,7 +432,7 @@ eval_makefile (const char *filename, unsigned short flags)
fclose (ebuf.fp);
free (ebuf.bufstart);
alloca (0);
free_alloca ();
errno = 0;
return deps;
@ -474,7 +474,7 @@ eval_buffer (char *buffer, const floc *flocp)
reading_file = curfile;
alloca (0);
free_alloca ();
}
/* Check LINE to see if it's a variable assignment or undefine.

View File

@ -337,7 +337,7 @@ update_file (struct file *file, unsigned int depth)
check_renamed (f);
/* Clean up any alloca() used during the update. */
alloca (0);
free_alloca ();
/* If we got an error, don't bother with double_colon etc. */
if (new && !keep_going_flag)