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