Daily bump.
[gcc.git] / gcc / testsuite / g++.dg / torture / pr116783.C
blob6d59159459d2009e4dd968709e40a63e0c136895
1 // { dg-do run }
2 // { dg-additional-options "-fstack-protector-strong -fno-late-combine-instructions" }
3 // { dg-require-effective-target fstack_protector }
4 // { dg-require-effective-target c++11 }
6 struct Private {
7   char data[24]{};
8   long moved_from : 4;
9   Private() : moved_from (0) {}
12 struct QVariant {
13   __attribute__((noipa))
14   ~QVariant() {
15     if (!d.moved_from && d.data[0] != 42)
16       __builtin_abort ();
17   }
18   __attribute__((noipa))
19   QVariant() {
20     d.data[0] = 42;
21   }
22   __attribute__((noipa))
23   QVariant(QVariant &other) : d(other.d) {}
24   QVariant(QVariant &&other) : d(other.d) {
25     other.d = Private();
26     other.d.moved_from = true;
27   }
28   QVariant &operator=(QVariant);
29   Private d;
32 QVariant id (QVariant v) { return v; }
33 QVariant &QVariant::operator=(QVariant other)
35   id(other);
36   return *this;
39 template <typename T> struct QList {
40   T d;
41   struct const_iterator {
42     T *ptr;
43     T &operator*() { return *ptr; }
44     __attribute__((noipa))
45     bool operator!=(const_iterator other) { return ptr != other.ptr; }
46     void operator++() { ptr++; }
47   };
48   __attribute__((noipa))
49   T at() { return d; }
50   const_iterator begin() { return const_iterator { &d }; }
51   const_iterator end() { return const_iterator { &d }; }
53 struct QArrayDataPointer {
54   int d;
55   int *ptr;
56   long size;
59 QArrayDataPointer null_qadp;
61 struct QString {
62   __attribute__((noipa))
63   QList<QString> split() const {
64     return QList<QString> {null_qadp};
65   }
66   __attribute__((noipa))
67   friend bool operator==(QString, QString) { return true; }
69   __attribute__((noipa))
70   QString(QArrayDataPointer dp) : d(dp) {}
71   QArrayDataPointer d;
74 __attribute__((noipa))
75 QString as_qstr (QVariant *v)
77   return QString (null_qadp);
80 int *getNode(const QString &tagContent) {
81   auto expr = tagContent.split();
82   auto blockName = expr.at();
83   auto loadedBlocksVariant = QVariant ();
84   QList<QVariant> blockVariantList;
85   for (auto &item : blockVariantList) {
86     auto blockNodeName = as_qstr (&item);
87     blockNodeName == blockName;
88     QString q(null_qadp);
89   }
90   loadedBlocksVariant = QVariant();
91   return nullptr;
94 int main(void)
96   QString foo(null_qadp);
97   getNode(foo);