2018-11-07 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / g++.dg / torture / pr34850.C
blobe41620b739d75dd4b3bc4d28f0cfd0d9265344ae
1 /* { dg-do compile } */
2 /* { dg-skip-if "" { *-*-* } { "-O0" } { "" } } */
3 /* { dg-options "-ffat-lto-objects" } */
4 /* { dg-additional-options "-Wno-return-type" } */
6 typedef unsigned char uint8_t;
7 typedef unsigned int uint32_t;
8 typedef uint8_t byte;
9 typedef uint32_t u32bit;
10 __extension__ typedef __SIZE_TYPE__ size_t;
11 extern "C" {
12     extern void __warn_memset_zero_len (void) __attribute__((__warning__ ("")));
13     extern __inline __attribute__ ((__always_inline__)) __attribute__ ((__gnu_inline__, __artificial__))
14     void * memset (void *__dest, int __ch, size_t __len) throw () {
15         if (__builtin_constant_p (__len) && __len == 0)
16             __warn_memset_zero_len ();
17     }
19 inline void clear_mem(void* ptr, u32bit n)    {
20     memset(ptr, 0, n);
22 template<typename T> class MemoryRegion    {
23 public:
24     u32bit size() const {
25     }
26     const T* begin() const {
27     }
28     void set(const T in[], u32bit n) {
29         create(n);
30     }
31     void set(const MemoryRegion<T>& in) {
32         set(in.begin(), in.size());
33     }
34     void clear() {
35         clear_mem(buf, allocated);
36     }
37     void create(u32bit);
38     MemoryRegion() {
39         used = allocated = 0;
40     }
41     mutable T* buf;
42     mutable u32bit used;
43     mutable u32bit allocated;
45 template<typename T> void MemoryRegion<T>::create(u32bit n)    {
46     if(n <= allocated) {
47         clear();
48     }
50 template<typename T> class SecureVector : public MemoryRegion<T>    {
51 public:
52     SecureVector<T>& operator=(const MemoryRegion<T>& in)          {
53         if(this != &in) this->set(in);
54     }
56 class OctetString    {
57 public:
58     SecureVector<byte> bits_of() const {
59     }
60     OctetString& operator^=(const OctetString&);
61     void change(const MemoryRegion<byte>& in) {
62         bits = in;
63     }
64     OctetString(const MemoryRegion<byte>& in) {
65         change(in);
66     }
67     SecureVector<byte> bits;
69 OctetString& OctetString::operator^=(const OctetString& k)    {
70     if(&k == this) {
71         bits.clear();
72     }
74 bool __attribute__((flatten))
75 operator==(const OctetString& s1, const OctetString& s2)    {
76     return (s1.bits_of() == s2.bits_of());