From 01855ca328065fb9999d419a52d46731904a197f Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Thu, 14 Mar 2019 13:26:57 +0100 Subject: [PATCH] warnings: don't use _Noreturn with G++ 4.7 in C++98 mode The timevar and bitset modules now use the c99 module which causes $CXX to now include -std=gnu++11 when possible. Unfortunately, G++ 4.7 does not implement [[noreturn]] in C++11 mode, so our tests of glr.cc (which uses _Noreturn) fail with input.cc:954:1: error: expected unqualified-id before '[' token right before [[noreturn]]. 4.8 works fine. * data/skeletons/c.m4 (b4_attribute_define): Do not use [[noreturn]] with GCC 4.7. --- README-hacking | 18 ++++++++++++++++++ data/skeletons/c.m4 | 26 +++++++++++++++----------- m4/.gitignore | 1 + 3 files changed, 34 insertions(+), 11 deletions(-) diff --git a/README-hacking b/README-hacking index 172566c0..ff701e99 100644 --- a/README-hacking +++ b/README-hacking @@ -288,6 +288,24 @@ release: - Test with a very recent version of GCC for both C and C++. Testing with older versions that are still in use is nice too. +** gnulib +To run tests on gnulib components (e.g., on bitset): + + cd gnulib + ./gnulib-tool --test bitset-tests + +possibly within a specified environment: + + CC='gcc-mp-8 -fsanitize=undefined' ./gnulib-tool --test bitset-tests + +To be able to run the tests several times, and to use symlinks instead of +copies so that one can update the origin gnulib directory and immediately +re-run the tests, run: + + ./gnulib-tool --symlink --create-test --dir=/tmp/gnutest bitset-tests + cd /tmp/gnutest + ./configure CC='gcc-mp-8 -fsanitize=undefined' + make check * Release Procedure This section needs to be updated to take into account features from gnulib. diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 3cde04a9..60c36687 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -229,18 +229,22 @@ m4_define([b4_attribute_define], #endif ]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */ -#if ! defined _Noreturn -# if defined __cplusplus && 201103L <= __cplusplus +]dnl This is an exact copy of lib/_Noreturn.h. +[#ifndef _Noreturn +# if (defined __cplusplus \ + && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ + || (defined _MSC_VER && 1900 <= _MSC_VER))) # define _Noreturn [[noreturn]] -# elif !(defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__) -# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ - || 0x5110 <= __SUNPRO_C) -# define _Noreturn __attribute__ ((__noreturn__)) -# elif defined _MSC_VER && 1200 <= _MSC_VER -# define _Noreturn __declspec (noreturn) -# else -# define _Noreturn -# endif +# elif ((!defined __cplusplus || defined __clang__) \ + && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ + || 4 < __GNUC__ + (7 <= __GNUC_MINOR__))) + /* _Noreturn works as-is. */ +# elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C +# define _Noreturn __attribute__ ((__noreturn__)) +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn # endif #endif diff --git a/m4/.gitignore b/m4/.gitignore index a66d8661..f8c49fc6 100644 --- a/m4/.gitignore +++ b/m4/.gitignore @@ -198,3 +198,4 @@ /libtextstyle.m4 /rename.m4 /rmdir.m4 +/std-gnu11.m4