Re: C11 and C++11 support detection fails with clang

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

 



On 02/24/2016 10:51 AM, Nick Bowler wrote:
Right, the C11 standard says that the controlling expression of _Static_assert must be an integer constant expression.

Thanks, I installed the attached into autoconf master; it should fix these problems.
From d393c88f8f170c203052d1aacc7fb876b651ed4d Mon Sep 17 00:00:00 2001
From: Paul Eggert <eggert@cs.ucla.edu>
Date: Tue, 15 Mar 2016 08:56:43 -0700
Subject: [PATCH] Port C11 and C++11 testing to clang

* 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 | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index fe87dbf..933955f 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -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";
 }
 ]])
 
-- 
2.5.0

_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
https://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux