# HG changeset patch # User John W. Eaton # Date 1711600346 14400 # Node ID ab68bff7b8b8819eef68de1379f96fadcb581f71 # Parent 9a0bf9284128fc39b352b3c8f343996836b8e818 style fixes for panic_ functions * panic.h (panic_impossible, panic_if, panic_unless): If NDEBUG is defined, define away using "do { } while (0)" so that a semicolon is always required. Also allow panic_impossible to be defined away if NDEBUG is defined. * lo-error.h (liboctave_panic_impossible, liboctave_panic_if, liboctave_panic_unless): Likewise. diff -r 9a0bf9284128 -r ab68bff7b8b8 libinterp/corefcn/panic.h --- a/libinterp/corefcn/panic.h Wed Mar 27 23:44:46 2024 -0400 +++ b/libinterp/corefcn/panic.h Thu Mar 28 00:32:26 2024 -0400 @@ -41,19 +41,23 @@ // panic_impossible, panic_if, and panic_unless symbols must be defined // as macros. -#define panic_impossible() \ +#if defined (NDEBUG) + +# define panic_impossible() do { } while (0) + +# define panic_if(cond) do { } while (0) + +# define panic_unless(cond) do { } while (0) + +#else + +# define panic_impossible() \ ::panic ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__) -#if defined (NDEBUG) -# define panic_if(cond) -#else # define panic_if(cond) do { if (cond) panic_impossible (); } while (0) -#endif -#if defined (NDEBUG) -# define panic_unless(cond) -#else # define panic_unless(cond) panic_if (! (cond)) + #endif #endif diff -r 9a0bf9284128 -r ab68bff7b8b8 liboctave/util/lo-error.h --- a/liboctave/util/lo-error.h Wed Mar 27 23:44:46 2024 -0400 +++ b/liboctave/util/lo-error.h Thu Mar 28 00:32:26 2024 -0400 @@ -85,18 +85,22 @@ // liboctave_panic_impossible, liboctave_panic_if, and // liboctave_panic_unless symbols must be defined as macros. -#define liboctave_panic_impossible() (*current_liboctave_error_handler) ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__) +#if defined (NDEBUG) + +# define liboctave_panic_impossible() do { } while (0) + +# define liboctave_panic_if(cond) do { } while (0) -#if defined (NDEBUG) -# define liboctave_panic_if(cond) +# define liboctave_panic_unless(cond) do { } while (0) + #else + +# define liboctave_panic_impossible() (*current_liboctave_error_handler) ("impossible state reached in file '%s' at line %d", __FILE__, __LINE__) + # define liboctave_panic_if(cond) do { if (cond) liboctave_panic_impossible (); } while (0) -#endif -#if defined (NDEBUG) -# define liboctave_panic_unless(cond) -#else # define liboctave_panic_unless(cond) liboctave_panic_if (! (cond)) + #endif #if defined (__cplusplus)