bison-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

c: restore definition of _Noreturn as [[noreturn]] in C++


From: Akim Demaille
Subject: c: restore definition of _Noreturn as [[noreturn]] in C++
Date: Sat, 16 May 2020 17:31:57 +0200

commit 22c38391682bb2cb95a7014e87785afbcb41efe1
Author: Akim Demaille <address@hidden>
Date:   Sat May 16 17:24:31 2020 +0200

    c: restore definition of _Noreturn as [[noreturn]] in C++
    
    c.m4 contains a definition of _Noreturn which is modeled after
    gnulib's lib/_Noreturn.h.  The latter was recently
    changed (b61bf2f0e8bdc1e522ae8e97d57d5625163b42ea) to not using
    [[noreturn]] at all, because the uses of _Noreturn in gnulib are
    sometimes incompatible with the rules of [[noreturn]].
    
    As a result glr.cc started to use _Noreturn in C++, which clang
    refuses (all the glr.cc tests currently fail with Clang++).
    
    * data/skeletons/c.m4 (b4_attribute_define): Restore the definition of
    _Noreturn as [[noreturn]] in modern C++.
    The generated code uses _Noreturn in places where [[noreturn]] is
    valid.

diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index f2d7b32f..d9cc2d8b 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -355,18 +355,15 @@ m4_define([b4_attribute_define],
 #endif
 
 ]m4_bmatch([$1], [\bnoreturn\b], [[/* The _Noreturn keyword of C11.  */
-]dnl This is an exact copy of lib/_Noreturn.h.
+]dnl This is close to lib/_Noreturn.h, except that we do enable
+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.
 [#ifndef _Noreturn
 # if (defined __cplusplus \
       && ((201103 <= __cplusplus && !(__GNUC__ == 4 && __GNUC_MINOR__ == 7)) \
-          || (defined _MSC_VER && 1900 <= _MSC_VER)) \
-      && 0)
-    /* [[noreturn]] is not practically usable, because with it the syntax
-         extern _Noreturn void func (...);
-       would not be valid; such a declaration would only be valid with 'extern'
-       and '_Noreturn' swapped, or without the 'extern' keyword.  However, some
-       AIX system header files and several gnulib header files use precisely
-       this syntax with 'extern'.  */
+          || (defined _MSC_VER && 1900 <= _MSC_VER)))
 #  define _Noreturn [[noreturn]]
 # elif ((!defined __cplusplus || defined __clang__)                     \
         && (201112 <= (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0)  \




reply via email to

[Prev in Thread] Current Thread [Next in Thread]