From 867d9ec87f5460a72e5d22fd599cf6a3adf09c45 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Mon, 19 Sep 2011 23:29:44 +0200 Subject: [PATCH] msvc-inval: Ensure the entire expansion is a single statement. * lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Add an extra pair of braces. --- ChangeLog | 6 ++++++ lib/msvc-inval.h | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5271f662a..617267350 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2011-09-19 Bruno Haible + + msvc-inval: Ensure the entire expansion is a single statement. + * lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Add an extra pair + of braces. + 2011-09-19 Jim Meyering tests: use printf, not echo in init.sh's warn_ function diff --git a/lib/msvc-inval.h b/lib/msvc-inval.h index 700c9451b..61f0f4667 100644 --- a/lib/msvc-inval.h +++ b/lib/msvc-inval.h @@ -29,14 +29,16 @@ TRY_MSVC_INVAL { + but does not do 'return', 'break', 'continue', nor 'goto'.> } CATCH_MSVC_INVAL { + but does not do 'return', 'break', 'continue', nor 'goto'.> } DONE_MSVC_INVAL + + This entire block expands to a single statement. */ #if HAVE_MSVC_INVALID_PARAMETER_HANDLER @@ -77,13 +79,15 @@ extern void gl_msvc_inval_ensure_handler (void); # endif # define TRY_MSVC_INVAL \ - gl_msvc_inval_ensure_handler (); \ - __try + { \ + gl_msvc_inval_ensure_handler (); \ + __try # define CATCH_MSVC_INVAL \ - __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ - ? EXCEPTION_EXECUTE_HANDLER \ - : EXCEPTION_CONTINUE_SEARCH) -# define DONE_MSVC_INVAL + __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER \ + ? EXCEPTION_EXECUTE_HANDLER \ + : EXCEPTION_CONTINUE_SEARCH) +# define DONE_MSVC_INVAL \ + } # else /* Any compiler. @@ -140,10 +144,13 @@ extern void cdecl gl_msvc_invalid_parameter_handler (const wchar_t *expression, # endif #else +/* A platform that does not need to the invalid parameter handler. */ -# define TRY_MSVC_INVAL if (1) +/* The braces here avoid GCC warnings like + "warning: suggest explicit braces to avoid ambiguous `else'". */ +# define TRY_MSVC_INVAL { if (1) # define CATCH_MSVC_INVAL else -# define DONE_MSVC_INVAL +# define DONE_MSVC_INVAL } #endif -- 2.11.0