gcc-9 testcase warning fix
warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime]
This commit is contained in:
parent
b55ce0cf84
commit
75c5cb7458
2 changed files with 40 additions and 3 deletions
|
|
@ -6,12 +6,21 @@
|
|||
%ignore A::A(std::initializer_list<int>);
|
||||
%ignore B::method;
|
||||
|
||||
%typemap(in) std::initializer_list<const char *> {
|
||||
%typemap(in) std::initializer_list<const char *> %{
|
||||
$1 = {"Ab", "Fab"};
|
||||
}
|
||||
%}
|
||||
|
||||
%begin %{
|
||||
#if __GNUC__ >= 9
|
||||
/* warning: ‘new’ of initializer_list does not extend the lifetime of the underlying array [-Winit-list-lifetime] */
|
||||
/* incorrect warning for C::C(std::initializer_list<const char *>) */
|
||||
#pragma GCC diagnostic ignored "-Winit-list-lifetime"
|
||||
#endif
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
class A {
|
||||
public:
|
||||
|
|
@ -26,9 +35,16 @@ public:
|
|||
void method(std::initializer_list<int> init) {}
|
||||
};
|
||||
class C {
|
||||
std::string joined;
|
||||
public:
|
||||
C(std::initializer_list<const char *>) {}
|
||||
C(std::initializer_list<const char *> init) {
|
||||
for (auto& val : init)
|
||||
joined += val;
|
||||
}
|
||||
C() {}
|
||||
const char * get_joined_string() {
|
||||
return joined.c_str();
|
||||
}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue