2 This patch brings over a few features from MirBSD:
4 If this option is not given, it's warned (depending
5 on environment variables). This is to catch errors
6 of misbuilt packages which override CFLAGS themselves.
8 Has the effect of -Wno-error if GCC_NO_WERROR is
9 set and not '0', a no-operation otherwise. This is
10 to be able to use -Werror in "make" but prevent
11 GNU autoconf generated configure scripts from
14 This patch was authored by Thorsten Glaser <tg at mirbsd.de>
15 with copyright assignment to the FSF in effect.
17 --- a/gcc/c-family/c-opts.c
18 +++ b/gcc/c-family/c-opts.c
19 @@ -122,6 +122,9 @@ static int class_dump_flags;
20 /* Whether any standard preincluded header has been preincluded. */
21 static bool done_preinclude;
23 +/* Check if a port honours COPTS. */
24 +static int honour_copts = 0;
26 static void handle_OPT_d (const char *);
27 static void set_std_cxx98 (int);
28 static void set_std_cxx11 (int);
29 @@ -449,6 +452,12 @@ c_common_handle_option (size_t scode, co
30 flag_no_builtin = !value;
33 + case OPT_fhonour_copts:
34 + if (c_language == clk_c) {
39 case OPT_fconstant_string_class_:
40 constant_string_class_name = arg;
42 @@ -1034,6 +1043,47 @@ c_common_init (void)
46 + if (c_language == clk_c) {
47 + char *ev = getenv ("GCC_HONOUR_COPTS");
51 + else if ((*ev == '0') || (*ev == '\0'))
53 + else if (*ev == '1')
55 + else if (*ev == '2')
57 + else if (*ev == 's')
60 + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
61 + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
64 + if (honour_copts == 0) {
65 + error ("someone does not honour COPTS at all in lenient mode");
67 + } else if (honour_copts != 1) {
68 + warning (0, "someone does not honour COPTS correctly, passed %d times",
71 + } else if (evv == 2) {
72 + if (honour_copts == 0) {
73 + error ("someone does not honour COPTS at all in strict mode");
75 + } else if (honour_copts != 1) {
76 + error ("someone does not honour COPTS correctly, passed %d times",
80 + } else if (evv == 0) {
81 + if (honour_copts != 1)
82 + inform (0, "someone does not honour COPTS correctly, passed %d times",
90 --- a/gcc/c-family/c.opt
91 +++ b/gcc/c-family/c.opt
92 @@ -431,6 +431,10 @@ Wfloat-conversion
93 C ObjC C++ ObjC++ Var(warn_float_conversion) LangEnabledBy(C ObjC C++ ObjC++,Wconversion)
94 Warn for implicit type conversions that cause loss of floating point precision
98 +; Documented in common.opt
101 C ObjC C++ ObjC++ Var(warn_float_equal) Warning
102 Warn if testing floating point numbers for equality
103 @@ -1161,6 +1165,9 @@ C++ ObjC++ Optimization Alias(fexception
105 C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
108 +C ObjC C++ ObjC++ RejectNegative
112 Assume normal C execution environment
115 @@ -561,6 +561,10 @@ Werror=
117 Treat specified warning as error
121 +If environment variable GCC_NO_WERROR is set, act as -Wno-error
124 Common Var(extra_warnings) Warning
125 Print extra (possibly unwanted) warnings
126 @@ -1360,6 +1364,9 @@ fguess-branch-probability
127 Common Report Var(flag_guess_branch_prob) Optimization
128 Enable guessing of branch probabilities
131 +Common RejectNegative
133 ; Nonzero means ignore `#ident' directives. 0 means handle them.
134 ; Generate position-independent code for executables if possible
135 ; On SVR4 targets, it also controls whether or not to emit a
138 @@ -1699,6 +1699,17 @@ common_handle_option (struct gcc_options
139 opts, opts_set, loc, dc);
142 + case OPT_Werror_maybe_reset:
144 + char *ev = getenv ("GCC_NO_WERROR");
145 + if ((ev != NULL) && (*ev != '0'))
146 + warnings_are_errors = 0;
150 + case OPT_fhonour_copts:
153 case OPT_Wlarger_than_:
154 opts->x_larger_than_size = value;
155 opts->x_warn_larger_than = value != -1;
156 --- a/gcc/doc/cppopts.texi
157 +++ b/gcc/doc/cppopts.texi
158 @@ -163,6 +163,11 @@ in older programs. This warning is on b
159 Make all warnings into hard errors. Source code which triggers warnings
162 +@item -Werror-maybe-reset
163 +@opindex Werror-maybe-reset
164 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
165 +variable is set to anything other than 0 or empty.
167 @item -Wsystem-headers
168 @opindex Wsystem-headers
169 Issue warnings for code in system headers. These are normally unhelpful
170 --- a/gcc/doc/invoke.texi
171 +++ b/gcc/doc/invoke.texi
172 @@ -251,7 +251,7 @@ Objective-C and Objective-C++ Dialects}.
173 -Wdisabled-optimization @gol
174 -Wno-discarded-qualifiers -Wno-discarded-array-qualifiers @gol
175 -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
176 --Wno-endif-labels -Werror -Werror=* @gol
177 +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
178 -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
179 -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
180 -Wformat-security -Wformat-signedness -Wformat-y2k @gol
181 @@ -5382,6 +5382,22 @@ This option is only supported for C and
182 @option{-Wall} and by @option{-Wpedantic}, which can be disabled with
183 @option{-Wno-pointer-sign}.
185 +@item -Werror-maybe-reset
186 +@opindex Werror-maybe-reset
187 +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
188 +variable is set to anything other than 0 or empty.
190 +@item -fhonour-copts
191 +@opindex fhonour-copts
192 +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
193 +given at least once, and warn if it is given more than once.
194 +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
196 +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
197 +is not given exactly once.
198 +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
199 +This flag and environment variable only affect the C language.
201 @item -Wstack-protector
202 @opindex Wstack-protector
203 @opindex Wno-stack-protector
204 @@ -7860,7 +7876,7 @@ so, the first branch is redirected to ei
205 second branch or a point immediately following it, depending on whether
206 the condition is known to be true or false.
208 -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
209 +Enabled at levels @option{-O3}.
211 @item -fsplit-wide-types
212 @opindex fsplit-wide-types
213 --- a/gcc/java/jvspec.c
214 +++ b/gcc/java/jvspec.c
215 @@ -629,6 +629,7 @@ lang_specific_pre_link (void)
216 class name. Append dummy `.c' that can be stripped by set_input so %b
218 set_input (concat (main_class_name, "main.c", NULL));
219 + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
220 err = do_spec (jvgenmain_spec);