cflags.patch 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. diff -Nur gcc-4.6.0.orig/gcc/c-family/c-opts.c gcc-4.6.0/gcc/c-family/c-opts.c
  2. --- gcc-4.6.0.orig/gcc/c-family/c-opts.c 2011-01-26 07:48:04.000000000 +0100
  3. +++ gcc-4.6.0/gcc/c-family/c-opts.c 2011-03-31 15:46:52.000000000 +0200
  4. @@ -103,6 +103,9 @@
  5. /* Number of deferred options scanned for -include. */
  6. static size_t include_cursor;
  7. +/* Check if a port honours COPTS. */
  8. +static int honour_copts = 0;
  9. +
  10. static void handle_OPT_d (const char *);
  11. static void set_std_cxx98 (int);
  12. static void set_std_cxx0x (int);
  13. @@ -441,6 +444,9 @@
  14. global_dc->warning_as_error_requested = value;
  15. break;
  16. + case OPT_Werror_maybe_reset:
  17. + break;
  18. +
  19. case OPT_Wformat:
  20. set_Wformat (value);
  21. break;
  22. @@ -653,6 +659,11 @@
  23. visibility_options.inlines_hidden = value;
  24. break;
  25. + case OPT_fhonour_copts:
  26. + if (c_language == clk_c)
  27. + honour_copts++;
  28. + break;
  29. +
  30. case OPT_femit_struct_debug_baseonly:
  31. set_struct_debug_option (&global_options, loc, "base");
  32. break;
  33. @@ -1058,6 +1069,47 @@
  34. return false;
  35. }
  36. + if (c_language == clk_c) {
  37. + char *ev = getenv ("GCC_HONOUR_COPTS");
  38. + int evv;
  39. + if (ev == NULL)
  40. + evv = -1;
  41. + else if ((*ev == '0') || (*ev == '\0'))
  42. + evv = 0;
  43. + else if (*ev == '1')
  44. + evv = 1;
  45. + else if (*ev == '2')
  46. + evv = 2;
  47. + else if (*ev == 's')
  48. + evv = -1;
  49. + else {
  50. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  51. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  52. + }
  53. + if (evv == 1) {
  54. + if (honour_copts == 0) {
  55. + error ("someone does not honour COPTS at all in lenient mode");
  56. + return false;
  57. + } else if (honour_copts != 1) {
  58. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  59. + honour_copts);
  60. + }
  61. + } else if (evv == 2) {
  62. + if (honour_copts == 0) {
  63. + error ("someone does not honour COPTS at all in strict mode");
  64. + return false;
  65. + } else if (honour_copts != 1) {
  66. + error ("someone does not honour COPTS correctly, passed %d times",
  67. + honour_copts);
  68. + return false;
  69. + }
  70. + } else if (evv == 0) {
  71. + if (honour_copts != 1)
  72. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  73. + honour_copts);
  74. + }
  75. + }
  76. +
  77. return true;
  78. }
  79. diff -Nur gcc-4.6.0.orig/gcc/c-family/c.opt gcc-4.6.0/gcc/c-family/c.opt
  80. --- gcc-4.6.0.orig/gcc/c-family/c.opt 2011-02-17 22:34:10.000000000 +0100
  81. +++ gcc-4.6.0/gcc/c-family/c.opt 2011-03-31 15:40:46.000000000 +0200
  82. @@ -363,6 +363,10 @@
  83. C ObjC RejectNegative Warning Alias(Werror=, implicit-function-declaration)
  84. This switch is deprecated; use -Werror=implicit-function-declaration instead
  85. +Werror-maybe-reset
  86. +C ObjC C++ ObjC++
  87. +; Documented in common.opt
  88. +
  89. Wfloat-equal
  90. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  91. Warn if testing floating point numbers for equality
  92. @@ -790,6 +794,9 @@
  93. fhonor-std
  94. C++ ObjC++ Ignore Warn(switch %qs is no longer supported)
  95. +fhonour-copts
  96. +C ObjC C++ ObjC++ RejectNegative
  97. +
  98. fhosted
  99. C ObjC
  100. Assume normal C execution environment
  101. diff -Nur gcc-4.6.0.orig/gcc/common.opt gcc-4.6.0/gcc/common.opt
  102. --- gcc-4.6.0.orig/gcc/common.opt 2011-03-06 01:38:13.000000000 +0100
  103. +++ gcc-4.6.0/gcc/common.opt 2011-03-31 15:40:46.000000000 +0200
  104. @@ -511,6 +511,10 @@
  105. Common Joined
  106. Treat specified warning as error
  107. +Werror-maybe-reset
  108. +Common
  109. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  110. +
  111. Wextra
  112. Common Var(extra_warnings) Warning
  113. Print extra (possibly unwanted) warnings
  114. @@ -1147,6 +1151,9 @@
  115. Common Report Var(flag_guess_branch_prob) Optimization
  116. Enable guessing of branch probabilities
  117. +fhonour-copts
  118. +Common RejectNegative
  119. +
  120. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  121. ; Generate position-independent code for executables if possible
  122. ; On SVR4 targets, it also controls whether or not to emit a
  123. diff -Nur gcc-4.6.0.orig/gcc/doc/cppopts.texi gcc-4.6.0/gcc/doc/cppopts.texi
  124. --- gcc-4.6.0.orig/gcc/doc/cppopts.texi 2010-12-20 08:26:12.000000000 +0100
  125. +++ gcc-4.6.0/gcc/doc/cppopts.texi 2011-03-31 15:40:46.000000000 +0200
  126. @@ -164,6 +164,11 @@
  127. Make all warnings into hard errors. Source code which triggers warnings
  128. will be rejected.
  129. + at item -Werror-maybe-reset
  130. + at opindex Werror-maybe-reset
  131. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  132. +variable is set to anything other than 0 or empty.
  133. +
  134. @item -Wsystem-headers
  135. @opindex Wsystem-headers
  136. Issue warnings for code in system headers. These are normally unhelpful
  137. diff -Nur gcc-4.6.0.orig/gcc/doc/invoke.texi gcc-4.6.0/gcc/doc/invoke.texi
  138. --- gcc-4.6.0.orig/gcc/doc/invoke.texi 2011-03-18 15:34:52.000000000 +0100
  139. +++ gcc-4.6.0/gcc/doc/invoke.texi 2011-03-31 15:41:41.000000000 +0200
  140. @@ -240,7 +240,7 @@
  141. -Wconversion -Wcoverage-mismatch -Wcpp -Wno-deprecated @gol
  142. -Wno-deprecated-declarations -Wdisabled-optimization @gol
  143. -Wno-div-by-zero -Wdouble-promotion -Wempty-body -Wenum-compare @gol
  144. --Wno-endif-labels -Werror -Werror=* @gol
  145. +-Wno-endif-labels -Werror -Werror=* -Werror-maybe-reset @gol
  146. -Wfatal-errors -Wfloat-equal -Wformat -Wformat=2 @gol
  147. -Wno-format-contains-nul -Wno-format-extra-args -Wformat-nonliteral @gol
  148. -Wformat-security -Wformat-y2k @gol
  149. @@ -4488,6 +4488,22 @@
  150. @option{-Wall} and by @option{-pedantic}, which can be disabled with
  151. @option{-Wno-pointer-sign}.
  152. + at item -Werror-maybe-reset
  153. + at opindex Werror-maybe-reset
  154. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  155. +variable is set to anything other than 0 or empty.
  156. +
  157. + at item -fhonour-copts
  158. + at opindex fhonour-copts
  159. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  160. +given at least once, and warn if it is given more than once.
  161. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  162. +given exactly once.
  163. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  164. +is not given exactly once.
  165. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  166. +This flag and environment variable only affect the C language.
  167. +
  168. @item -Wstack-protector
  169. @opindex Wstack-protector
  170. @opindex Wno-stack-protector
  171. @@ -6310,7 +6326,7 @@
  172. second branch or a point immediately following it, depending on whether
  173. the condition is known to be true or false.
  174. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  175. +Enabled at levels @option{-O3}.
  176. @item -fsplit-wide-types
  177. @opindex fsplit-wide-types
  178. diff -Nur gcc-4.6.0.orig/gcc/java/jvspec.c gcc-4.6.0/gcc/java/jvspec.c
  179. --- gcc-4.6.0.orig/gcc/java/jvspec.c 2011-02-13 20:20:01.000000000 +0100
  180. +++ gcc-4.6.0/gcc/java/jvspec.c 2011-03-31 15:40:46.000000000 +0200
  181. @@ -627,6 +627,7 @@
  182. class name. Append dummy `.c' that can be stripped by set_input so %b
  183. is correct. */
  184. set_input (concat (main_class_name, "main.c", NULL));
  185. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  186. err = do_spec (jvgenmain_spec);
  187. if (err == 0)
  188. {
  189. diff -Nur gcc-4.6.0.orig/gcc/opts.c gcc-4.6.0/gcc/opts.c
  190. --- gcc-4.6.0.orig/gcc/opts.c 2011-02-17 23:51:57.000000000 +0100
  191. +++ gcc-4.6.0/gcc/opts.c 2011-03-31 15:43:52.000000000 +0200
  192. @@ -477,8 +477,6 @@
  193. { OPT_LEVELS_2_PLUS, OPT_fschedule_insns2, NULL, 1 },
  194. #endif
  195. { OPT_LEVELS_2_PLUS, OPT_fregmove, NULL, 1 },
  196. - { OPT_LEVELS_2_PLUS, OPT_fstrict_aliasing, NULL, 1 },
  197. - { OPT_LEVELS_2_PLUS, OPT_fstrict_overflow, NULL, 1 },
  198. { OPT_LEVELS_2_PLUS, OPT_freorder_blocks, NULL, 1 },
  199. { OPT_LEVELS_2_PLUS, OPT_freorder_functions, NULL, 1 },
  200. { OPT_LEVELS_2_PLUS, OPT_ftree_vrp, NULL, 1 },
  201. @@ -501,6 +499,8 @@
  202. { OPT_LEVELS_3_PLUS_AND_SIZE, OPT_finline_functions, NULL, 1 },
  203. { OPT_LEVELS_3_PLUS, OPT_funswitch_loops, NULL, 1 },
  204. { OPT_LEVELS_3_PLUS, OPT_fgcse_after_reload, NULL, 1 },
  205. + { OPT_LEVELS_3_PLUS, OPT_fstrict_aliasing, NULL, 1 },
  206. + { OPT_LEVELS_3_PLUS, OPT_fstrict_overflow, NULL, 1 },
  207. { OPT_LEVELS_3_PLUS, OPT_ftree_vectorize, NULL, 1 },
  208. { OPT_LEVELS_3_PLUS, OPT_fipa_cp_clone, NULL, 1 },
  209. @@ -1399,6 +1399,17 @@
  210. opts, opts_set, loc, dc);
  211. break;
  212. + case OPT_Werror_maybe_reset:
  213. + {
  214. + char *ev = getenv ("GCC_NO_WERROR");
  215. + if ((ev != NULL) && (*ev != '0'))
  216. + warnings_are_errors = 0;
  217. + }
  218. + break;
  219. +
  220. + case OPT_fhonour_copts:
  221. + break;
  222. +
  223. case OPT_Wlarger_than_:
  224. opts->x_larger_than_size = value;
  225. opts->x_warn_larger_than = value != -1;