This doesn't clean up all the warnings, just most of them.
The ones that are left will require some care to unravel.
+2015-04-01 Mike Frysinger <vapier@gentoo.org>
+
+ * configure.ac: Call SIM_AC_OPTION_WARNINGS.
+ * configure: Regenerate.
+ * cpu.h (decode_opcode, decode_r8c, decode_m32c,
+ trace_register_changes): Convert old style prototypes.
+ (m32c_dump_all_registers): New prototype.
+ * gdb-if.c: Include stdlib.h.
+ (sim_info): Delete.
+ (siggnal, handle_step): Mark static.
+ (sim_resume): Move rc decl to top of scope.
+ * load.c: Include load.h.
+ (decode_opcode); Convert old style prototype.
+ (m32c_load): Move base decl to top of scope.
+ * load.h (m32c_set_mach): Change mach type to unsigned long.
+ * m32c.opc (getbyte, decode_m32c): Convert old style prototypes.
+ (prefix): Convert old style prototype and mark static.
+ * mem.c (mem_ptr, mem_usage_stats, e, mem_get_pc, stdin_ready,
+ m32c_sim_restore_console, update_timer_a): Convert old style
+ prototypes.
+ (mem_put_byte): Mark static.
+ * mem.h (mem_get_pc, m32c_sim_restore_console): Convert old style
+ prototypes.
+ * r8c.opc (getbyte, IMM, decode_r8c): Convert old style prototypes.
+ * reg.c (stack_heap_stats, trace_register_changes,
+ m32c_dump_all_registers): Convert old style prototypes.
+ (put_reg): Move b decl to top of scope.
+ * sample2.c (start): Convert old style prototype.
+ * srcdest.c (disp8, disp16, disp24, disp20): Convert old style
+ prototypes.
+ (decode_srcdest4, decode_jumpdest): Move sd init below decls.
+ * timer_a.h (update_timer_a): Convert old style prototype.
+ * trace.c: Include trace.h.
+ (load_file_and_line): Move file decl to top of scope.
+ (sim_disasm_one): Convert old style prototype.
+
2015-03-31 Mike Frysinger <vapier@gentoo.org>
* config.in, configure: Regenerate.
enable_sim_profile
with_pkgversion
with_bugurl
+enable_werror
+enable_build_warnings
+enable_sim_build_warnings
'
ac_precious_vars='build_alias
host_alias
--enable-sim-stdio Specify whether to use stdio for console input/output.
--enable-sim-trace=opts Enable tracing flags
--enable-sim-profile=opts Enable profiling flags
+ --enable-werror treat compile warnings as errors
+ --enable-build-warnings enable build-time compiler warnings if gcc is used
+ --enable-sim-build-warnings
+ enable SIM specific build-time compiler warnings if
+ gcc is used
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12289 "configure"
+#line 12297 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 12395 "configure"
+#line 12403 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
+
+# Check whether --enable-werror was given.
+if test "${enable_werror+set}" = set; then :
+ enableval=$enable_werror; case "${enableval}" in
+ yes | y) ERROR_ON_WARNING="yes" ;;
+ no | n) ERROR_ON_WARNING="no" ;;
+ *) as_fn_error "bad value ${enableval} for --enable-werror" "$LINENO" 5 ;;
+ esac
+fi
+
+
+# Enable -Werror by default when using gcc
+if test "${GCC}" = yes -a -z "${ERROR_ON_WARNING}" ; then
+ ERROR_ON_WARNING=yes
+fi
+
+WERROR_CFLAGS=""
+if test "${ERROR_ON_WARNING}" = yes ; then
+# NOTE: Disabled in the sim dir due to most sims generating warnings.
+# WERROR_CFLAGS="-Werror"
+ true
+fi
+
+build_warnings="-Wall -Wdeclaration-after-statement -Wpointer-arith \
+-Wpointer-sign \
+-Wno-unused -Wunused-value -Wunused-function \
+-Wno-switch -Wno-char-subscripts -Wmissing-prototypes
+-Wdeclaration-after-statement -Wempty-body -Wmissing-parameter-type \
+-Wold-style-declaration -Wold-style-definition"
+
+# Enable -Wno-format by default when using gcc on mingw since many
+# GCC versions complain about %I64.
+case "${host}" in
+ *-*-mingw32*) build_warnings="$build_warnings -Wno-format" ;;
+ *) build_warnings="$build_warnings -Wformat-nonliteral" ;;
+esac
+
+# Check whether --enable-build-warnings was given.
+if test "${enable_build_warnings+set}" = set; then :
+ enableval=$enable_build_warnings; case "${enableval}" in
+ yes) ;;
+ no) build_warnings="-w";;
+ ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${build_warnings} ${t}";;
+ *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${t} ${build_warnings}";;
+ *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+esac
+if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
+ echo "Setting compiler warning flags = $build_warnings" 6>&1
+fi
+fi
+# Check whether --enable-sim-build-warnings was given.
+if test "${enable_sim_build_warnings+set}" = set; then :
+ enableval=$enable_sim_build_warnings; case "${enableval}" in
+ yes) ;;
+ no) build_warnings="-w";;
+ ,*) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${build_warnings} ${t}";;
+ *,) t=`echo "${enableval}" | sed -e "s/,/ /g"`
+ build_warnings="${t} ${build_warnings}";;
+ *) build_warnings=`echo "${enableval}" | sed -e "s/,/ /g"`;;
+esac
+if test x"$silent" != x"yes" && test x"$build_warnings" != x""; then
+ echo "Setting GDB specific compiler warning flags = $build_warnings" 6>&1
+fi
+fi
+WARN_CFLAGS=""
+if test "x${build_warnings}" != x -a "x$GCC" = xyes
+then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking compiler warning flags" >&5
+$as_echo_n "checking compiler warning flags... " >&6; }
+ # Separate out the -Werror flag as some files just cannot be
+ # compiled with it enabled.
+ for w in ${build_warnings}; do
+ case $w in
+ -Werr*) WERROR_CFLAGS=-Werror ;;
+ *) # Check that GCC accepts it
+ saved_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $w"
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+
+int
+main ()
+{
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+ WARN_CFLAGS="${WARN_CFLAGS} $w"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ CFLAGS="$saved_CFLAGS"
+ esac
+ done
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${WARN_CFLAGS} ${WERROR_CFLAGS}" >&5
+$as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
+fi
+
+
for ac_header in sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
SIM_AC_COMMON
+SIM_AC_OPTION_WARNINGS
+
AC_CHECK_HEADERS(sys/select.h termios.h sys/socket.h netinet/in.h netinet/tcp.h)
SIM_AC_OUTPUT
extern unsigned int heapbottom;
/* Points to one of the below functions, set by m32c_load(). */
-extern int (*decode_opcode) ();
+extern int (*decode_opcode) (void);
-extern int decode_r8c ();
-extern int decode_m32c ();
+extern int decode_r8c (void);
+extern int decode_m32c (void);
-extern void trace_register_changes ();
+extern void trace_register_changes (void);
+
+extern void m32c_dump_all_registers (void);
#include <stdio.h>
#include <assert.h>
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include <ctype.h>
return size;
}
-void
-sim_info (SIM_DESC sd, int verbose)
-{
- check_desc (sd);
-
- printf ("The m32c minisim doesn't collect any statistics.\n");
-}
-
static volatile int stop;
static enum sim_stop reason;
-int siggnal;
+static int siggnal;
/* Given a signal number used by the M32C bsp (that is, newlib),
return a target signal number used by GDB. */
-int
+static int
m32c_signal_to_target (int m32c)
{
switch (m32c)
/* Take a step return code RC and set up the variables consulted by
sim_stop_reason appropriately. */
-void
+static void
handle_step (int rc)
{
if (M32C_STEPPED (rc) || M32C_HIT_BREAK (rc))
interrupt signal handler. */
for (;;)
{
+ int rc;
+
if (stop)
{
stop = 0;
break;
}
- int rc = decode_opcode ();
+ rc = decode_opcode ();
#ifdef TIMER_A
update_timer_a ();
#endif
#include "cpu.h"
#include "mem.h"
+#include "load.h"
-int (*decode_opcode) () = 0;
+int (*decode_opcode) (void) = 0;
int default_machine = 0;
void
{
char *buf;
bfd_size_type size;
+ bfd_vma base;
size = bfd_get_section_size (s);
if (size <= 0)
continue;
- bfd_vma base = bfd_section_lma (prog, s);
+ base = bfd_section_lma (prog, s);
if (verbose)
fprintf (stderr, "[load a=%08x s=%08x %s]\n",
(int) base, (int) size, bfd_get_section_name (prog, s));
extern int default_machine;
-void m32c_set_mach (int mach);
+void m32c_set_mach (unsigned long mach);
void m32c_load (bfd *);
#define tprintf if (trace) printf
static unsigned char
-getbyte ()
+getbyte (void)
{
int tsave = trace;
unsigned char b;
/* Indicate which sorts of prefixes are allowed for the current
opcode. */
-void
-prefix (src_allowed, dest_allowed, index_bytewidth)
+static void
+prefix (int src_allowed, int dest_allowed, int index_bytewidth)
{
/* At the moment, we don't do anything with this information. We
just wanted to get the information entered in some
static int ipcs = 0;
int
-decode_m32c()
+decode_m32c (void)
{
unsigned char op[40];
int opi;
}
static unsigned char *
-mem_ptr (address)
+mem_ptr (int address)
{
static int recursing = 0;
int pt1 = (address >> (L2_BITS + OFF_BITS)) & ((1 << L1_BITS) - 1);
}
void
-mem_usage_stats ()
+mem_usage_stats (void)
{
int i, j;
int rstart = 0;
#define S(d) if (trace) s(address, d)
static void
-e ()
+e (void)
{
if (!trace)
return;
extern int m32c_disassemble;
-void
+static void
mem_put_byte (int address, unsigned char value)
{
unsigned char *m;
}
unsigned char
-mem_get_pc ()
+mem_get_pc (void)
{
unsigned char *m = mem_ptr (regs.r_pc & membus_mask);
COUNT (0, 0);
static struct termios oattr;
static int
-stdin_ready ()
+stdin_ready (void)
{
fd_set ifd;
int n;
}
void
-m32c_sim_restore_console ()
+m32c_sim_restore_console (void)
{
if (console_raw)
tcsetattr (m32c_console_ifd, TCSANOW, &oattr);
#if TIMER_A
void
-update_timer_a ()
+update_timer_a (void)
{
if (timer_a.bsr & 1)
{
void mem_put_blk (int address, const void *bufptr, int nbytes);
-unsigned char mem_get_pc ();
+unsigned char mem_get_pc (void);
unsigned char mem_get_qi (int address);
unsigned short mem_get_hi (int address);
int sign_ext (int v, int bits);
-void m32c_sim_restore_console ();
+void m32c_sim_restore_console (void);
extern int m32c_use_raw_console;
#define tprintf if (trace) printf
static unsigned char
-getbyte ()
+getbyte (void)
{
int tsave = trace;
unsigned char b;
}
static int
-IMM(bw)
+IMM (int bw)
{
int rv = getbyte ();
if (bw)
};
int
-decode_r8c()
+decode_r8c (void)
{
unsigned char op[40];
int opi = 0;
static int highest_sp = 0, lowest_sp = 0xffffff;
void
-stack_heap_stats ()
+stack_heap_stats (void)
{
printf ("heap: %08x - %08x (%d bytes)\n", heapbottom, heaptop,
heaptop - heapbottom);
void
put_reg (reg_id id, unsigned int v)
{
+ reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0);
+
if (trace > ((id != pc) ? 0 : 1))
printf ("put_reg (%s) = %0*x\n", reg_names[id], reg_bytes[id] * 2, v);
- reg_bank_type *b = regs.r + (FLAG_B ? 1 : 0);
switch (id)
{
case r0:
}
void
-trace_register_changes ()
+trace_register_changes (void)
{
if (!trace)
return;
reg_bytes[id]*2, (unsigned int)regs.f); \
void
-m32c_dump_all_registers ()
+m32c_dump_all_registers (void)
{
printf ("\033[36mREGS:");
DRC (r[0].r_r0, "r0", r0);
/* See the 'sample2.x' target in Makefile.in. */
void exit (int);
-start ()
+void
+start (void)
{
foo (1, 2, 3, 4);
exit (5);
static int dest_addend = 0;
static int
-disp8 ()
+disp8 (void)
{
int rv;
int tsave = trace;
}
static int
-disp16 ()
+disp16 (void)
{
int rv;
int tsave = trace;
}
static int
-disp24 ()
+disp24 (void)
{
int rv;
int tsave = trace;
}
static int
-disp20 ()
+disp20 (void)
{
return disp24 () & 0x000fffff;
}
decode_srcdest4 (int destcode, int bw)
{
srcdest sd;
- sd.bytes = bw ? 2 : 1;
- sd.mem = (destcode >= 6) ? 1 : 0;
static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3",
"a0", "a1", "[a0]", "[a1]",
"disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]",
};
static const char *dc_bnames[4] = { "r0l", "r0h", "r1l", "r1h" };;
+ sd.bytes = bw ? 2 : 1;
+ sd.mem = (destcode >= 6) ? 1 : 0;
+
if (trace)
{
const char *n = dc_wnames[destcode];
decode_jumpdest (int destcode, int w)
{
srcdest sd;
- sd.bytes = w ? 2 : 3;
- sd.mem = (destcode >= 6) ? 1 : 0;
static const char *dc_wnames[16] = { "r0", "r1", "r2", "r3",
"a0", "a1", "[a0]", "[a1]",
"disp8[a0]", "disp8[a1]", "disp8[sb]", "disp8[fb]",
};
static const char *dc_anames[4] = { "r0l", "r0h", "r1l", "r1h" };
+ sd.bytes = w ? 2 : 3;
+ sd.mem = (destcode >= 6) ? 1 : 0;
+
if (trace)
{
const char *n = dc_wnames[destcode];
extern Timer_A timer_a;
-extern void update_timer_a ();
+extern void update_timer_a (void);
#include "cpu.h"
#include "mem.h"
#include "load.h"
+#include "trace.h"
static int
sim_dis_read (bfd_vma memaddr, bfd_byte * ptr, unsigned int length,
int i;
struct stat s;
const char *found_filename, *slash;
+ FILE *file;
found_filename = filename;
while (1)
files = f;
f->filename = strdup (filename);
f->data = (char *) malloc (s.st_size + 2);
- FILE *file = fopen (found_filename, "rb");
+ file = fopen (found_filename, "rb");
fread (f->data, 1, s.st_size, file);
f->data[s.st_size] = 0;
fclose (file);
}
void
-sim_disasm_one ()
+sim_disasm_one (void)
{
static int initted = 0;
static asymbol **symtab = 0;