compiler.h: watcom_switch_hack() improvements

Avoid type promotion due to ?:, and put in a comment to explain what
the heck the purpose is of wrapping default in a macro.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin 2017-02-23 17:25:31 -08:00
parent e3cd70bc46
commit be01d496d4

View File

@ -1,6 +1,6 @@
/* ----------------------------------------------------------------------- *
*
* Copyright 2007-2016 The NASM Authors - All Rights Reserved
* Copyright 2007-2017 The NASM Authors - All Rights Reserved
* See the file AUTHORS included with the NASM distribution for
* the specific copyright holders.
*
@ -261,7 +261,10 @@ static inline unsigned int watcom_switch_hack(uint64_t x)
return (unsigned int)x;
}
# define switch(x) switch(sizeof(x) > sizeof(unsigned int) ? watcom_switch_hack(x) : (x))
# define switch(x) switch(sizeof(x) > sizeof(unsigned int) \
? watcom_switch_hack(x) : (unsigned int)(x))
/* This is to make sure BOGUS_CASE doesn't conflict with anything real... */
# define default case BOGUS_CASE: default
#endif