From f8cadc731b0df0df9e93d009d5e96b0f752a9b3c Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Wed, 31 Oct 2018 09:25:04 +0100 Subject: [PATCH] c: provide a definition of _Noreturn that works for C++ On Solaris, GCC 7.3 defines: -std=c++14 -std=c++17 __cplusplus 201402L 201703L __STDC_VERSION__ 199901L 201112L So the current #definition of _Noreturn sees that 201112 <= __STDC_VERSION__, i.e., that C11 is supported, so it expects _Noreturn to be supported. Apparently it is not. This is only for C++, the test suite works for C. However, the test suite does not try several C standards, maybe we should... http://lists.gnu.org/archive/html/bug-bison/2018-10/msg00064.html * data/c.m4 (b4_attribute_define): Define _Noreturn as [[noreturn]] in modern C++. --- data/c.m4 | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/data/c.m4 b/data/c.m4 index 04df3ffc..bb19b348 100644 --- a/data/c.m4 +++ b/data/c.m4 @@ -228,15 +228,18 @@ m4_define([b4_attribute_define], #endif ]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11. */ -#if ! (defined _Noreturn \ - || (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 +#if ! defined _Noreturn +# if defined __cplusplus && 201103L <= __cplusplus +# 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 # endif #endif