[Mesa-dev] [PATCH 1/2] mesa: Add unreachable macro.
Matt Turner
mattst88 at gmail.com
Tue Nov 5 10:45:33 PST 2013
On Mon, Nov 4, 2013 at 4:43 PM, Matt Turner <mattst88 at gmail.com> wrote:
> ---
> src/mesa/main/compiler.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/src/mesa/main/compiler.h b/src/mesa/main/compiler.h
> index 61ce5db..6a25bf5 100644
> --- a/src/mesa/main/compiler.h
> +++ b/src/mesa/main/compiler.h
> @@ -252,6 +252,21 @@ static INLINE GLuint CPU_TO_LE32(GLuint x)
> (void) sizeof(char [1 - 2*!(COND)]); \
> } while (0)
>
> +/**
> + * Unreachable macro. Useful for suppressing "control reaches end of non-void
> + * function" warnings.
> + */
> +#if __GNUC__ >= 4 && __GNUC_MINOR__ >= 5
> +#define unreachable __builtin_unreachable()
> +#elif (defined(__clang__) && defined(__has_builtin))
> +# if __has_builtin(__builtin_unreachable)
> +# define unreachable __builtin_unreachable()
> +# endif
> +#endif
> +
> +#ifndef unreachable
> +#define unreachable
> +#endif
>
> #if (__GNUC__ >= 3)
> #define PRINTFLIKE(f, a) __attribute__ ((format(__printf__, f, a)))
> --
> 1.8.3.2
>
I'm actually going to change these to 'unreachable()' so it looks less funny.
More information about the mesa-dev
mailing list