From 3bbd8432169461af9af0e6f3e8e307637d28d9ae Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 8 Jan 2019 06:06:46 +0000 Subject: [PATCH] Suppress uninitialized variable warnings. GCC is easily confused by the code we generate. --- src/compiler/machines/C/cutl.scm | 4 +++- src/microcode/liarc.h | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/machines/C/cutl.scm b/src/compiler/machines/C/cutl.scm index 6a1d6c182..be23d5530 100644 --- a/src/compiler/machines/C/cutl.scm +++ b/src/compiler/machines/C/cutl.scm @@ -410,7 +410,9 @@ USA. (define (c:decl type var #!optional val) (c:line (c:type type) " " (c:var var) - (if (default-object? val) "" (string-append " = " (c:expr val))) + (if (default-object? val) + (string-append " LIARC_UNINITIALIZED(" (c:var var) ")") + (string-append " = " (c:expr val))) ";")) (define (c:decl-unused type var #!optional val) diff --git a/src/microcode/liarc.h b/src/microcode/liarc.h index e9cd7cd22..ad63529f9 100644 --- a/src/microcode/liarc.h +++ b/src/microcode/liarc.h @@ -64,6 +64,12 @@ union machine_word_u typedef union machine_word_u machine_word; typedef unsigned long entry_count_t; +#ifdef __GNUC__ +#define LIARC_UNINITIALIZED(name) = name +#else +#define LIARC_UNINITIALIZED(name) +#endif + #define ADDRESS_UNITS_PER_OBJECT SIZEOF_SCHEME_OBJECT #define ADDRESS_UNITS_PER_FLOAT (sizeof (double)) -- 2.25.1