xref: /llvm-project/clang/test/SemaCXX/eval-crashes.cpp (revision 060137038ab9246b377e190ae3c6f272fa57cbfc)
1 // RUN: %clang_cc1 -std=c++1z -verify %s
2 
3 namespace pr32864_0 {
4   struct transfer_t {
5     void *fctx;
6   };
7   template <typename Ctx> class record {
8     void run() {
9       transfer_t t;
10       Ctx from{t.fctx};
11     }
12   };
13 }
14 
15 namespace pr33140_0a {
16   struct S {
17     constexpr S(const int &a = 0) {}
18   };
19   void foo(void) { S s[2] = {}; }
20 }
21 
22 namespace pr33140_0b {
23   bool bar(float const &f = 0);
24   bool foo() { return bar() && bar(); }
25 }
26 
27 namespace pr33140_2 {
28   struct A { int &&r = 0; };
29   struct B { A x, y; };
30   B b = {};
31 }
32 
33 namespace pr33140_3 {
34   typedef struct Y { unsigned int c; } Y_t;
35   struct X {
36     Y_t a;
37   };
38   struct X foo[2] = {[0 ... 1] = {.a = (Y_t){.c = 0}}}; // expected-warning {{C99 extension}}
39 }
40 
41 namespace pr33140_6 {
42   struct Y { unsigned int c; };
43   struct X { struct Y *p; };
44   int f() {
45     // FIXME: This causes clang to crash.
46     //return (struct X[2]){ [0 ... 1] = { .p = &(struct Y&)(struct Y&&)(struct Y){0} } }[0].p->c;
47     return 0;
48   }
49 }
50 
51 namespace pr33140_10 {
52   int a(const int &n = 0);
53   bool b() { return a() == a(); }
54 }
55 
56 namespace GH67317 {
57 struct array {
58   int (&data)[2];
59   array() : data(*new int[1][2]) {}
60 };
61 }
62 
63 namespace GH96670 {
64 inline constexpr long ullNil = -1;
65 
66 template<typename T = long, const T &Nil = ullNil>
67 struct Test {};
68 
69 inline constexpr long lNil = -1;
70 Test<long, lNil> c;
71 }
72