autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

const/volatile vs. -Werror


From: Eric Blake
Subject: const/volatile vs. -Werror
Date: Fri, 07 Apr 2006 06:46:22 -0600
User-agent: Thunderbird 1.5 (Windows/20051201)

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

This patch allows:
./testsuite -d -k 'C keywords' CFLAGS='-Wall -Werror'
to succeed with gcc 3.4.4.  There were so many tests in AC_C_CONST, some
with duplicate names but different scopes, that I relettered the local
variables.

2006-04-07  Eric Blake  <address@hidden>

        * lib/autoconf/c.m4 (AC_C_CONST, AC_C_VOLATILE): Avoid warnings
        from gcc.

- --
Life is short - so eat dessert first!

Eric Blake             address@hidden
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Public key at home.comcast.net/~ericblake/eblake.gpg
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFENl8e84KuGfSFAYARAvT9AKDUfbeg3MN4SsDp2nwuLDBO8vjjQQCdHhCF
DLe+ZwXqXaPXIjSaFUV+Qjc=
=8MwQ
-----END PGP SIGNATURE-----
Index: lib/autoconf/c.m4
===================================================================
RCS file: /sources/autoconf/autoconf/lib/autoconf/c.m4,v
retrieving revision 1.220
diff -u -p -r1.220 c.m4
--- lib/autoconf/c.m4   6 Apr 2006 11:24:00 -0000       1.220
+++ lib/autoconf/c.m4   7 Apr 2006 12:31:32 -0000
@@ -1439,47 +1439,43 @@ AC_DEFUN([AC_C_CONST],
 #ifndef __cplusplus
   /* Ultrix mips cc rejects this.  */
   typedef int charset[2];
-  const charset x;
+  const charset a;
   /* SunOS 4.1.1 cc rejects this.  */
   char const *const *ccp;
   char **p;
   /* NEC SVR4.0.2 mips cc rejects this.  */
   struct point {int x, y;};
-  static struct point const zero = {0,0};
+  static struct point const b = {0,0};
   /* AIX XL C 1.02.0.0 rejects this.
      It does not let you subtract one const X* pointer from another in
      an arm of an if-expression whose if-part is not a constant
      expression */
-  const char *g = "string";
-  ccp = &g + (g ? g-g : 0);
+  const char *c = "string";
+  ccp = &c + (c ? c-c : 0);
   /* HPUX 7.0 cc rejects these. */
   ++ccp;
   p = (char**) ccp;
   ccp = (char const *const *) p;
-  { /* SCO 3.2v4 cc rejects this.  */
-    char *t;
-    char const *s = 0 ? (char *) 0 : (char const *) 0;
-
-    *t++ = 0;
-  }
-  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
-    int x[] = {25, 17};
-    const int *foo = &x[0];
-    ++foo;
-  }
-  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+  /* SCO 3.2v4 cc rejects this.  */
+  char *d;
+  char const *e = 0 ? (char *) 0 : (char const *) 0;
+  *d++ = 0;
+  /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+  int f[] = {25, 17};
+  const int *g = &f[0];
+  ++g;
+  /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
     typedef const int *iptr;
-    iptr p = 0;
-    ++p;
-  }
-  { /* AIX XL C 1.02.0.0 rejects this saying
+  iptr h = 0;
+  ++h;
+  /* AIX XL C 1.02.0.0 rejects this saying
        "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
     struct s { int j; const int *ap[3]; };
-    struct s *b; b->j = 5;
-  }
-  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
-    const int foo = 10;
-  }
+  struct s *i; i->j = 5;
+  /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+  const int j = 10;
+  /* Refer to all variables to avoid compiler warnings.  */
+  return !a[0] && !b.x && !c && !d && !e && !f && !g && !h && !i->j && !j;
 #endif
 ]])],
                   [ac_cv_c_const=yes],
@@ -1546,8 +1542,9 @@ AN_IDENTIFIER([volatile], [AC_C_VOLATILE
 AC_DEFUN([AC_C_VOLATILE],
 [AC_CACHE_CHECK([for working volatile], ac_cv_c_volatile,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
-volatile int x;
-int * volatile y;])],
+volatile int x = 0;
+int * volatile y = (int *) 0;
+return !x && !y;])],
                   [ac_cv_c_volatile=yes],
                   [ac_cv_c_volatile=no])])
 if test $ac_cv_c_volatile = no; then


reply via email to

[Prev in Thread] Current Thread [Next in Thread]