From e6d83116aebbf3b03bc700cf6dad09c8d62c211e Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Sat, 16 May 2020 18:26:34 +0200 Subject: [PATCH] c: more fixes for _Noreturn The previous fix was insufficient. tests/types.at:366: $CXX $CXXFLAGS $CPPFLAGS $LDFLAGS -o test test.cc $LIBS ++ ccache clang++-mp-9.0 -Qunused-arguments -ggdb -Wall -Wextra -Wcast-align -Wchar-subscripts -fparse-all-comments -Wdocumentation -Wformat -Wimplicit-fallthrough -Wnull-dereference -Wno-sign-compare -Wno-tautological-constant-out-of-range-compare -Wpointer-arith -Wshadow -Wwrite-strings -Wextra-semi -Wold-style-cast -Wundefined-func-template -Wweak-vtables -Wunreachable-code -Wundef -pedantic -Wconversion -Wdeprecated -Wsign-compare -Wsign-conversion -Wtautological-constant-out-of-range-compare -fno-color-diagnostics -Wno-keyword-macro -Werror -std=c++98 -I/Users/akim/src/gnu/bison/tests -isystem /opt/gostai/include -isystem /opt/local/include -L/opt/gostai/lib -L/opt/local/lib -o test test.cc /Users/akim/src/gnu/bison/_build/c9d/lib/libbison.a -lintl -Wl,-framework -Wl,CoreFoundation stderr: test.cc:955:1: error: _Noreturn functions are a C11-specific feature [-Werror,-Wc11-extensions] _Noreturn static void ^ test.cc:963:1: error: _Noreturn functions are a C11-specific feature [-Werror,-Wc11-extensions] _Noreturn static void ^ 2 errors generated. * data/skeletons/c.m4 (b4_attribute_define): Do not use _Noreturn at all in C++, clang or not. --- data/skeletons/c.m4 | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index d9cc2d8b..3b00fbf6 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -359,13 +359,14 @@ m4_define([b4_attribute_define], dnl the use of [[noreturn]], because _Noreturn is used in places dnl where [[noreturn]] works in C++. We need this in particular dnl because of glr.cc which compiles code from glr.c in C++. -dnl And the C++ compiler chokes on _Noreturn. +dnl And the C++ compiler chokes on _Noreturn. Also, we do not +dnl use C' _Noreturn in C++, to avoid -Wc11-extensions warnings. [#ifndef _Noreturn # if (defined __cplusplus \ && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \ || (defined _MSC_VER && 1900 <= _MSC_VER))) # define _Noreturn [[noreturn]] -# elif ((!defined __cplusplus || defined __clang__) \ +# elif (!defined __cplusplus \ && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) \ || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \ || (defined __apple_build_version__ \