[testsuite] Fix C++11 compilation failure for gdb.cp/m-static.exp
Commit Message
On Thu, 15 Sep 2016 14:22:54 +0200, Pedro Alves wrote:
> Did you try moving the initialization to the .cc file? Like:
>
> const float gnu_obj_4::somewhere = 3.14159;
>
> Did you find a reason to not do that?
I have found that it may invalidate the testcase some way so I stayed on the
safe side. I have read now briefly the .exp file and it does have some XFAIL
around "extra CU-level DW_TAG_variable as DW_AT_declaration".
But those compiler bugs should be forgotten now so I am fine even with this
new patch below.
Jan
gdb/testsuite/ChangeLog
2016-09-15 Jan Kratochvil <jan.kratochvil@redhat.com>
* gdb.cp/m-static.cc (gnu_obj_4::somewhere): New.
* gdb.cp/m-static.h (class gnu_obj_4): Remove somewhere initializer.
Comments
On 09/15/2016 01:34 PM, Jan Kratochvil wrote:
> On Thu, 15 Sep 2016 14:22:54 +0200, Pedro Alves wrote:
>> Did you try moving the initialization to the .cc file? Like:
>>
>> const float gnu_obj_4::somewhere = 3.14159;
>>
>> Did you find a reason to not do that?
>
> I have found that it may invalidate the testcase some way so I stayed on the
> safe side. I have read now briefly the .exp file and it does have some XFAIL
> around "extra CU-level DW_TAG_variable as DW_AT_declaration".
>
> But those compiler bugs should be forgotten now so I am fine even with this
> new patch below.
>
Hmm, OK, now that I read the test, I think you were right in trying to
keep it safe, actually. The .exp file has:
# static const initialized in the class definition, PR gdb/11702.
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.
(Even better would be to rewrite the test using the
dwarf assembler, but that'd of course be much more work.)
Thanks,
Pedro Alves
On Thu, 15 Sep 2016 15:10:50 +0200, Pedro Alves wrote:
> So I now think your original patch is better. Please push
> that one instead.
d2dfe7003423d41394d2475680e55af796566b8e
Thanks,
Jan
@@ -77,6 +77,7 @@ gnu_obj_2<int> gnu_obj_3<T>::data(etruscan);
// 2002-08-16
// Test four.
#include "m-static.h"
+const float gnu_obj_4::somewhere = 3.14159;
// instantiate templates explicitly so their static members will exist
template class gnu_obj_2<int>;
@@ -6,9 +6,10 @@ class gnu_obj_4
static const int elsewhere;
static const int nowhere;
static const int everywhere = 317;
- static const float somewhere = 3.14159;
+ // see m-static.cc - otherwise:
+ // 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;
// try to ensure test4 is actually allocated
int dummy;
};
-