From: Paul Eggert <eggert@cs.ucla.edu> Date: Fri, 2 Nov 2018 21:09:35 +0000 (-0700) Subject: gnulib-common.m4: port _Noreturn to C++ X-Git-Tag: v1.0~5302 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=df396b2c93b704ade1089dc22f062d9f9d6924b8;p=gnulib.git 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. --- diff --git a/ChangeLog b/ChangeLog index 94f8e919fc..bbf379b8c7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2018-11-02 Paul Eggert <eggert@cs.ucla.edu> + + 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 <bruno@clisp.org> gnu-make: Fix for NetBSD 8 'make'. diff --git a/lib/_Noreturn.h b/lib/_Noreturn.h index c44ad89b7c..94fdfaf022 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 1b8cdd567c..2b253dabf5 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