]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Resolve unused-result warnings for alloca(0)
authorPaul Smith <psmith@gnu.org>
Sun, 29 Nov 2020 19:28:29 +0000 (14:28 -0500)
committerPaul Smith <psmith@gnu.org>
Sun, 29 Nov 2020 22:59:40 +0000 (17:59 -0500)
* 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.

src/makeint.h
src/read.c
src/remake.c

index edd34ad8ca5e7b31176a6330e173fc2cb1d2fd30..c4cc4dfddbaf593e3698e773cdd9b727f83d2f5b 100644 (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
index 95033a6b115ff765b8729d7e524d053eb07c9a9a..b66f3d4a46626ef3a98cae25dc0242b7cc4ede7d 100644 (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 ();
 }
 \f
 /* Check LINE to see if it's a variable assignment or undefine.
index fb237c5e2c321175dd05ad279e16cf9abfe67eb8..beaf7e054ac4a709f1a0b1a17c0884a97bbd3b93 100644 (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)