]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Port AC_C_CONST to GCC 16 -Wunused-but-set-variable
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Aug 2025 16:03:21 +0000 (09:03 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 7 Aug 2025 16:10:03 +0000 (09:10 -0700)
Problem reported by Vincent Lefevre in:
https://lists.gnu.org/r/autoconf-patches/2025-08/msg00001.html
https://lists.gnu.org/r/autoconf-patches/2025-08/msg00002.html
* lib/autoconf/c.m4 (AC_C_CONST): Combine two tests, use
the set variable, and don’t try to add 1 to a null pointer.

lib/autoconf/c.m4

index bafa72c1cde7dffdd99bb6374b54543486e7de0e..12c9a5c51bd41054c4f4dbea71588fdb2b662dea 100644 (file)
@@ -2137,15 +2137,12 @@ AC_DEFUN([AC_C_CONST],
     *t++ = 0;
     if (s) return 0;
   }
-  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+  { /* Derived from code rejected by Sun C 1.0 and similar vintage.  */
     int x[] = {25, 17};
-    const int *foo = &x[0];
+    typedef int const *iptr;
+    iptr foo = &x[0];
     ++foo;
-  }
-  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
-    typedef const int *iptr;
-    iptr p = 0;
-    ++p;
+    if (!*foo) return 0;
   }
   { /* IBM XL C 1.02.0.0 rejects this sort of thing, saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */