mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
improve setting of warning flags
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@29899 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
ee25a8f059
commit
8632d7f34a
17 changed files with 266 additions and 24 deletions
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2010-03-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* configure:
|
||||
* config.mak.in:
|
||||
* NSCharacterSets/GNUmakefile:
|
||||
* Source/unix/Makefile.preamble:
|
||||
* Source/win32/Makefile.preamble:
|
||||
* Source/ObjectiveC2/Makefile.preamble:
|
||||
* Source/Additions/Makefile.preamble:
|
||||
* Source/Makefile.preamble:
|
||||
* SSL/Makefile.preamble:
|
||||
* configure.ac:
|
||||
* Documentation/manual/GNUmakefile:
|
||||
* Resources/GNUmakefile:
|
||||
* Examples/Makefile.preamble:
|
||||
* Examples/GNUmakefile:
|
||||
* Tools/Makefile.preamble:
|
||||
* Tools/make_strings/GNUmakefile.preamble:
|
||||
Improve setting of warning flags.
|
||||
|
||||
2010-03-11 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Source/NSException.m:
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
PACKAGE_NAME = gnustep-base
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
-include ../../config.mak
|
||||
|
||||
GNUSTEP_MAKEINFO_FLAGS = -D NO-TEXI2HTML
|
||||
|
||||
|
|
|
@ -45,6 +45,8 @@ GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES = ../base.make
|
|||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
|
||||
-include ../config.mak
|
||||
|
||||
# The tools to be created
|
||||
TEST_TOOL_NAME = \
|
||||
dictionary \
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = -Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS = $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -42,6 +42,7 @@ PACKAGE_NAME = gnustep-base
|
|||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
-include ../config.mak
|
||||
|
||||
CHARSET_FILES = \
|
||||
alphanumericCharSet.dat \
|
||||
|
|
|
@ -43,6 +43,7 @@ PACKAGE_NAME = gnustep-base
|
|||
GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES=../base.make
|
||||
|
||||
include $(GNUSTEP_MAKEFILES)/common.make
|
||||
-include ../config.mak
|
||||
|
||||
include ../Version
|
||||
libgnustep-base_INTERFACE_VERSION=$(MAJOR_VERSION).$(MINOR_VERSION)
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS = $(SSLFLAGS)
|
||||
|
|
|
@ -39,10 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement \
|
||||
-DNO_GNUSTEP=1
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS) -DNO_GNUSTEP=1
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -39,9 +39,8 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) -Wall \
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS) \
|
||||
-Wcast-align \
|
||||
-Wdeclaration-after-statement \
|
||||
#-Wstrict-prototypes \
|
||||
#-Wpointer-arith \
|
||||
#-Wcast-qual \
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -39,9 +39,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS = $(DEFS) $(CONFIG_SYSTEM_DEFS) $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS =
|
||||
|
|
|
@ -37,9 +37,7 @@
|
|||
#
|
||||
|
||||
# Additional flags to pass to the preprocessor
|
||||
ADDITIONAL_CPPFLAGS += \
|
||||
-Wall \
|
||||
-Wdeclaration-after-statement
|
||||
ADDITIONAL_CPPFLAGS += $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
#ADDITIONAL_OBJCFLAGS +=
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
ADDITIONAL_CPPFLAGS +=
|
||||
|
||||
# Additional flags to pass to the Objective-C compiler
|
||||
ADDITIONAL_OBJCFLAGS += -Wall -Wdeclaration-after-statement
|
||||
ADDITIONAL_OBJCFLAGS += $(WARN_FLAGS)
|
||||
|
||||
# Additional flags to pass to the C compiler
|
||||
#ADDITIONAL_CFLAGS +=
|
||||
|
|
|
@ -19,6 +19,7 @@ WITH_FFI=@WITH_FFI@
|
|||
NX_CONST_STRING_CLASS=@NX_CONST_STRING_CLASS@
|
||||
OBJCFLAGS+=@OBJCFLAGS@
|
||||
OBJC2RUNTIME=@OBJC2RUNTIME@
|
||||
WARN_FLAGS=@WARN_FLAGS@
|
||||
|
||||
HAVE_INET_PTON=@HAVE_INET_PTON@
|
||||
HAVE_INET_NTOP=@HAVE_INET_NTOP@
|
||||
|
|
218
configure
vendored
218
configure
vendored
|
@ -743,6 +743,7 @@ HAVE_MDNS
|
|||
USE_GMP
|
||||
INCLUDE_FLAGS
|
||||
LDIR_FLAGS
|
||||
WARN_FLAGS
|
||||
subdirs
|
||||
VERSION
|
||||
MAJOR_VERSION
|
||||
|
@ -20983,6 +20984,220 @@ _ACEOF
|
|||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check for C99ism warnings
|
||||
#--------------------------------------------------------------------
|
||||
{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C99" >&5
|
||||
echo $ECHO_N "checking for $CC option to accept ISO C99... $ECHO_C" >&6; }
|
||||
if test "${ac_cv_prog_cc_c99+set}" = set; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
ac_cv_prog_cc_c99=no
|
||||
ac_save_CC=$CC
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <wchar.h>
|
||||
#include <stdio.h>
|
||||
|
||||
// Check varargs macros. These examples are taken from C99 6.10.3.5.
|
||||
#define debug(...) fprintf (stderr, __VA_ARGS__)
|
||||
#define showlist(...) puts (#__VA_ARGS__)
|
||||
#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
|
||||
static void
|
||||
test_varargs_macros (void)
|
||||
{
|
||||
int x = 1234;
|
||||
int y = 5678;
|
||||
debug ("Flag");
|
||||
debug ("X = %d\n", x);
|
||||
showlist (The first, second, and third items.);
|
||||
report (x>y, "x is %d but y is %d", x, y);
|
||||
}
|
||||
|
||||
// Check long long types.
|
||||
#define BIG64 18446744073709551615ull
|
||||
#define BIG32 4294967295ul
|
||||
#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
|
||||
#if !BIG_OK
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
#if BIG_OK
|
||||
#else
|
||||
your preprocessor is broken;
|
||||
#endif
|
||||
static long long int bignum = -9223372036854775807LL;
|
||||
static unsigned long long int ubignum = BIG64;
|
||||
|
||||
struct incomplete_array
|
||||
{
|
||||
int datasize;
|
||||
double data[];
|
||||
};
|
||||
|
||||
struct named_init {
|
||||
int number;
|
||||
const wchar_t *name;
|
||||
double average;
|
||||
};
|
||||
|
||||
typedef const char *ccp;
|
||||
|
||||
static inline int
|
||||
test_restrict (ccp restrict text)
|
||||
{
|
||||
// See if C++-style comments work.
|
||||
// Iterate through items via the restricted pointer.
|
||||
// Also check for declarations in for loops.
|
||||
for (unsigned int i = 0; *(text+i) != '\0'; ++i)
|
||||
continue;
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Check varargs and va_copy.
|
||||
static void
|
||||
test_varargs (const char *format, ...)
|
||||
{
|
||||
va_list args;
|
||||
va_start (args, format);
|
||||
va_list args_copy;
|
||||
va_copy (args_copy, args);
|
||||
|
||||
const char *str;
|
||||
int number;
|
||||
float fnumber;
|
||||
|
||||
while (*format)
|
||||
{
|
||||
switch (*format++)
|
||||
{
|
||||
case 's': // string
|
||||
str = va_arg (args_copy, const char *);
|
||||
break;
|
||||
case 'd': // int
|
||||
number = va_arg (args_copy, int);
|
||||
break;
|
||||
case 'f': // float
|
||||
fnumber = va_arg (args_copy, double);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
va_end (args_copy);
|
||||
va_end (args);
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
|
||||
// Check bool.
|
||||
_Bool success = false;
|
||||
|
||||
// Check restrict.
|
||||
if (test_restrict ("String literal") == 0)
|
||||
success = true;
|
||||
char *restrict newvar = "Another string";
|
||||
|
||||
// Check varargs.
|
||||
test_varargs ("s, d' f .", "string", 65, 34.234);
|
||||
test_varargs_macros ();
|
||||
|
||||
// Check flexible array members.
|
||||
struct incomplete_array *ia =
|
||||
malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
|
||||
ia->datasize = 10;
|
||||
for (int i = 0; i < ia->datasize; ++i)
|
||||
ia->data[i] = i * 1.234;
|
||||
|
||||
// Check named initializers.
|
||||
struct named_init ni = {
|
||||
.number = 34,
|
||||
.name = L"Test wide string",
|
||||
.average = 543.34343,
|
||||
};
|
||||
|
||||
ni.number = 58;
|
||||
|
||||
int dynamic_array[ni.number];
|
||||
dynamic_array[ni.number - 1] = 543;
|
||||
|
||||
// work around unused variable warnings
|
||||
return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
|
||||
|| dynamic_array[ni.number - 1] != 543);
|
||||
|
||||
;
|
||||
return 0;
|
||||
}
|
||||
_ACEOF
|
||||
for ac_arg in '' -std=gnu99 -c99 -qlanglvl=extc99
|
||||
do
|
||||
CC="$ac_save_CC $ac_arg"
|
||||
rm -f conftest.$ac_objext
|
||||
if { (ac_try="$ac_compile"
|
||||
case "(($ac_try" in
|
||||
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
|
||||
*) ac_try_echo=$ac_try;;
|
||||
esac
|
||||
eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
|
||||
(eval "$ac_compile") 2>conftest.er1
|
||||
ac_status=$?
|
||||
grep -v '^ *+' conftest.er1 >conftest.err
|
||||
rm -f conftest.er1
|
||||
cat conftest.err >&5
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && {
|
||||
test -z "$ac_c_werror_flag" ||
|
||||
test ! -s conftest.err
|
||||
} && test -s conftest.$ac_objext; then
|
||||
ac_cv_prog_cc_c99=$ac_arg
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
|
||||
fi
|
||||
|
||||
rm -f core conftest.err conftest.$ac_objext
|
||||
test "x$ac_cv_prog_cc_c99" != "xno" && break
|
||||
done
|
||||
rm -f conftest.$ac_ext
|
||||
CC=$ac_save_CC
|
||||
|
||||
fi
|
||||
# AC_CACHE_VAL
|
||||
case "x$ac_cv_prog_cc_c99" in
|
||||
x)
|
||||
{ echo "$as_me:$LINENO: result: none needed" >&5
|
||||
echo "${ECHO_T}none needed" >&6; } ;;
|
||||
xno)
|
||||
{ echo "$as_me:$LINENO: result: unsupported" >&5
|
||||
echo "${ECHO_T}unsupported" >&6; } ;;
|
||||
*)
|
||||
CC="$CC $ac_cv_prog_cc_c99"
|
||||
{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c99" >&5
|
||||
echo "${ECHO_T}$ac_cv_prog_cc_c99" >&6; } ;;
|
||||
esac
|
||||
|
||||
|
||||
|
||||
# If the compiler supports c99 then we assume it supports the option to
|
||||
# warn about declarations after statements.
|
||||
if test "no" = "$ac_cv_prog_cc_c99"; then
|
||||
WARN_FLAGS=-Wall
|
||||
else
|
||||
WARN_FLAGS="-Wall -Wdeclaration-after-statement"
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Configure flags from sub-configure runs, so they show up in our
|
||||
# help file.
|
||||
|
@ -21865,6 +22080,7 @@ HAVE_MDNS!$HAVE_MDNS$ac_delim
|
|||
USE_GMP!$USE_GMP$ac_delim
|
||||
INCLUDE_FLAGS!$INCLUDE_FLAGS$ac_delim
|
||||
LDIR_FLAGS!$LDIR_FLAGS$ac_delim
|
||||
WARN_FLAGS!$WARN_FLAGS$ac_delim
|
||||
subdirs!$subdirs$ac_delim
|
||||
VERSION!$VERSION$ac_delim
|
||||
MAJOR_VERSION!$MAJOR_VERSION$ac_delim
|
||||
|
@ -21875,7 +22091,7 @@ LIBOBJS!$LIBOBJS$ac_delim
|
|||
LTLIBOBJS!$LTLIBOBJS$ac_delim
|
||||
_ACEOF
|
||||
|
||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 41; then
|
||||
if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 42; then
|
||||
break
|
||||
elif $ac_last_try; then
|
||||
{ { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
|
||||
|
|
14
configure.ac
14
configure.ac
|
@ -1743,6 +1743,20 @@ AM_LANGINFO_CODESET
|
|||
AC_SUBST(INCLUDE_FLAGS)
|
||||
AC_SUBST(LDIR_FLAGS)
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Check for C99ism warnings
|
||||
#--------------------------------------------------------------------
|
||||
AC_PROG_CC_C99
|
||||
# If the compiler supports c99 then we assume it supports the option to
|
||||
# warn about declarations after statements.
|
||||
if test "no" = "$ac_cv_prog_cc_c99"; then
|
||||
WARN_FLAGS=-Wall
|
||||
else
|
||||
WARN_FLAGS="-Wall -Wdeclaration-after-statement"
|
||||
fi
|
||||
AC_SUBST(WARN_FLAGS)
|
||||
|
||||
|
||||
#--------------------------------------------------------------------
|
||||
# Configure flags from sub-configure runs, so they show up in our
|
||||
# help file.
|
||||
|
|
Loading…
Reference in a new issue