60c662d
http://sourceware.org/ml/gdb-patches/2016-09/msg00083.html
60c662d
Subject: [testsuite patch] Fix C++11 compilation failure for gdb.cp/m-static.exp
60c662d
60c662d
60c662d
--y0ulUmNC+osPPQO6
60c662d
Content-Type: text/plain; charset=iso-2022-jp
60c662d
Content-Disposition: inline
60c662d
60c662d
Hi,
60c662d
60c662d
gcc-6.2.1-1.fc26.x86_64
60c662d
60c662d
g++ -std=c++03:
60c662d
no warnings
60c662d
60c662d
g++:
60c662d
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:0:
60c662d
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:34: error: ‘constexpr’ needed for in-class initialization of static data member ‘const float gnu_obj_4::somewhere’ of non-integral type [-fpermissive]
60c662d
   static const float somewhere = 3.14159;
60c662d
                                  ^~~~~~~
60c662d
60c662d
clang++:
60c662d
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
60c662d
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init]
60c662d
  static const float somewhere = 3.14159;
60c662d
                     ^           ~~~~~~~
60c662d
1 warning generated.
60c662d
60c662d
clang++ -std=c++11:
60c662d
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
60c662d
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: error: in-class initializer for static data member of type 'const float' requires 'constexpr' specifier [-Wstatic-float-init]
60c662d
  static const float somewhere = 3.14159;
60c662d
                     ^           ~~~~~~~
60c662d
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:3: note: add 'constexpr'
60c662d
  static const float somewhere = 3.14159;
60c662d
  ^
60c662d
  constexpr
60c662d
1 error generated.
60c662d
60c662d
OK for check-in?
60c662d
60c662d
After the fix out of the 4 combinations above only this one remains non-empty:
60c662d
60c662d
clang++:
60c662d
In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
60c662d
/home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:22: warning: in-class initializer for static data member of type 'const float' is a GNU extension [-Wgnu-static-float-init]
60c662d
  static const float somewhere = 3.14159;
60c662d
                     ^           ~~~~~~~
60c662d
1 warning generated.
60c662d
60c662d
60c662d
Jan
60c662d
60c662d
--y0ulUmNC+osPPQO6
60c662d
Content-Type: text/plain; charset=us-ascii
60c662d
Content-Disposition: inline; filename=1
60c662d
60c662d
gdb/testsuite/ChangeLog
60c662d
2016-09-11  Jan Kratochvil  <jan.kratochvil@redhat.com>
60c662d
60c662d
	* gdb.cp/m-static.h (gnu_obj_4::somewhere): Use constexpr for C++11.
60c662d
60c662d
diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h
60c662d
index bcedfff..2992463 100644
60c662d
--- a/gdb/testsuite/gdb.cp/m-static.h
60c662d
+++ b/gdb/testsuite/gdb.cp/m-static.h
60c662d
@@ -6,6 +6,9 @@ class gnu_obj_4
60c662d
   static const int elsewhere;
60c662d
   static const int nowhere;
60c662d
   static const int everywhere = 317;
60c662d
+#if __cplusplus >= 201103L
60c662d
+  constexpr
60c662d
+#endif
60c662d
   static const float somewhere = 3.14159;
60c662d
 
60c662d
   // try to ensure test4 is actually allocated
60c662d
60c662d
--y0ulUmNC+osPPQO6--
60c662d