>From 5821ccc02d138bfcb9dcc4f39bfb2abe87c9d5ed Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 2 Nov 2018 14:09:35 -0700 Subject: [PATCH] gnulib-common.m4: port _Noreturn to C++ Problem reported by Akim Demaille in: https://lists.gnu.org/r/bug-bison/2018-10/msg00067.html * m4/gnulib-common.m4 (gl_COMMON_BODY): If C++, use [[noreturn]]. Merge adjustments from _Noreturn.h and from glibc into the non-C++ version. * lib/_Noreturn.h: Match gnulib-common. --- ChangeLog | 10 ++++++++++ lib/_Noreturn.h | 12 ++++++++---- m4/gnulib-common.m4 | 15 +++++++++------ 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 94f8e919f..bbf379b8c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-11-02 Paul Eggert + + gnulib-common.m4: port _Noreturn to C++ + Problem reported by Akim Demaille in: + https://lists.gnu.org/r/bug-bison/2018-10/msg00067.html + * m4/gnulib-common.m4 (gl_COMMON_BODY): If C++, use [[noreturn]]. + Merge adjustments from _Noreturn.h and from glibc into the non-C++ + version. + * lib/_Noreturn.h: Match gnulib-common. + 2018-10-30 Bruno Haible gnu-make: Fix for NetBSD 8 'make'. diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index c44ad89b7..94fdfaf02 100644 --- a/lib/_Noreturn.h +++ b/lib/_Noreturn.h @@ -1,8 +1,12 @@ -#if !defined _Noreturn && __STDC_VERSION__ < 201112 -# if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ - || 0x5110 <= __SUNPRO_C) +#ifndef _Noreturn +# if 201103 <= (defined __cplusplus ? __cplusplus : 0) +# define _Noreturn [[noreturn]] +# elif (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 <= _MSC_VER +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) # define _Noreturn __declspec (noreturn) # else # define _Noreturn diff --git a/m4/gnulib-common.m4 b/m4/gnulib-common.m4 index 1b8cdd567..2b253dabf 100644 --- a/m4/gnulib-common.m4 +++ b/m4/gnulib-common.m4 @@ -1,4 +1,4 @@ -# gnulib-common.m4 serial 40 +# gnulib-common.m4 serial 41 dnl Copyright (C) 2007-2018 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -16,12 +16,15 @@ AC_DEFUN([gl_COMMON], [ AC_DEFUN([gl_COMMON_BODY], [ AH_VERBATIM([_Noreturn], [/* 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) +#ifndef _Noreturn +# if 201103 <= (defined __cplusplus ? __cplusplus : 0) +# define _Noreturn [[noreturn]] +# elif (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 defined _MSC_VER && 1200 <= _MSC_VER +# elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0) # define _Noreturn __declspec (noreturn) # else # define _Noreturn -- 2.19.1