diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-23 00:50:58 +0200 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2020-06-23 01:34:08 +0200 |
commit | 44936538b1f956c524ba063eb3f1efaf0f92dae1 (patch) | |
tree | 2fb1eb6503bfb721e6c368fb7ef8002bca477435 | |
parent | cc651aa7b6a01c3d89d1eb212a080d683f2df9ed (diff) | |
download | sparse-44936538b1f956c524ba063eb3f1efaf0f92dae1.tar.gz |
teach sparse about __STDC_HOSTED__
It seems that some system libraries expect __STDC_HOSTED__ to
be always defined.
So, teach sparse the options flags -f[no-]{hosted,freestanding}
and define __STDC_HOSTED__ accordingly.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
-rw-r--r-- | lib.c | 4 | ||||
-rw-r--r-- | lib.h | 1 | ||||
-rw-r--r-- | validation/preprocessor/freestanding.c | 11 | ||||
-rw-r--r-- | validation/preprocessor/hosted.c | 11 |
4 files changed, 27 insertions, 0 deletions
@@ -311,6 +311,7 @@ int dbg_ir = 0; int dbg_postorder = 0; unsigned long fdump_ir; +int fhosted = 1; int fmem_report = 0; unsigned long long fmemcpy_max_count = 100000; unsigned long fpasses = ~0UL; @@ -994,6 +995,8 @@ static int handle_fmax_warnings(const char *arg, const char *opt, const struct f static struct flag fflags[] = { { "diagnostic-prefix", NULL, handle_fdiagnostic_prefix }, { "dump-ir", NULL, handle_fdump_ir }, + { "freestanding", &fhosted, NULL, OPT_INVERSE }, + { "hosted", &fhosted }, { "linearize", NULL, handle_fpasses, PASS_LINEARIZE }, { "max-warnings=", NULL, handle_fmax_warnings }, { "mem-report", &fmem_report }, @@ -1300,6 +1303,7 @@ static void predefined_macros(void) predefine("__GNUC_PATCHLEVEL__", 1, "%d", gcc_patchlevel); predefine("__STDC__", 1, "1"); + predefine("__STDC_HOSTED__", 0, fhosted ? "1" : "0"); switch (standard) { default: break; @@ -202,6 +202,7 @@ extern int dbg_postorder; extern unsigned int fmax_warnings; extern int fmem_report; extern unsigned long fdump_ir; +extern int fhosted; extern unsigned long long fmemcpy_max_count; extern unsigned long fpasses; extern int fpic; diff --git a/validation/preprocessor/freestanding.c b/validation/preprocessor/freestanding.c new file mode 100644 index 00000000..7ee35354 --- /dev/null +++ b/validation/preprocessor/freestanding.c @@ -0,0 +1,11 @@ +__STDC_HOSTED__ + +/* + * check-name: freestanding + * check-command: sparse -E -ffreestanding $file + * + * check-output-start + +0 + * check-output-end + */ diff --git a/validation/preprocessor/hosted.c b/validation/preprocessor/hosted.c new file mode 100644 index 00000000..e6b3d3c1 --- /dev/null +++ b/validation/preprocessor/hosted.c @@ -0,0 +1,11 @@ +__STDC_HOSTED__ + +/* + * check-name: hosted + * check-command: sparse -E -fhosted $file + * + * check-output-start + +1 + * check-output-end + */ |