Commit 220ea09c authored by Matthias Braun's avatar Matthias Braun
Browse files

fix C11/msvc build by differentiating between FIRM_NORETURN and FIRM_NORETURN_FUNCPTR

parent 864cb07b
......@@ -38,16 +38,28 @@
* @def FIRM_NORETURN
* Attribute to mark a function which never returns.
*/
#if defined(__STDC__) && (__STDC_VERSION__ >= 201112L)
#if defined(__GNUC__) && __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 70)
# define FIRM_NORETURN __attribute__((__noreturn__)) void
#elif defined(__STDC__) && (__STDC_VERSION__ >= 201112L)
# define FIRM_NORETURN _Noreturn void
#elif defined(__GNUC__)
# if __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 70)
# define FIRM_NORETURN __attribute__((__noreturn__)) void
# endif
#elif defined(_MSC_VER)
# define FIRM_NORETURN void __declspec(noreturn)
#else
# define FIRM_NORETURN void
#endif
/**
* @def FIRM_NORETURN_FUNCPTR
* Attribute to mark a function pointers target as noreturn.
*
* Unfortunately some platforms only allow noreturn on functions but not on
* function pointer targets making it necessary to have FIRM_NORETURN and
* FIRM_NORETURN_FUNCPTR.
*/
#if defined(__GNUC__) && __GNUC__ >= 3 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 70)
# define FIRM_NORETURN_FUNCPTR __attribute__((__noreturn__)) void
#else
# define FIRM_NORETURN_FUNCPTR void
#endif
#endif
......@@ -208,7 +208,7 @@ FIRM_API void obstack_free (struct obstack *obstack, void *block);
more memory. This can be set to a user defined function which
should either abort gracefully or use longjump - but shouldn't
return. The default action is to print a message and abort. */
FIRM_API FIRM_NORETURN (*obstack_alloc_failed_handler) (void);
FIRM_API FIRM_NORETURN_FUNCPTR (*obstack_alloc_failed_handler) (void);
/* Exit value used when `print_and_abort' is used. */
FIRM_API int obstack_exit_failure;
......
......@@ -65,7 +65,7 @@ enum
variable by default points to the internal function
`print_and_abort'. */
static FIRM_NORETURN print_and_abort (void);
FIRM_NORETURN (*obstack_alloc_failed_handler) (void) = print_and_abort;
FIRM_NORETURN_FUNCPTR (*obstack_alloc_failed_handler) (void) = print_and_abort;
/* Exit value used when `print_and_abort' is used. */
# include <stdlib.h>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment