Commit 15e96b03 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'update-KWIML'

289e5e60 Merge branch 'upstream-kwiml' into update-KWIML
f94ae0ec KWIML: Make test_INT robust to #define-d int#_t and INT#_C
parents 88720153 289e5e60
...@@ -18,15 +18,13 @@ ...@@ -18,15 +18,13 @@
# define LANG "C " # define LANG "C "
#endif #endif
#define VALUE(T, U) \ #define VALUE(T, U) (T)((U)0xab << ((sizeof(T)-1)<<3))
(@KWIML@_INT_##T)((@KWIML@_INT_##U)0xab << \
((sizeof(@KWIML@_INT_##T)-1)<<3)) \
#define TEST_C(C, V, PRI, T, U) \ #define TEST_C_(C, V, PRI, T, U) \
{ \ { \
@KWIML@_INT_##T const x = VALUE(T, U); \ T const x = VALUE(T, U); \
@KWIML@_INT_##T y = @KWIML@_INT_##C(V); \ T y = C(V); \
printf(LANG "@KWIML@_INT_" #C ":" \ printf(LANG #C ":" \
" expression [%"@KWIML@_INT_PRI##PRI"]," \ " expression [%"@KWIML@_INT_PRI##PRI"]," \
" literal [%"@KWIML@_INT_PRI##PRI"]", x, y); \ " literal [%"@KWIML@_INT_PRI##PRI"]", x, y); \
if(x == y) \ if(x == y) \
...@@ -40,9 +38,9 @@ ...@@ -40,9 +38,9 @@
} \ } \
} }
#define TEST_PRI(PRI, T, U, STR) \ #define TEST_PRI_(PRI, T, U, STR) \
{ \ { \
@KWIML@_INT_##T const x = VALUE(T, U); \ T const x = VALUE(T, U); \
char const* str = STR; \ char const* str = STR; \
sprintf(buf, "%"@KWIML@_INT_PRI##PRI, x); \ sprintf(buf, "%"@KWIML@_INT_PRI##PRI, x); \
printf(LANG "@KWIML@_INT_PRI" #PRI ":" \ printf(LANG "@KWIML@_INT_PRI" #PRI ":" \
...@@ -58,11 +56,11 @@ ...@@ -58,11 +56,11 @@
} \ } \
} }
#define TEST_SCN(SCN, T, U, STR) TEST_SCN2(SCN, SCN, T, U, STR) #define TEST_SCN_(SCN, T, U, STR) TEST_SCN2_(SCN, SCN, T, U, STR)
#define TEST_SCN2(PRI, SCN, T, U, STR) \ #define TEST_SCN2_(PRI, SCN, T, U, STR) \
{ \ { \
@KWIML@_INT_##T const x = VALUE(T, U); \ T const x = VALUE(T, U); \
@KWIML@_INT_##T y; \ T y; \
char const* str = STR; \ char const* str = STR; \
if(sscanf(str, "%"@KWIML@_INT_SCN##SCN, &y) != 1) \ if(sscanf(str, "%"@KWIML@_INT_SCN##SCN, &y) != 1) \
{ \ { \
...@@ -82,10 +80,24 @@ ...@@ -82,10 +80,24 @@
} \ } \
} }
#define TEST(FMT, T, U, STR) TEST2(FMT, FMT, T, U, STR) #define TEST_(FMT, T, U, STR) TEST2_(FMT, FMT, T, U, STR)
#define TEST2(PRI, SCN, T, U, STR) \ #define TEST2_(PRI, SCN, T, U, STR) \
TEST_PRI(PRI, T, U, STR) \ TEST_PRI_(PRI, T, U, STR) \
TEST_SCN2(PRI, SCN, T, U, STR) TEST_SCN2_(PRI, SCN, T, U, STR)
/* Concatenate T and U now to avoid expanding them. */
#define TEST(FMT, T, U, STR) \
TEST_(FMT, @KWIML@_INT_##T, @KWIML@_INT_##U, STR)
#define TEST2(PRI, SCN, T, U, STR) \
TEST2_(PRI, SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR)
#define TEST_C(C, V, PRI, T, U) \
TEST_C_(@KWIML@_INT_##C, V, PRI, @KWIML@_INT_##T, @KWIML@_INT_##U)
#define TEST_PRI(PRI, T, U, STR) \
TEST_PRI_(PRI, @KWIML@_INT_##T, @KWIML@_INT_##U, STR)
#define TEST_SCN(SCN, T, U, STR) \
TEST_SCN_(SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR)
#define TEST_SCN2(PRI, SCN, T, U, STR) \
TEST_SCN2_(PRI, SCN, @KWIML@_INT_##T, @KWIML@_INT_##U, STR)
static int test_INT_format(void) static int test_INT_format(void)
{ {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment