From c1e768db524407c25d14fe693a931af9cb6d9ad4 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 8 Mar 2014 00:56:53 -0500 Subject: sim: msp430: use common warnings options This triggers a bunch of new warnings, so fix some of them. --- sim/msp430/ChangeLog | 10 +++ sim/msp430/aclocal.m4 | 17 +++-- sim/msp430/configure | 164 ++++++++++++++++++++++++++++++++++++++++++++++-- sim/msp430/configure.ac | 2 + sim/msp430/msp430-sim.c | 2 + sim/msp430/trace.c | 4 +- sim/msp430/trace.h | 2 +- 7 files changed, 186 insertions(+), 15 deletions(-) diff --git a/sim/msp430/ChangeLog b/sim/msp430/ChangeLog index 7d52dca..d351d64 100644 --- a/sim/msp430/ChangeLog +++ b/sim/msp430/ChangeLog @@ -1,5 +1,15 @@ 2015-03-14 Mike Frysinger + * aclocal.m4, configure: Regenerate. + * configure.ac: Call the common inline & warning macros. + * msp430-sim.c: Include unistd.h & trace.h. + * trace.c: Include trace.h. + (load_file_and_line): Move FILE* decl to top of scope. + * trace.h (msp430_get_current_source_location): Adjust prototype to + match the function definition. + +2015-03-14 Mike Frysinger + * Makefile.in (SIM_RUN_OBJS): Delete. 2015-02-24 Nick Clifton diff --git a/sim/msp430/aclocal.m4 b/sim/msp430/aclocal.m4 index a24bbeb..517bc73 100644 --- a/sim/msp430/aclocal.m4 +++ b/sim/msp430/aclocal.m4 @@ -1,8 +1,7 @@ -# generated automatically by aclocal 1.11.3 -*- Autoconf -*- +# generated automatically by aclocal 1.11.1 -*- Autoconf -*- # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, -# 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, -# Inc. +# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -72,8 +71,8 @@ AC_SUBST([am__leading_dot])]) # Add --enable-maintainer-mode option to configure. -*- Autoconf -*- # From Jim Meyering -# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008, -# 2011 Free Software Foundation, Inc. +# Copyright (C) 1996, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2008 +# Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -93,7 +92,7 @@ AC_DEFUN([AM_MAINTAINER_MODE], [disable], [m4_define([am_maintainer_other], [enable])], [m4_define([am_maintainer_other], [enable]) m4_warn([syntax], [unexpected argument to AM@&t@_MAINTAINER_MODE: $1])]) -AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) +AC_MSG_CHECKING([whether to am_maintainer_other maintainer-specific portions of Makefiles]) dnl maintainer-mode's default is 'disable' unless 'enable' is passed AC_ARG_ENABLE([maintainer-mode], [ --][am_maintainer_other][-maintainer-mode am_maintainer_other make rules and dependencies not useful @@ -109,13 +108,13 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles]) AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) -# Copyright (C) 2006, 2008, 2010 Free Software Foundation, Inc. +# Copyright (C) 2006, 2008 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. -# serial 3 +# serial 2 # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- @@ -124,7 +123,7 @@ AU_DEFUN([jm_MAINTAINER_MODE], [AM_MAINTAINER_MODE]) AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) -# -------------------------- +# --------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) diff --git a/sim/msp430/configure b/sim/msp430/configure index 3ea2365..2ed3724 100755 --- a/sim/msp430/configure +++ b/sim/msp430/configure @@ -761,6 +761,10 @@ with_pkgversion with_bugurl enable_sim_endian enable_sim_alignment +enable_sim_inline +enable_werror +enable_build_warnings +enable_sim_build_warnings ' ac_precious_vars='build_alias host_alias @@ -1405,6 +1409,12 @@ Optional Features: --enable-sim-profile=opts Enable profiling flags --enable-sim-endian=endian Specify target byte endian orientation. --enable-sim-alignment=align Specify strict, nonstrict or forced alignment of memory accesses. + --enable-sim-inline=inlines Specify which functions should be inlined. + --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] @@ -8123,7 +8133,7 @@ $as_echo "$lt_cv_ld_force_load" >&6; } case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in 10.0,*86*-darwin8*|10.0,*-darwin[91]*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; - 10.[012]*) + 10.[012][,.]*) _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;; 10.*) _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;; @@ -10146,7 +10156,7 @@ _LT_EOF if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ && test "$tmp_diet" = no then - tmp_addflag= + tmp_addflag=' $pic_flag' tmp_sharedflag='-shared' case $cc_basename,$host_cpu in pgcc*) # Portland Group C compiler @@ -12356,7 +12366,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12359 "configure" +#line 12369 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12462,7 +12472,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12465 "configure" +#line 12475 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13065,6 +13075,152 @@ fi fi +default_sim_inline="" +# Check whether --enable-sim-inline was given. +if test "${enable_sim_inline+set}" = set; then : + enableval=$enable_sim_inline; sim_inline="" +case "$enableval" in + no) sim_inline="-DDEFAULT_INLINE=0";; + 0) sim_inline="-DDEFAULT_INLINE=0";; + yes | 2) sim_inline="-DDEFAULT_INLINE=ALL_C_INLINE";; + 1) sim_inline="-DDEFAULT_INLINE=INLINE_LOCALS";; + *) for x in `echo "$enableval" | sed -e "s/,/ /g"`; do + new_flag="" + case "$x" in + *_INLINE=*) new_flag="-D$x";; + *=*) new_flag=`echo "$x" | sed -e "s/=/_INLINE=/" -e "s/^/-D/"`;; + *_INLINE) new_flag="-D$x=ALL_C_INLINE";; + *) new_flag="-D$x""_INLINE=ALL_C_INLINE";; + esac + if test x"$sim_inline" = x""; then + sim_inline="$new_flag" + else + sim_inline="$sim_inline $new_flag" + fi + done;; +esac +if test x"$silent" != x"yes" && test x"$sim_inline" != x""; then + echo "Setting inline flags = $sim_inline" 6>&1 +fi +else + +if test "x$cross_compiling" = "xno"; then + if test x"$GCC" != "x" -a x"${default_sim_inline}" != "x" ; then + sim_inline="${default_sim_inline}" + if test x"$silent" != x"yes"; then + echo "Setting inline flags = $sim_inline" 6>&1 + fi + else + sim_inline="" + fi +else + sim_inline="-DDEFAULT_INLINE=0" +fi +fi + + +# 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 + + ac_sources="$sim_link_files" ac_dests="$sim_link_links" diff --git a/sim/msp430/configure.ac b/sim/msp430/configure.ac index efeb514..f257e0c 100644 --- a/sim/msp430/configure.ac +++ b/sim/msp430/configure.ac @@ -28,5 +28,7 @@ AC_CHECK_HEADERS(getopt.h) SIM_AC_OPTION_ENDIAN(LITTLE_ENDIAN) SIM_AC_OPTION_ALIGNMENT(STRICT_ALIGNMENT,STRICT_ALIGNMENT) +SIM_AC_OPTION_INLINE +SIM_AC_OPTION_WARNINGS SIM_AC_OUTPUT diff --git a/sim/msp430/msp430-sim.c b/sim/msp430/msp430-sim.c index ee86339..f7057e2 100644 --- a/sim/msp430/msp430-sim.c +++ b/sim/msp430/msp430-sim.c @@ -24,12 +24,14 @@ #include #include #include +#include #include #include "bfd.h" #include "opcode/msp430-decode.h" #include "sim-main.h" #include "dis-asm.h" #include "targ-vals.h" +#include "trace.h" static int loader_write_mem (SIM_DESC sd, diff --git a/sim/msp430/trace.c b/sim/msp430/trace.c index d85069f..b6c7b02 100644 --- a/sim/msp430/trace.c +++ b/sim/msp430/trace.c @@ -32,6 +32,7 @@ #include "libiberty.h" #include "bfd.h" #include "dis-asm.h" +#include "trace.h" static int sim_dis_read (bfd_vma memaddr, bfd_byte * ptr, unsigned int length, @@ -138,6 +139,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) @@ -155,7 +157,7 @@ load_file_and_line (const char *filename, int lineno) files = f; f->filename = xstrdup (filename); f->data = (char *) xmalloc (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); diff --git a/sim/msp430/trace.h b/sim/msp430/trace.h index c68146b..0085c3c 100644 --- a/sim/msp430/trace.h +++ b/sim/msp430/trace.h @@ -23,6 +23,6 @@ extern void msp430_trace_init (bfd *); extern void msp430_trace_one (int pc); -extern int msp430_get_current_source_location (const char **, const char **, unsigned int *); +extern int msp430_get_current_source_location (int, const char **, const char **, unsigned int *); #endif -- cgit v1.1