changeset 15667:df3eb2f0f1e8

msvc-inval: Require a semicolon after DONE_MSVC_INVAL. * lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Wrap in a do...while(0). * lib/dup2.c (rpl_dup2): Add a semicolon after DONE_MSVC_INVAL. Suggested by Paul Eggert.
author Bruno Haible <bruno@clisp.org>
date Tue, 20 Sep 2011 03:16:18 +0200
parents bbe6ab59b982
children d64334690661
files ChangeLog lib/dup2.c lib/msvc-inval.h
diffstat 3 files changed, 50 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2011-09-19  Bruno Haible  <bruno@clisp.org>
+
+	msvc-inval: Require a semicolon after DONE_MSVC_INVAL.
+	* lib/msvc-inval.h (TRY_MSVC_INVAL, DONE_MSVC_INVAL): Wrap in a
+	do...while(0).
+	* lib/dup2.c (rpl_dup2): Add a semicolon after DONE_MSVC_INVAL.
+	Suggested by Paul Eggert.
+
 2011-09-19  Bruno Haible  <bruno@clisp.org>
 
 	sched: Ensure pid_t is defined.
--- a/lib/dup2.c
+++ b/lib/dup2.c
@@ -57,7 +57,7 @@
         {
           handle = INVALID_HANDLE_VALUE;
         }
-      DONE_MSVC_INVAL
+      DONE_MSVC_INVAL;
 
       if (handle == INVALID_HANDLE_VALUE)
         {
@@ -88,7 +88,7 @@
       result = -1;
       errno = EBADF;
     }
-  DONE_MSVC_INVAL
+  DONE_MSVC_INVAL;
 
 # ifdef __linux__
   /* Correct a Linux return value.
--- a/lib/msvc-inval.h
+++ b/lib/msvc-inval.h
@@ -36,7 +36,7 @@
          <Code that handles an invalid parameter notification
           but does not do 'return', 'break', 'continue', nor 'goto'.>
        }
-     DONE_MSVC_INVAL
+     DONE_MSVC_INVAL;
 
    This entire block expands to a single statement.
  */
@@ -79,15 +79,17 @@
 #  endif
 
 #  define TRY_MSVC_INVAL \
-     {                                                                         \
-       gl_msvc_inval_ensure_handler ();                                        \
-       __try
+     do                                                                        \
+       {                                                                       \
+         gl_msvc_inval_ensure_handler ();                                      \
+         __try
 #  define CATCH_MSVC_INVAL \
-       __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER        \
-                 ? EXCEPTION_EXECUTE_HANDLER                                   \
-                 : EXCEPTION_CONTINUE_SEARCH)
+         __except (GetExceptionCode () == STATUS_GNULIB_INVALID_PARAMETER      \
+                   ? EXCEPTION_EXECUTE_HANDLER                                 \
+                   : EXCEPTION_CONTINUE_SEARCH)
 #  define DONE_MSVC_INVAL \
-     }
+       }                                                                       \
+     while (0)
 
 # else
 /* Any compiler.
@@ -119,27 +121,29 @@
 #  endif
 
 #  define TRY_MSVC_INVAL \
-     {                                                                         \
-       _invalid_parameter_handler orig_handler;                                \
-       /* First, initialize gl_msvc_inval_restart.  */                         \
-       if (setjmp (gl_msvc_inval_restart) == 0)                                \
-         {                                                                     \
-           /* Then, enable gl_msvc_invalid_parameter_handler.  */              \
-           orig_handler =                                                      \
-             _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler);
+     do                                                                        \
+       {                                                                       \
+         _invalid_parameter_handler orig_handler;                              \
+         /* First, initialize gl_msvc_inval_restart.  */                       \
+         if (setjmp (gl_msvc_inval_restart) == 0)                              \
+           {                                                                   \
+             /* Then, enable gl_msvc_invalid_parameter_handler.  */            \
+             orig_handler =                                                    \
+               _set_invalid_parameter_handler (gl_msvc_invalid_parameter_handler);
 #  define CATCH_MSVC_INVAL \
-           /* Execution completed.                                             \
-              Disable gl_msvc_invalid_parameter_handler.  */                   \
-           _set_invalid_parameter_handler (orig_handler);                      \
-         }                                                                     \
-       else                                                                    \
-         {                                                                     \
-           /* Execution triggered an invalid parameter notification.           \
-              Disable gl_msvc_invalid_parameter_handler.  */                   \
-           _set_invalid_parameter_handler (orig_handler);
+             /* Execution completed.                                           \
+                Disable gl_msvc_invalid_parameter_handler.  */                 \
+             _set_invalid_parameter_handler (orig_handler);                    \
+           }                                                                   \
+         else                                                                  \
+           {                                                                   \
+             /* Execution triggered an invalid parameter notification.         \
+                Disable gl_msvc_invalid_parameter_handler.  */                 \
+             _set_invalid_parameter_handler (orig_handler);
 #  define DONE_MSVC_INVAL \
-         }                                                                     \
-     }
+           }                                                                   \
+       }                                                                       \
+     while (0)
 
 # endif
 
@@ -148,9 +152,15 @@
 
 /* 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 TRY_MSVC_INVAL \
+    do                                                                         \
+      {                                                                        \
+        if (1)
+# define CATCH_MSVC_INVAL \
+        else
+# define DONE_MSVC_INVAL \
+      }                                                                        \
+    while (0)
 
 #endif