summaryrefslogtreecommitdiff
path: root/lib/autoconf/c.m4
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2020-12-07 11:49:52 -0500
committerZack Weinberg <zackw@panix.com>2020-12-07 11:49:52 -0500
commitd132ea0278f574fbb3c8d433ea094e36ece73ba1 (patch)
treef38d3731a4e262658b35981efe7f0a306b54f4f7 /lib/autoconf/c.m4
parentb4ec547b86e6dd878d312cc79dddabce825a4492 (diff)
downloadautoconf-d132ea0278f574fbb3c8d433ea094e36ece73ba1.tar.gz
Add checks of __STDC__ and __STDC_VERSION__ to C conformance tests.
This makes the C conformance tests more consistent with the C++ conformance tests, and should also speed up cycling through the possible options to turn on C99/C11. Tested with gcc, clang, SunPRO C, and AIX xlc. * lib/autoconf/c.m4 (_AC_C_C89_TEST_GLOBALS): Add preprocessor test for __STDC__ being defined (to any value). (_AC_C_C99_TEST_GLOBALS, _AC_C_C11_TEST_GLOBALS): Add preprocessor test of the value of __STDC_VERSION__.
Diffstat (limited to 'lib/autoconf/c.m4')
-rw-r--r--lib/autoconf/c.m417
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/autoconf/c.m4 b/lib/autoconf/c.m4
index d4bed687..7984f25f 100644
--- a/lib/autoconf/c.m4
+++ b/lib/autoconf/c.m4
@@ -1143,6 +1143,13 @@ AC_DEFUN([_AC_C_C89_TEST_GLOBALS],
[m4_divert_text([INIT_PREPARE],
[[# Test code for whether the C compiler supports C89 (global declarations)
ac_c_conftest_c89_globals='
+/* Does the compiler advertise C89 conformance?
+ Do not test the value of __STDC__, because some compilers set it to 0
+ while being otherwise adequately conformant. */
+#if !defined __STDC__
+# error "Compiler does not advertise C89 conformance"
+#endif
+
#include <stddef.h>
#include <stdarg.h>
struct stat;
@@ -1198,6 +1205,11 @@ AC_DEFUN([_AC_C_C99_TEST_GLOBALS],
[m4_divert_text([INIT_PREPARE],
[[# Test code for whether the C compiler supports C99 (global declarations)
ac_c_conftest_c99_globals='
+// Does the compiler advertise C99 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
+# error "Compiler does not advertise C99 conformance"
+#endif
+
#include <stdbool.h>
extern int puts (const char *);
extern int printf (const char *, ...);
@@ -1345,6 +1357,11 @@ AC_DEFUN([_AC_C_C11_TEST_GLOBALS],
[m4_divert_text([INIT_PREPARE],
[[# Test code for whether the C compiler supports C11 (global declarations)
ac_c_conftest_c11_globals='
+// Does the compiler advertise C11 conformance?
+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L
+# error "Compiler does not advertise C11 conformance"
+#endif
+
// Check _Alignas.
char _Alignas (double) aligned_as_double;
char _Alignas (0) no_special_alignment;