fix-23714-cxx11-v2.patch 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. Index: configure.ac
  2. ===================================================================
  3. --- configure.ac (révision 956)
  4. +++ configure.ac (copie de travail)
  5. @@ -18,8 +18,9 @@
  6. AC_C_INLINE
  7. # Checks for programs.
  8. +AC_LANG([C++])
  9. AC_PROG_CXX
  10. -#AC_PROG_CC
  11. +AX_CXX_COMPILE_STDCXX_11([noext], [mandatory])
  12. # Checks for library functions.
  13. AC_FUNC_SELECT_ARGTYPES
  14. @@ -253,7 +254,7 @@
  15. if test "$enable_debug" = "yes"; then
  16. CXXFLAGS="$CXXFLAGS -DDEBUG -g"
  17. - LDFLAGS="$LDFLAGS -g -ansi -Wall"
  18. + LDFLAGS="$LDFLAGS -g -Wall"
  19. fi
  20. # =========================================================================
  21. @@ -265,13 +266,13 @@
  22. if test "$enable_profile" = "yes"; then
  23. CXXFLAGS="$CXXFLAGS -pg"
  24. - LDFLAGS="$LDFLAGS -pg -ansi -Wall"
  25. + LDFLAGS="$LDFLAGS -pg -Wall"
  26. fi
  27. # =========================================================================
  28. # gcc flags
  29. -CXXFLAGS="$CXXFLAGS -ansi -Wall -Wextra -Wconversion" #-Werror
  30. +CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wconversion" #-Werror
  31. # =========================================================================
  32. # make use of ccache
  33. Index: m4/ax_cxx_compile_stdcxx_11.m4
  34. ===================================================================
  35. --- m4/ax_cxx_compile_stdcxx_11.m4 (nonexistent)
  36. +++ m4/ax_cxx_compile_stdcxx_11.m4 (copie de travail)
  37. @@ -0,0 +1,172 @@
  38. +# ============================================================================
  39. +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
  40. +# ============================================================================
  41. +#
  42. +# SYNOPSIS
  43. +#
  44. +# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
  45. +#
  46. +# DESCRIPTION
  47. +#
  48. +# Check for baseline language coverage in the compiler for the C++11
  49. +# standard; if necessary, add switches to CXXFLAGS to enable support.
  50. +#
  51. +# The first argument, if specified, indicates whether you insist on an
  52. +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
  53. +# -std=c++11). If neither is specified, you get whatever works, with
  54. +# preference for an extended mode.
  55. +#
  56. +# The second argument, if specified 'mandatory' or if left unspecified,
  57. +# indicates that baseline C++11 support is required and that the macro
  58. +# should error out if no mode with that support is found. If specified
  59. +# 'optional', then configuration proceeds regardless, after defining
  60. +# HAVE_CXX11 if and only if a supporting mode is found.
  61. +#
  62. +# LICENSE
  63. +#
  64. +# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
  65. +# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
  66. +# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
  67. +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
  68. +# Copyright (c) 2015 Paul Norman <penorman@mac.com>
  69. +#
  70. +# Copying and distribution of this file, with or without modification, are
  71. +# permitted in any medium without royalty provided the copyright notice
  72. +# and this notice are preserved. This file is offered as-is, without any
  73. +# warranty.
  74. +
  75. +#serial 13
  76. +
  77. +m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [[
  78. + template <typename T>
  79. + struct check
  80. + {
  81. + static_assert(sizeof(int) <= sizeof(T), "not big enough");
  82. + };
  83. +
  84. + struct Base {
  85. + virtual void f() {}
  86. + };
  87. + struct Child : public Base {
  88. + virtual void f() override {}
  89. + };
  90. +
  91. + typedef check<check<bool>> right_angle_brackets;
  92. +
  93. + int a;
  94. + decltype(a) b;
  95. +
  96. + typedef check<int> check_type;
  97. + check_type c;
  98. + check_type&& cr = static_cast<check_type&&>(c);
  99. +
  100. + auto d = a;
  101. + auto l = [](){};
  102. + // Prevent Clang error: unused variable 'l' [-Werror,-Wunused-variable]
  103. + struct use_l { use_l() { l(); } };
  104. +
  105. + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae
  106. + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function because of this
  107. + namespace test_template_alias_sfinae {
  108. + struct foo {};
  109. +
  110. + template<typename T>
  111. + using member = typename T::member_type;
  112. +
  113. + template<typename T>
  114. + void func(...) {}
  115. +
  116. + template<typename T>
  117. + void func(member<T>*) {}
  118. +
  119. + void test();
  120. +
  121. + void test() {
  122. + func<foo>(0);
  123. + }
  124. + }
  125. +
  126. + // Check for C++11 attribute support
  127. + void noret [[noreturn]] () { throw 0; }
  128. +]])
  129. +
  130. +AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
  131. + m4_if([$1], [], [],
  132. + [$1], [ext], [],
  133. + [$1], [noext], [],
  134. + [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
  135. + m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
  136. + [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
  137. + [$2], [optional], [ax_cxx_compile_cxx11_required=false],
  138. + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])
  139. + AC_LANG_PUSH([C++])dnl
  140. + ac_success=no
  141. + AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
  142. + ax_cv_cxx_compile_cxx11,
  143. + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
  144. + [ax_cv_cxx_compile_cxx11=yes],
  145. + [ax_cv_cxx_compile_cxx11=no])])
  146. + if test x$ax_cv_cxx_compile_cxx11 = xyes; then
  147. + ac_success=yes
  148. + fi
  149. +
  150. + m4_if([$1], [noext], [], [dnl
  151. + if test x$ac_success = xno; then
  152. + for switch in -std=gnu++11 -std=gnu++0x; do
  153. + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
  154. + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
  155. + $cachevar,
  156. + [ac_save_CXXFLAGS="$CXXFLAGS"
  157. + CXXFLAGS="$CXXFLAGS $switch"
  158. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
  159. + [eval $cachevar=yes],
  160. + [eval $cachevar=no])
  161. + CXXFLAGS="$ac_save_CXXFLAGS"])
  162. + if eval test x\$$cachevar = xyes; then
  163. + CXXFLAGS="$CXXFLAGS $switch"
  164. + ac_success=yes
  165. + break
  166. + fi
  167. + done
  168. + fi])
  169. +
  170. + m4_if([$1], [ext], [], [dnl
  171. + if test x$ac_success = xno; then
  172. + dnl HP's aCC needs +std=c++11 according to:
  173. + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf
  174. + dnl Cray's crayCC needs "-h std=c++11"
  175. + for switch in -std=c++11 -std=c++0x +std=c++11 "-h std=c++11"; do
  176. + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
  177. + AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
  178. + $cachevar,
  179. + [ac_save_CXXFLAGS="$CXXFLAGS"
  180. + CXXFLAGS="$CXXFLAGS $switch"
  181. + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
  182. + [eval $cachevar=yes],
  183. + [eval $cachevar=no])
  184. + CXXFLAGS="$ac_save_CXXFLAGS"])
  185. + if eval test x\$$cachevar = xyes; then
  186. + CXXFLAGS="$CXXFLAGS $switch"
  187. + ac_success=yes
  188. + break
  189. + fi
  190. + done
  191. + fi])
  192. + AC_LANG_POP([C++])
  193. + if test x$ax_cxx_compile_cxx11_required = xtrue; then
  194. + if test x$ac_success = xno; then
  195. + AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
  196. + fi
  197. + else
  198. + if test x$ac_success = xno; then
  199. + HAVE_CXX11=0
  200. + AC_MSG_NOTICE([No compiler with C++11 support was found])
  201. + else
  202. + HAVE_CXX11=1
  203. + AC_DEFINE(HAVE_CXX11,1,
  204. + [define if the compiler supports basic C++11 syntax])
  205. + fi
  206. +
  207. + AC_SUBST(HAVE_CXX11)
  208. + fi
  209. +])
  210. Index: plugins/actions/dialoguize/dialoguize.cc
  211. ===================================================================
  212. --- plugins/actions/dialoguize/dialoguize.cc (révision 956)
  213. +++ plugins/actions/dialoguize/dialoguize.cc (copie de travail)
  214. @@ -23,7 +23,7 @@
  215. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  216. */
  217. -#include <auto_ptr.h>
  218. +#include <memory.h>
  219. #include "extension/action.h"
  220. #include "i18n.h"
  221. #include "debug.h"
  222. Index: plugins/actions/documentmanagement/documentmanagement.cc
  223. ===================================================================
  224. --- plugins/actions/documentmanagement/documentmanagement.cc (révision 956)
  225. +++ plugins/actions/documentmanagement/documentmanagement.cc (copie de travail)
  226. @@ -178,9 +178,9 @@
  227. ui_id = ui->new_merge_id();
  228. - #define ADD_UI(name) ui->add_ui(ui_id, "/menubar/menu-file/"name, name, name);
  229. - #define ADD_OPEN_UI(name) ui->add_ui(ui_id, "/menubar/menu-file/menu-open/"name, name, name);
  230. - #define ADD_SAVE_UI(name) ui->add_ui(ui_id, "/menubar/menu-file/menu-save/"name, name, name);
  231. + #define ADD_UI(name) ui->add_ui(ui_id, Glib::ustring::compose("%1/%2","/menubar/menu-file", name), name, name);
  232. + #define ADD_OPEN_UI(name) ui->add_ui(ui_id, Glib::ustring::compose("%1/%2","/menubar/menu-file/menu-open", name), name, name);
  233. + #define ADD_SAVE_UI(name) ui->add_ui(ui_id, Glib::ustring::compose("%1/%2","/menubar/menu-file/menu-save", name), name, name);
  234. ADD_UI("new-document");
  235. ADD_OPEN_UI("open-document");
  236. Index: src/subtitleview.cc
  237. ===================================================================
  238. --- src/subtitleview.cc (révision 956)
  239. +++ src/subtitleview.cc (copie de travail)
  240. @@ -1363,7 +1363,7 @@
  241. {
  242. int num;
  243. std::istringstream ss(event->string);
  244. - bool is_num = ss >> num != 0;
  245. + bool is_num = static_cast<bool>(ss >> num) != 0;
  246. // Update only if it's different
  247. if(is_num != get_enable_search())
  248. set_enable_search(is_num);
  249. Index: src/utility.h
  250. ===================================================================
  251. --- src/utility.h (révision 956)
  252. +++ src/utility.h (copie de travail)
  253. @@ -91,7 +91,7 @@
  254. std::istringstream s(src);
  255. // return s >> dest != 0;
  256. - bool state = s >> dest != 0;
  257. + bool state = static_cast<bool>(s >> dest) != 0;
  258. if(!state)
  259. se_debug_message(SE_DEBUG_UTILITY, "string:'%s'failed.", src.c_str());