]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Port C11 and C++11 testing to clang
authorPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2016 15:56:43 +0000 (08:56 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Tue, 15 Mar 2016 15:57:10 +0000 (08:57 -0700)
* lib/autoconf/c.m4 (_AC_C_C99_TEST_HEADER):
Include stddef.h, for offsetof.
(_AC_PROG_CC_C11): Limit _Static_assert to integer constant
expressions.  Suggested by Nick Bowler in:
http://lists.gnu.org/archive/html/autoconf/2016-02/msg00009.html
(_AC_CXX_CXX11_TEST_BODY): Don't use string literals to initialize
non-const pointers.  Suggested by Mike Miller in:
http://lists.gnu.org/archive/html/autoconf/2016-02/msg00008.html

lib/autoconf/c.m4

index fe87dbfa6c69c406c4fba527d2e1530e7916a9bb..933955f17015916da6b5b69678368c7da99c4740 100644 (file)
@@ -1205,6 +1205,7 @@ AS_IF([test "x$ac_cv_prog_cc_$1" != xno], [$5], [$6])
 AC_DEFUN([_AC_C_C99_TEST_HEADER],
 [[#include <stdarg.h>
 #include <stdbool.h>
+#include <stddef.h>
 #include <stdlib.h>
 #include <wchar.h>
 #include <stdio.h>
@@ -1439,7 +1440,9 @@ struct anonymous
 [_AC_C_C99_TEST_BODY[
   v1.i = 2;
   v1.w.k = 5;
-  _Static_assert (&v1.i == &v1.w.k, "Anonymous union alignment botch");
+  _Static_assert ((offsetof (struct anonymous, i)
+                  == offsetof (struct anonymous, w.k)),
+                 "Anonymous union alignment botch");
 ]],
 dnl Try
 dnl GCC                -std=gnu11 (unused restrictive mode: -std=c11)
@@ -2453,9 +2456,9 @@ AC_DEFUN([_AC_CXX_CXX11_TEST_BODY],
 }
 {
   // Unicode literals
-  char *utf8 = u8"UTF-8 string \u2500";
-  char16_t *utf16 = u"UTF-8 string \u2500";
-  char32_t *utf32 = U"UTF-32 string \u2500";
+  char const *utf8 = u8"UTF-8 string \u2500";
+  char16_t const *utf16 = u"UTF-8 string \u2500";
+  char32_t const *utf32 = U"UTF-32 string \u2500";
 }
 ]])