1
dnl Copyright (C) 2009 Sun Microsystems
2
dnl This file is free software; Sun Microsystems
3
dnl gives unlimited permission to copy and/or distribute it,
4
dnl with or without modifications, as long as this notice is preserved.
1
6
dnl AC_PANDORA_WARNINGS([less-warnings|warnings-always-on])
2
7
dnl less-warnings turn on a limited set of warnings
3
8
dnl warnings-always-on always set warnings=error regardless of tarball/vc
5
10
AC_DEFUN([PANDORA_WARNINGS],[
11
m4_define([PW_LESS_WARNINGS],[no])
12
m4_define([PW_WARN_ALWAYS_ON],[no])
13
m4_foreach_w([pw_arg],$@,[
16
m4_undefine([PW_LESS_WARNINGS])
17
m4_define([PW_LESS_WARNINGS],[yes])
19
[warnings-always-on],[
20
m4_undefine([PW_WARN_ALWAYS_ON])
21
m4_define([PW_WARN_ALWAYS_ON],[yes])
19
25
AC_REQUIRE([PANDORA_BUILDING_FROM_VC])
20
AS_IF([test "${PW_VC_WARN_OFF}" = "no" -o "$ac_cv_building_from_vc" = "yes"],
26
m4_if(PW_WARN_ALWAYS_ON, [yes],
21
27
[ac_cv_warnings_as_errors=yes],
22
[ac_cv_warnings_as_errors=no])
28
AS_IF([test "$ac_cv_building_from_vc" = "yes"],
29
[ac_cv_warnings_as_errors=yes],
30
[ac_cv_warnings_as_errors=no]))
24
32
AC_ARG_ENABLE([profiling],
25
33
[AS_HELP_STRING([--enable-profiling],
110
118
NO_STRICT_ALIASING="-fno-strict-aliasing -Wno-strict-aliasing"
111
119
NO_SHADOW="-Wno-shadow"
113
AS_IF([test "${PW_FULL_WARNINGS}" = "yes"],[
121
m4_if(PW_LESS_WARNINGS,[no],[
114
122
BASE_WARNINGS_FULL="-Wformat=2 ${W_CONVERSION} -Wstrict-aliasing"
115
123
CC_WARNINGS_FULL="-Wswitch-default -Wswitch-enum"
116
124
CXX_WARNINGS_FULL="-Weffc++ -Wold-style-cast"
118
126
BASE_WARNINGS_FULL="-Wformat ${NO_STRICT_ALIASING}"
121
BASE_WARNINGS="-pedantic -Wall -Wextra ${W_FAIL} -Wundef -Wshadow -Wmissing-declarations -Wstrict-aliasing ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
122
CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls ${CC_WARNINGS_FULL} -Wcast-align"
129
BASE_WARNINGS="${W_FAIL} -pedantic -Wall -Wextra -Wundef -Wshadow -Wstrict-aliasing ${F_DIAGNOSTICS_SHOW_OPTION} ${CFLAG_VISIBILITY} ${BASE_WARNINGS_FULL}"
130
CC_WARNINGS="${BASE_WARNINGS} -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wmissing-declarations -Wcast-align ${CC_WARNINGS_FULL}"
123
131
CXX_WARNINGS="${BASE_WARNINGS} -Woverloaded-virtual -Wnon-virtual-dtor -Wctor-dtor-privacy -Wno-long-long ${CXX_WARNINGS_FULL}"
133
AC_CACHE_CHECK([whether it is safe to use -Wmissing-declarations from C++],
134
[ac_cv_safe_to_use_Wmissing_declarations_],
136
save_CXXFLAGS="$CXXFLAGS"
137
CXXFLAGS="-Werror -pedantic -Wmissing-declarations ${AM_CXXFLAGS}"
144
[ac_cv_safe_to_use_Wmissing_declarations_=yes],
145
[ac_cv_safe_to_use_Wmissing_declarations_=no])
146
CXXFLAGS="$save_CXXFLAGS"
149
AS_IF([test "$ac_cv_safe_to_use_Wmissing_declarations_" = "yes"],
150
[CXX_WARNINGS="${CXX_WARNINGS} -Wmissing-declarations"])
125
152
AC_CACHE_CHECK([whether it is safe to use -Wlogical-op],
126
153
[ac_cv_safe_to_use_Wlogical_op_],
127
154
[save_CFLAGS="$CFLAGS"
128
CFLAGS="-Wlogical-op -Werror -pedantic ${AM_CFLAGS}"
155
CFLAGS="${W_FAIL} -pedantic -Wlogical-op ${AM_CFLAGS}"
129
156
AC_COMPILE_IFELSE([
142
169
[ac_cv_safe_to_use_Wredundant_decls_],
143
170
[AC_LANG_PUSH(C++)
144
171
save_CXXFLAGS="${CXXFLAGS}"
145
CXXFLAGS="-Wredundant-decls ${W_FAIL} -pedantic -Wredundant-decls"
172
CXXFLAGS="${W_FAIL} -pedantic -Wredundant-decls ${AM_CXXFLAGS}"
146
173
AC_COMPILE_IFELSE(
147
174
[AC_LANG_PROGRAM([
148
175
template <typename E> struct C { void foo(); };
188
215
[W_PASTE_RESULT=",E_PASTE_RESULT_NOT_TOKEN"])
191
AS_IF([test "${PW_FULL_WARNINGS}" = "yes"],[
218
m4_if(PW_LESS_WARNINGS, [no],[
192
219
CC_WARNINGS_FULL="-erroff=E_INTEGER_OVERFLOW_DETECTED${W_PASTE_RESULT}"
194
221
CC_WARNINGS_FULL="-erroff=E_ATTRIBUTE_NOT_VAR"