This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] testsuite: Fix C++11 compilation failure for gdb.cp/m-static.exp


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=d2dfe7003423d41394d2475680e55af796566b8e

commit d2dfe7003423d41394d2475680e55af796566b8e
Author: Jan Kratochvil <jan.kratochvil@redhat.com>
Date:   Thu Sep 15 23:45:11 2016 +0200

    testsuite: Fix C++11 compilation failure for gdb.cp/m-static.exp
    
    gcc-6.2.1-1.fc26.x86_64
    
    g++ -std=c++03:
    no warnings
    
    g++:
    In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:0:
    /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]
       static const float somewhere = 3.14159;
                                      ^~~~~~~
    
    clang++:
    In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
    /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]
      static const float somewhere = 3.14159;
                         ^           ~~~~~~~
    1 warning generated.
    
    clang++ -std=c++11:
    In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
    /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]
      static const float somewhere = 3.14159;
                         ^           ~~~~~~~
    /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.h:9:3: note: add 'constexpr'
      static const float somewhere = 3.14159;
      ^
      constexpr
    1 error generated.
    
    OK for check-in?
    
    After the fix out of the 4 combinations above only this one remains non-empty:
    
    clang++:
    In file included from /home/jkratoch/redhat/gdb-clean/gdb/testsuite/gdb.cp/m-static.cc:79:
    /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]
      static const float somewhere = 3.14159;
                         ^           ~~~~~~~
    1 warning generated.
    
    On Thu, 15 Sep 2016 15:10:50 +0200, Pedro Alves wrote:
    
    Hmm, OK, now that I read the test, I think you were right in trying to
    keep it safe, actually.  The .exp file has:
    
    if { $non_dwarf } { setup_xfail *-*-* }
    gdb_test "print test4.everywhere" "\\$\[0-9\].* = 317" "static const int initialized in class definition"
    if { $non_dwarf } { setup_xfail *-*-* }
    gdb_test "print test4.somewhere" "\\$\[0-9\].* = 3.14\[0-9\]*" "static const float initialized in class definition"
                                                                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    
    Added by this:
    
     https://sourceware.org/bugzilla/show_bug.cgi?id=11702
     https://sourceware.org/ml/gdb-patches/2010-06/msg00677.html
     https://sourceware.org/ml/gdb-patches/2010-06/txt00011.txt
    
    So the new patch would make that highlighted tested above not
    test what its test message says it is testing.
    
    So I now think your original patch is better.  Please push
    that one instead.
    
    gdb/testsuite/ChangeLog
    2016-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
    
    	* gdb.cp/m-static.h (gnu_obj_4::somewhere): Use constexpr for C++11.

Diff:
---
 gdb/testsuite/ChangeLog         | 4 ++++
 gdb/testsuite/gdb.cp/m-static.h | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog
index 8e02eeb..15db4ea 100644
--- a/gdb/testsuite/ChangeLog
+++ b/gdb/testsuite/ChangeLog
@@ -1,3 +1,7 @@
+2016-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	* gdb.cp/m-static.h (gnu_obj_4::somewhere): Use constexpr for C++11.
+
 2016-09-15  Peter Bergner  <bergner@vnet.ibm.com>
 
 	* gdb.arch/powerpc-power.s: Update Power9 instruction tests
diff --git a/gdb/testsuite/gdb.cp/m-static.h b/gdb/testsuite/gdb.cp/m-static.h
index bcedfff..2992463 100644
--- a/gdb/testsuite/gdb.cp/m-static.h
+++ b/gdb/testsuite/gdb.cp/m-static.h
@@ -6,6 +6,9 @@ class gnu_obj_4
   static const int elsewhere;
   static const int nowhere;
   static const int everywhere = 317;
+#if __cplusplus >= 201103L
+  constexpr
+#endif
   static const float somewhere = 3.14159;
 
   // try to ensure test4 is actually allocated


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]