help-bison
[Top][All Lists]
Advanced

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

GLR causing warning about _Noreturn in C99


From: Joe Nelson
Subject: GLR causing warning about _Noreturn in C99
Date: Sun, 3 Jan 2021 12:23:38 -0600

When I enable %glr-parser, it generates two functions marked with
_Noreturn:

        _Noreturn static void
        yyFail (yyGLRStack* yystackp, void *scanner, const char* yymsg)

        _Noreturn static void
        yyMemoryExhausted (yyGLRStack* yystackp)

Since my compile flags include -std=c99 -pedantic, clang warns me:

        warning: _Noreturn functions are a C11-specific feature

The generated parser tries to define _Noreturn appropriately with these
preprocessor rules:

        /* The _Noreturn keyword of C11.  */
        #ifndef _Noreturn
        # if (defined __cplusplus \
                  && ((201103 <= __cplusplus && !(__GNUC__ == 4 && 
__GNUC_MINOR__ == 7)) \
                          || (defined _MSC_VER && 1900 <= _MSC_VER)))
        #  define _Noreturn [[noreturn]]
        # elif (!defined __cplusplus                     \
                        && (201112 <= (defined __STDC_VERSION__ ? 
__STDC_VERSION__ : 0)  \
                                || 4 < __GNUC__ + (7 <= __GNUC_MINOR__) \
                                || (defined __apple_build_version__ \
                                        ? 6000000 <= __apple_build_version__ \
                                        : 3 < __clang_major__ + (5 <= 
__clang_minor__))))
           /* _Noreturn works as-is.  */
        # elif 2 < __GNUC__ + (8 <= __GNUC_MINOR__) || 0x5110 <= __SUNPRO_C
        #  define _Noreturn __attribute__ ((__noreturn__))
        # elif 1200 <= (defined _MSC_VER ? _MSC_VER : 0)
        #  define _Noreturn __declspec (noreturn)
        # else
        #  define _Noreturn
        # endif
        #endif

However I confirmed it's hitting the condition marked
/* _Noreturn works as-is.  */
whereas I would like it to respect the value of __STDC_VERSION__ that I
set with the -std=c99 compiler flag. I'm not sure of the history behind
the preprocessor checks in that section, but maybe you could simplify
and go primarily by the stdc version?

Here are the values of the macros in my environment:

#define __GNUC__ 4
#define __GNUC_MINOR__ 2
#define __STDC_VERSION__ 199901L
#define __apple_build_version__ 10001145
#define __clang_major__ 10
#define __clang_minor__ 0

Here are my compiler and bison version:

Bison 3.7.4
Clang
        Apple LLVM version 10.0.0 (clang-1000.11.45.5)
        Target: x86_64-apple-darwin17.7.0



reply via email to

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