cflags-honour.patch 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. diff -Nur gcc-4.5.4.orig/gcc/common.opt gcc-4.5.4/gcc/common.opt
  2. --- gcc-4.5.4.orig/gcc/common.opt 2010-03-18 04:01:09.000000000 +0100
  3. +++ gcc-4.5.4/gcc/common.opt 2014-08-29 11:25:51.000000000 +0200
  4. @@ -105,6 +105,10 @@
  5. Common Joined
  6. Treat specified warning as error
  7. +Werror-maybe-reset
  8. +Common
  9. +If environment variable GCC_NO_WERROR is set, act as -Wno-error
  10. +
  11. Wextra
  12. Common Var(extra_warnings) Warning
  13. Print extra (possibly unwanted) warnings
  14. @@ -613,6 +617,9 @@
  15. Common Report Var(flag_guess_branch_prob) Optimization
  16. Enable guessing of branch probabilities
  17. +fhonour-copts
  18. +Common RejectNegative
  19. +
  20. ; Nonzero means ignore `#ident' directives. 0 means handle them.
  21. ; Generate position-independent code for executables if possible
  22. ; On SVR4 targets, it also controls whether or not to emit a
  23. diff -Nur gcc-4.5.4.orig/gcc/c.opt gcc-4.5.4/gcc/c.opt
  24. --- gcc-4.5.4.orig/gcc/c.opt 2010-04-02 21:54:46.000000000 +0200
  25. +++ gcc-4.5.4/gcc/c.opt 2014-08-29 11:25:51.000000000 +0200
  26. @@ -219,6 +219,10 @@
  27. C ObjC RejectNegative Warning
  28. This switch is deprecated; use -Werror=implicit-function-declaration instead
  29. +Werror-maybe-reset
  30. +C ObjC C++ ObjC++
  31. +; Documented in common.opt
  32. +
  33. Wfloat-equal
  34. C ObjC C++ ObjC++ Var(warn_float_equal) Warning
  35. Warn if testing floating point numbers for equality
  36. @@ -633,6 +637,9 @@
  37. fhonor-std
  38. C++ ObjC++
  39. +fhonour-copts
  40. +C ObjC C++ ObjC++ RejectNegative
  41. +
  42. fhosted
  43. C ObjC
  44. Assume normal C execution environment
  45. diff -Nur gcc-4.5.4.orig/gcc/c-opts.c gcc-4.5.4/gcc/c-opts.c
  46. --- gcc-4.5.4.orig/gcc/c-opts.c 2010-04-02 21:54:46.000000000 +0200
  47. +++ gcc-4.5.4/gcc/c-opts.c 2014-08-29 11:25:51.000000000 +0200
  48. @@ -106,6 +106,9 @@
  49. /* Number of deferred options scanned for -include. */
  50. static size_t include_cursor;
  51. +/* Check if a port honours COPTS. */
  52. +static int honour_copts = 0;
  53. +
  54. static void set_Wimplicit (int);
  55. static void handle_OPT_d (const char *);
  56. static void set_std_cxx98 (int);
  57. @@ -472,6 +475,9 @@
  58. enable_warning_as_error ("implicit-function-declaration", value, CL_C | CL_ObjC);
  59. break;
  60. + case OPT_Werror_maybe_reset:
  61. + break;
  62. +
  63. case OPT_Wformat:
  64. set_Wformat (value);
  65. break;
  66. @@ -704,6 +710,12 @@
  67. flag_exceptions = value;
  68. break;
  69. + case OPT_fhonour_copts:
  70. + if (c_language == clk_c) {
  71. + honour_copts++;
  72. + }
  73. + break;
  74. +
  75. case OPT_fimplement_inlines:
  76. flag_implement_inlines = value;
  77. break;
  78. @@ -1240,6 +1252,47 @@
  79. return false;
  80. }
  81. + if (c_language == clk_c) {
  82. + char *ev = getenv ("GCC_HONOUR_COPTS");
  83. + int evv;
  84. + if (ev == NULL)
  85. + evv = -1;
  86. + else if ((*ev == '0') || (*ev == '\0'))
  87. + evv = 0;
  88. + else if (*ev == '1')
  89. + evv = 1;
  90. + else if (*ev == '2')
  91. + evv = 2;
  92. + else if (*ev == 's')
  93. + evv = -1;
  94. + else {
  95. + warning (0, "unknown GCC_HONOUR_COPTS value, assuming 1");
  96. + evv = 1; /* maybe depend this on something like MIRBSD_NATIVE? */
  97. + }
  98. + if (evv == 1) {
  99. + if (honour_copts == 0) {
  100. + error ("someone does not honour COPTS at all in lenient mode");
  101. + return false;
  102. + } else if (honour_copts != 1) {
  103. + warning (0, "someone does not honour COPTS correctly, passed %d times",
  104. + honour_copts);
  105. + }
  106. + } else if (evv == 2) {
  107. + if (honour_copts == 0) {
  108. + error ("someone does not honour COPTS at all in strict mode");
  109. + return false;
  110. + } else if (honour_copts != 1) {
  111. + error ("someone does not honour COPTS correctly, passed %d times",
  112. + honour_copts);
  113. + return false;
  114. + }
  115. + } else if (evv == 0) {
  116. + if (honour_copts != 1)
  117. + inform (0, "someone does not honour COPTS correctly, passed %d times",
  118. + honour_copts);
  119. + }
  120. + }
  121. +
  122. return true;
  123. }
  124. diff -Nur gcc-4.5.4.orig/gcc/doc/cppopts.texi gcc-4.5.4/gcc/doc/cppopts.texi
  125. --- gcc-4.5.4.orig/gcc/doc/cppopts.texi 2010-04-02 21:54:46.000000000 +0200
  126. +++ gcc-4.5.4/gcc/doc/cppopts.texi 2014-08-29 11:25:51.000000000 +0200
  127. @@ -164,6 +164,11 @@
  128. Make all warnings into hard errors. Source code which triggers warnings
  129. will be rejected.
  130. + at item -Werror-maybe-reset
  131. + at opindex Werror-maybe-reset
  132. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  133. +variable is set to anything other than 0 or empty.
  134. +
  135. @item -Wsystem-headers
  136. @opindex Wsystem-headers
  137. Issue warnings for code in system headers. These are normally unhelpful
  138. diff -Nur gcc-4.5.4.orig/gcc/doc/invoke.texi gcc-4.5.4/gcc/doc/invoke.texi
  139. --- gcc-4.5.4.orig/gcc/doc/invoke.texi 2011-03-23 23:03:29.000000000 +0100
  140. +++ gcc-4.5.4/gcc/doc/invoke.texi 2014-08-29 11:25:51.000000000 +0200
  141. @@ -4324,6 +4324,22 @@
  142. @option{-Wall} and by @option{-pedantic}, which can be disabled with
  143. @option{-Wno-pointer-sign}.
  144. + at item -Werror-maybe-reset
  145. + at opindex Werror-maybe-reset
  146. +Act like @samp{-Wno-error} if the @env{GCC_NO_WERROR} environment
  147. +variable is set to anything other than 0 or empty.
  148. +
  149. + at item -fhonour-copts
  150. + at opindex fhonour-copts
  151. +If @env{GCC_HONOUR_COPTS} is set to 1, abort if this option is not
  152. +given at least once, and warn if it is given more than once.
  153. +If @env{GCC_HONOUR_COPTS} is set to 2, abort if this option is not
  154. +given exactly once.
  155. +If @env{GCC_HONOUR_COPTS} is set to 0 or unset, warn if this option
  156. +is not given exactly once.
  157. +The warning is quelled if @env{GCC_HONOUR_COPTS} is set to @samp{s}.
  158. +This flag and environment variable only affect the C language.
  159. +
  160. @item -Wstack-protector
  161. @opindex Wstack-protector
  162. @opindex Wno-stack-protector
  163. @@ -6076,7 +6092,7 @@
  164. second branch or a point immediately following it, depending on whether
  165. the condition is known to be true or false.
  166. -Enabled at levels @option{-O2}, @option{-O3}, @option{-Os}.
  167. +Enabled at levels @option{-O3}.
  168. @item -fsplit-wide-types
  169. @opindex fsplit-wide-types
  170. diff -Nur gcc-4.5.4.orig/gcc/java/jvspec.c gcc-4.5.4/gcc/java/jvspec.c
  171. --- gcc-4.5.4.orig/gcc/java/jvspec.c 2010-01-20 11:35:38.000000000 +0100
  172. +++ gcc-4.5.4/gcc/java/jvspec.c 2014-08-29 11:25:51.000000000 +0200
  173. @@ -667,6 +667,7 @@
  174. class name. Append dummy `.c' that can be stripped by set_input so %b
  175. is correct. */
  176. set_input (concat (main_class_name, "main.c", NULL));
  177. + putenv ("GCC_HONOUR_COPTS=s"); /* XXX hack! */
  178. err = do_spec (jvgenmain_spec);
  179. if (err == 0)
  180. {
  181. diff -Nur gcc-4.5.4.orig/gcc/opts.c gcc-4.5.4/gcc/opts.c
  182. --- gcc-4.5.4.orig/gcc/opts.c 2010-05-17 12:13:28.000000000 +0200
  183. +++ gcc-4.5.4/gcc/opts.c 2014-08-29 11:25:51.000000000 +0200
  184. @@ -897,8 +897,6 @@
  185. flag_schedule_insns_after_reload = opt2;
  186. #endif
  187. flag_regmove = opt2;
  188. - flag_strict_aliasing = opt2;
  189. - flag_strict_overflow = opt2;
  190. flag_reorder_blocks = opt2;
  191. flag_reorder_functions = opt2;
  192. flag_tree_vrp = opt2;
  193. @@ -918,6 +916,8 @@
  194. /* -O3 optimizations. */
  195. opt3 = (optimize >= 3);
  196. + flag_strict_aliasing = opt3;
  197. + flag_strict_overflow = opt3;
  198. flag_predictive_commoning = opt3;
  199. flag_inline_functions = opt3;
  200. flag_unswitch_loops = opt3;
  201. @@ -1646,6 +1646,17 @@
  202. enable_warning_as_error (arg, value, lang_mask);
  203. break;
  204. + case OPT_Werror_maybe_reset:
  205. + {
  206. + char *ev = getenv ("GCC_NO_WERROR");
  207. + if ((ev != NULL) && (*ev != '0'))
  208. + warnings_are_errors = 0;
  209. + }
  210. + break;
  211. +
  212. + case OPT_fhonour_copts:
  213. + break;
  214. +
  215. case OPT_Wlarger_than_:
  216. /* This form corresponds to -Wlarger-than-.
  217. Kept for backward compatibility.