diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-14 01:13:26 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2019-11-15 02:24:31 +0100 |
commit | 0789c9a3eb450c5e140f61d35bf95043d2b37c94 (patch) | |
tree | cb66816e5317e5ee8e07bd49475b72260a21ec67 | |
parent | 47628528e22cc44e74604e45073c9e022b0472ca (diff) | |
download | sparse-0789c9a3eb450c5e140f61d35bf95043d2b37c94.tar.gz |
arch: teach sparse about -fshort-wchar
This is useful in cgcc for supporting Cygwin which doesn't
use a 32-bit type for wchar_t.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.c | 2 | ||||
-rw-r--r-- | lib.h | 1 | ||||
-rw-r--r-- | target.c | 2 | ||||
-rw-r--r-- | validation/arch/short-wchar.c | 6 |
4 files changed, 11 insertions, 0 deletions
@@ -313,6 +313,7 @@ unsigned long long fmemcpy_max_count = 100000; unsigned long fpasses = ~0UL; int fpic = 0; int fpie = 0; +int fshort_wchar = 0; int funsigned_char = -1; int preprocess_only; @@ -995,6 +996,7 @@ static struct flag fflags[] = { { "pie", &fpie, handle_switch_setval, 1 }, { "PIE", &fpie, handle_switch_setval, 2 }, { "signed-char", &funsigned_char, NULL, OPT_INVERSE }, + { "short-wchar", &fshort_wchar }, { "unsigned-char", &funsigned_char, NULL, }, { }, }; @@ -202,6 +202,7 @@ extern unsigned long long fmemcpy_max_count; extern unsigned long fpasses; extern int fpic; extern int fpie; +extern int fshort_wchar; extern int funsigned_char; extern int arch_m64; @@ -106,6 +106,8 @@ void init_target(void) default: break; } + if (fshort_wchar) + wchar_ctype = &ushort_ctype; switch (arch_mach) { case MACH_MIPS64: diff --git a/validation/arch/short-wchar.c b/validation/arch/short-wchar.c new file mode 100644 index 00000000..de05313c --- /dev/null +++ b/validation/arch/short-wchar.c @@ -0,0 +1,6 @@ +_Static_assert([__WCHAR_TYPE__] == [unsigned short], "short wchar"); + +/* + * check-name: short-wchar + * check-command: sparse -fshort-wchar $file + */ |