help-bison
[Top][All Lists]
Advanced

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

Re: GLR causing warning about _Noreturn in C99


From: Akim Demaille
Subject: Re: GLR causing warning about _Noreturn in C99
Date: Wed, 6 Jan 2021 07:04:06 +0100

Hi Joe,

Thanks for the report.

> Le 3 janv. 2021 à 19:23, Joe Nelson <joe@begriffs.com> a écrit :
> 
> 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

This piece of code comes from gnulib (well, it was copied-pasted from
there). This place is touchy and already pretty hairy. I don't want to
depart from what gnulib does.  After all, this is only a warning.

If Paul wants to give it a shot, that would be fine.  But I won't.

Cheers!


reply via email to

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