]> git.ipfire.org Git - thirdparty/autoconf.git/commit
Don’t use hosted headers when testing for C(++) standard level (#110393)
authorZack Weinberg <zackw@panix.com>
Sun, 6 Dec 2020 17:23:41 +0000 (12:23 -0500)
committerZack Weinberg <zackw@panix.com>
Sun, 6 Dec 2020 21:43:26 +0000 (16:43 -0500)
commit131d8c69f31dc6fc8dc93abe1096d52d1fe19fd3
treef34c4134e70b5d3cc130e2b550d25344a0699716
parentb045574cb2ea1c8441be7a7b56fd471d704ebf3a
Don’t use hosted headers when testing for C(++) standard level (#110393)

The tests for the level of the C and C++ standard supported by their
respective compilers should also avoid using any headers that are not
guaranteed to be available in the respective freestanding environment.

Unlike the previous change, the only user-visible consequence of this
one should be that C11/C99/C89/C++11/C++98 *compiler* support is now
correctly detected when the compilation target is a freestanding
environment.

This patch also refactors how we “emit [the text of the C/C++
standard-conformance test programs] only once per [configure script],
into shell variables which can then be referenced repeatedly,” from
c3853873, because editing them just a little made the M4 quotation
break.  Clearly too fragile.

I believe this completes the fix for bug #110393.

* lib/autoconf/c.m4 (_AC_PROG_CC_C89, _AC_PROG_CC_C99, _AC_PROG_CC_C11)
  _AC_C_C99_TEST_HEADER, _AC_C_C99_TEST_BODY): Move all test program
  fragments into new macros that can be AC_REQUIREd individually:
  _AC_C_C89_TEST_GLOBALS, _AC_C_C89_TEST_MAIN, _AC_C_C89_TEST_PROGRAM,
  _AC_C_C99_TEST_GLOBALS, _AC_C_C99_TEST_MAIN, _AC_C_C99_TEST_PROGRAM,
  _AC_C_C11_TEST_GLOBALS, _AC_C_C11_TEST_MAIN, _AC_C_C11_TEST_PROGRAM.
  Each emits test code at most once, into a shell variable in the
  INIT_PREPARE diversion.
  Revise each test program to use only library features of the
  respective standard’s freestanding environment.
  (_AC_C_STD_TRY): Take the *name* of the shell variable holding the
  complete test program as an argument, not the code itself.  All
  callers adjusted to match.

  (_AC_PROG_CXX_CXX98, _AC_PROG_CXX_CXX11, _AC_CXX_STD_TRY)
  (_AC_CXX_CXX98_TEST_HEADER, _AC_CXX_CXX98_TEST_BODY)
  (_AC_CXX_CXX11_TEST_HEADER, _AC_CXX_CXX11_TEST_BODY): Similarly.
  New macros are:
  _AC_CXX_CXX98_TEST_GLOBALS, _AC_CXX_CXX98_TEST_MAIN,
  _AC_CXX_CXX98_TEST_PROGRAM,
  _AC_CXX_CXX11_TEST_GLOBALS, _AC_CXX_CXX11_TEST_MAIN,
  _AC_CXX_CXX11_TEST_PROGRAM.
lib/autoconf/c.m4