diff options
author | Mike Frysinger <vapier@gentoo.org> | 2015-04-01 02:21:21 -0400 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2015-04-01 02:22:58 -0400 |
commit | 269e9c185f67d477a99574f53ead904d50fddfda (patch) | |
tree | 0177a3d3718cc79c55ae0ff07d9d4d974397800d /sim | |
parent | 0fe84f3fbe9a740c38a8dbaa0150b8e4c25c69dd (diff) | |
download | fsf-binutils-gdb-269e9c185f67d477a99574f53ead904d50fddfda.zip fsf-binutils-gdb-269e9c185f67d477a99574f53ead904d50fddfda.tar.gz fsf-binutils-gdb-269e9c185f67d477a99574f53ead904d50fddfda.tar.bz2 |
sim: m32c: enable warnings & clean up a bunch
This doesn't clean up all the warnings, just most of them.
The ones that are left will require some care to unravel.
Diffstat (limited to 'sim')
-rw-r--r-- | sim/m32c/ChangeLog | 36 | ||||
-rwxr-xr-x | sim/m32c/configure | 115 | ||||
-rw-r--r-- | sim/m32c/configure.ac | 2 | ||||
-rw-r--r-- | sim/m32c/cpu.h | 10 | ||||
-rw-r--r-- | sim/m32c/gdb-if.c | 19 | ||||
-rw-r--r-- | sim/m32c/load.c | 6 | ||||
-rw-r--r-- | sim/m32c/load.h | 2 | ||||
-rw-r--r-- | sim/m32c/m32c.opc | 8 | ||||
-rw-r--r-- | sim/m32c/mem.c | 16 | ||||
-rw-r--r-- | sim/m32c/mem.h | 4 | ||||
-rw-r--r-- | sim/m32c/r8c.opc | 6 | ||||
-rw-r--r-- | sim/m32c/reg.c | 9 | ||||
-rw-r--r-- | sim/m32c/sample2.c | 3 | ||||
-rw-r--r-- | sim/m32c/srcdest.c | 18 | ||||
-rw-r--r-- | sim/m32c/timer_a.h | 2 | ||||
-rw-r--r-- | sim/m32c/trace.c | 6 |
16 files changed, 208 insertions, 54 deletions
diff --git a/sim/m32c/ChangeLog b/sim/m32c/ChangeLog index ea4925a..814d2dc 100644 --- a/sim/m32c/ChangeLog +++ b/sim/m32c/ChangeLog @@ -1,3 +1,39 @@ +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. diff --git a/sim/m32c/configure b/sim/m32c/configure index ba4ae74..d46cfe1 100755 --- a/sim/m32c/configure +++ b/sim/m32c/configure @@ -761,6 +761,9 @@ enable_sim_trace enable_sim_profile with_pkgversion with_bugurl +enable_werror +enable_build_warnings +enable_sim_build_warnings ' ac_precious_vars='build_alias host_alias @@ -1403,6 +1406,11 @@ Optional Features: --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] @@ -12286,7 +12294,7 @@ else 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 @@ -12392,7 +12400,7 @@ else 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 @@ -12882,6 +12890,109 @@ sim_link_links="${sim_link_links} targ-vals.def" + +# 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` diff --git a/sim/m32c/configure.ac b/sim/m32c/configure.ac index 0010f07..6f4559c 100644 --- a/sim/m32c/configure.ac +++ b/sim/m32c/configure.ac @@ -24,6 +24,8 @@ sinclude(../common/acinclude.m4) 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 diff --git a/sim/m32c/cpu.h b/sim/m32c/cpu.h index 5d13ece..ce78889 100644 --- a/sim/m32c/cpu.h +++ b/sim/m32c/cpu.h @@ -220,9 +220,11 @@ extern unsigned int heaptop; 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); diff --git a/sim/m32c/gdb-if.c b/sim/m32c/gdb-if.c index 62ec28c..be00545 100644 --- a/sim/m32c/gdb-if.c +++ b/sim/m32c/gdb-if.c @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include <stdio.h> #include <assert.h> #include <signal.h> +#include <stdlib.h> #include <string.h> #include <ctype.h> @@ -509,22 +510,14 @@ sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length) 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) @@ -560,7 +553,7 @@ m32c_signal_to_target (int 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)) @@ -609,6 +602,8 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver) interrupt signal handler. */ for (;;) { + int rc; + if (stop) { stop = 0; @@ -617,7 +612,7 @@ sim_resume (SIM_DESC sd, int step, int sig_to_deliver) break; } - int rc = decode_opcode (); + rc = decode_opcode (); #ifdef TIMER_A update_timer_a (); #endif diff --git a/sim/m32c/load.c b/sim/m32c/load.c index e763773..0543b6d 100644 --- a/sim/m32c/load.c +++ b/sim/m32c/load.c @@ -27,8 +27,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #include "cpu.h" #include "mem.h" +#include "load.h" -int (*decode_opcode) () = 0; +int (*decode_opcode) (void) = 0; int default_machine = 0; void @@ -88,12 +89,13 @@ m32c_load (bfd * prog) { 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)); diff --git a/sim/m32c/load.h b/sim/m32c/load.h index b9161a0..b96a049 100644 --- a/sim/m32c/load.h +++ b/sim/m32c/load.h @@ -23,5 +23,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ extern int default_machine; -void m32c_set_mach (int mach); +void m32c_set_mach (unsigned long mach); void m32c_load (bfd *); diff --git a/sim/m32c/m32c.opc b/sim/m32c/m32c.opc index d345694..7462b1d 100644 --- a/sim/m32c/m32c.opc +++ b/sim/m32c/m32c.opc @@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define tprintf if (trace) printf static unsigned char -getbyte () +getbyte (void) { int tsave = trace; unsigned char b; @@ -105,8 +105,8 @@ IMM(int bytes) /* 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 @@ -394,7 +394,7 @@ static int pcs[16]; static int ipcs = 0; int -decode_m32c() +decode_m32c (void) { unsigned char op[40]; int opi; diff --git a/sim/m32c/mem.c b/sim/m32c/mem.c index 0e4fc77..e3202db 100644 --- a/sim/m32c/mem.c +++ b/sim/m32c/mem.c @@ -89,7 +89,7 @@ init_mem (void) } 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); @@ -139,7 +139,7 @@ mcs (int isput, int bytes) } void -mem_usage_stats () +mem_usage_stats (void) { int i, j; int rstart = 0; @@ -192,7 +192,7 @@ s (int address, char *dir) #define S(d) if (trace) s(address, d) static void -e () +e (void) { if (!trace) return; @@ -205,7 +205,7 @@ e () extern int m32c_disassemble; -void +static void mem_put_byte (int address, unsigned char value) { unsigned char *m; @@ -376,7 +376,7 @@ mem_put_blk (int address, const void *bufptr, int nbytes) } unsigned char -mem_get_pc () +mem_get_pc (void) { unsigned char *m = mem_ptr (regs.r_pc & membus_mask); COUNT (0, 0); @@ -388,7 +388,7 @@ static int console_raw = 0; static struct termios oattr; static int -stdin_ready () +stdin_ready (void) { fd_set ifd; int n; @@ -403,7 +403,7 @@ stdin_ready () } void -m32c_sim_restore_console () +m32c_sim_restore_console (void) { if (console_raw) tcsetattr (m32c_console_ifd, TCSANOW, &oattr); @@ -557,7 +557,7 @@ sign_ext (int v, int bits) #if TIMER_A void -update_timer_a () +update_timer_a (void) { if (timer_a.bsr & 1) { diff --git a/sim/m32c/mem.h b/sim/m32c/mem.h index f79426f..6d804b1 100644 --- a/sim/m32c/mem.h +++ b/sim/m32c/mem.h @@ -29,7 +29,7 @@ void mem_put_si (int address, unsigned long value); 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); @@ -40,6 +40,6 @@ void mem_get_blk (int address, void *bufptr, int nbytes); int sign_ext (int v, int bits); -void m32c_sim_restore_console (); +void m32c_sim_restore_console (void); extern int m32c_use_raw_console; diff --git a/sim/m32c/r8c.opc b/sim/m32c/r8c.opc index b4a4f6d..34f0af4 100644 --- a/sim/m32c/r8c.opc +++ b/sim/m32c/r8c.opc @@ -32,7 +32,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #define tprintf if (trace) printf static unsigned char -getbyte () +getbyte (void) { int tsave = trace; unsigned char b; @@ -77,7 +77,7 @@ unsupported (char *tag, int orig_pc) } static int -IMM(bw) +IMM (int bw) { int rv = getbyte (); if (bw) @@ -306,7 +306,7 @@ static int bmcnd_cond_map[] = { }; int -decode_r8c() +decode_r8c (void) { unsigned char op[40]; int opi = 0; diff --git a/sim/m32c/reg.c b/sim/m32c/reg.c index 3fdc2e6..be7d81c 100644 --- a/sim/m32c/reg.c +++ b/sim/m32c/reg.c @@ -219,7 +219,7 @@ get_reg_ll (reg_id id) 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); @@ -230,10 +230,11 @@ stack_heap_stats () 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: @@ -605,7 +606,7 @@ print_flags (int f) } void -trace_register_changes () +trace_register_changes (void) { if (!trace) return; @@ -646,7 +647,7 @@ trace_register_changes () 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); diff --git a/sim/m32c/sample2.c b/sim/m32c/sample2.c index f6aec0e..776989c 100644 --- a/sim/m32c/sample2.c +++ b/sim/m32c/sample2.c @@ -21,7 +21,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ /* See the 'sample2.x' target in Makefile.in. */ void exit (int); -start () +void +start (void) { foo (1, 2, 3, 4); exit (5); diff --git a/sim/m32c/srcdest.c b/sim/m32c/srcdest.c index a2415a8..ada2a9b 100644 --- a/sim/m32c/srcdest.c +++ b/sim/m32c/srcdest.c @@ -31,7 +31,7 @@ static int src_addend = 0; static int dest_addend = 0; static int -disp8 () +disp8 (void) { int rv; int tsave = trace; @@ -45,7 +45,7 @@ disp8 () } static int -disp16 () +disp16 (void) { int rv; int tsave = trace; @@ -59,7 +59,7 @@ disp16 () } static int -disp24 () +disp24 (void) { int rv; int tsave = trace; @@ -73,7 +73,7 @@ disp24 () } static int -disp20 () +disp20 (void) { return disp24 () & 0x000fffff; } @@ -117,8 +117,6 @@ srcdest 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]", @@ -126,6 +124,9 @@ decode_srcdest4 (int destcode, int bw) }; 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]; @@ -199,8 +200,6 @@ srcdest 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]", @@ -208,6 +207,9 @@ decode_jumpdest (int destcode, int w) }; 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]; diff --git a/sim/m32c/timer_a.h b/sim/m32c/timer_a.h index abf5883..2037ca3 100644 --- a/sim/m32c/timer_a.h +++ b/sim/m32c/timer_a.h @@ -11,4 +11,4 @@ typedef struct extern Timer_A timer_a; -extern void update_timer_a (); +extern void update_timer_a (void); diff --git a/sim/m32c/trace.c b/sim/m32c/trace.c index f98790c..2c5009f 100644 --- a/sim/m32c/trace.c +++ b/sim/m32c/trace.c @@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. */ #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, @@ -128,6 +129,7 @@ load_file_and_line (const char *filename, int lineno) int i; struct stat s; const char *found_filename, *slash; + FILE *file; found_filename = filename; while (1) @@ -145,7 +147,7 @@ load_file_and_line (const char *filename, int lineno) 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); @@ -174,7 +176,7 @@ load_file_and_line (const char *filename, int lineno) } void -sim_disasm_one () +sim_disasm_one (void) { static int initted = 0; static asymbol **symtab = 0; |