Add tests for a const member and a reference member for launder.
* g++.dg/cpp1z/launder3.C: New. * g++.dg/cpp1z/launder4.C: Likewise. * g++.dg/cpp1z/launder5.C: Likewise. * g++.dg/cpp1z/launder5.cc: Likewise. * g++.dg/cpp1z/launder5.h: Likewise. * g++.dg/cpp1z/launder6.C: Likewise. * g++.dg/cpp1z/launder6.cc: Likewise. * g++.dg/cpp1z/launder6.h: Likewise. From-SVN: r241708
This commit is contained in:
parent
dcb466eca3
commit
aee69156da
|
@ -1,3 +1,15 @@
|
|||
2016-10-31 Ville Voutilainen <ville.voutilainen@gmail.com>
|
||||
|
||||
Add tests for a const member and a reference member for launder.
|
||||
* g++.dg/cpp1z/launder3.C: New.
|
||||
* g++.dg/cpp1z/launder4.C: Likewise.
|
||||
* g++.dg/cpp1z/launder5.C: Likewise.
|
||||
* g++.dg/cpp1z/launder5.cc: Likewise.
|
||||
* g++.dg/cpp1z/launder5.h: Likewise.
|
||||
* g++.dg/cpp1z/launder6.C: Likewise.
|
||||
* g++.dg/cpp1z/launder6.cc: Likewise.
|
||||
* g++.dg/cpp1z/launder6.h: Likewise.
|
||||
|
||||
2016-10-31 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
PR c++/77948
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-additional-options "-O2" }
|
||||
|
||||
#include <cassert>
|
||||
|
||||
void *
|
||||
operator new (decltype (sizeof (0)), void *p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
T *
|
||||
launder (T *p)
|
||||
{
|
||||
return __builtin_launder (p);
|
||||
}
|
||||
}
|
||||
|
||||
struct A
|
||||
{
|
||||
const int x;
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
A a;
|
||||
};
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
B b{{42}};
|
||||
new (&b.a) A{666};
|
||||
assert(std::launder(&b.a)->x == 666);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-additional-options "-O2" }
|
||||
|
||||
#include <cassert>
|
||||
|
||||
void *
|
||||
operator new (decltype (sizeof (0)), void *p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
T *
|
||||
launder (T *p)
|
||||
{
|
||||
return __builtin_launder (p);
|
||||
}
|
||||
}
|
||||
|
||||
struct A
|
||||
{
|
||||
int& x;
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
A a;
|
||||
};
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int x = 42;
|
||||
B b{{x}};
|
||||
int y = 666;
|
||||
new (&b.a) A{y};
|
||||
assert(std::launder(&b.a)->x == 666);
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-additional-options "-O2" }
|
||||
// { dg-additional-sources "launder5.cc" }
|
||||
|
||||
#include <cassert>
|
||||
#include "launder5.h"
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
T *
|
||||
launder (T *p)
|
||||
{
|
||||
return __builtin_launder (p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
B b{{42}};
|
||||
f(b);
|
||||
assert(std::launder(&b.a)->x == 666);
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
#include "launder5.h"
|
||||
|
||||
void *
|
||||
operator new (decltype (sizeof (0)), void *p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
void f(B& b)
|
||||
{
|
||||
new (&b.a) A{666};
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef GCC_TEST_LAUNDER5_H
|
||||
#define GCC_TEST_LAUNDER5_H
|
||||
|
||||
struct A
|
||||
{
|
||||
const int x;
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
A a;
|
||||
};
|
||||
|
||||
void f(B& b);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,24 @@
|
|||
// { dg-do run { target c++11 } }
|
||||
// { dg-additional-options "-O2" }
|
||||
// { dg-additional-sources "launder6.cc" }
|
||||
#include <cassert>
|
||||
#include "launder6.h"
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <typename T>
|
||||
T *
|
||||
launder (T *p)
|
||||
{
|
||||
return __builtin_launder (p);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
main ()
|
||||
{
|
||||
int x = 42;
|
||||
B b{{x}};
|
||||
f(b);
|
||||
assert(std::launder(&b.a)->x == 666);
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
#include "launder6.h"
|
||||
|
||||
void *
|
||||
operator new (decltype (sizeof (0)), void *p)
|
||||
{
|
||||
return p;
|
||||
}
|
||||
|
||||
int y = 666;
|
||||
|
||||
void f(B& b)
|
||||
{
|
||||
new (&b.a) A{y};
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
#ifndef GCC_TEST_LAUNDER6_H
|
||||
#define GCC_TEST_LAUNDER6_H
|
||||
|
||||
struct A
|
||||
{
|
||||
int& x;
|
||||
};
|
||||
|
||||
struct B
|
||||
{
|
||||
A a;
|
||||
};
|
||||
|
||||
void f(B& b);
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue