xref: /minix3/external/bsd/llvm/dist/clang/test/CodeGenCXX/crash.cpp (revision f4a2713ac843a11c696ec80c0a5e3e5d80b4d338)
1*f4a2713aSLionel Sambuc // RUN: %clang_cc1 %s -std=c++11 -emit-llvm-only
2*f4a2713aSLionel Sambuc // CHECK that we don't crash.
3*f4a2713aSLionel Sambuc 
4*f4a2713aSLionel Sambuc // PR11676's example is ill-formed:
5*f4a2713aSLionel Sambuc /*
6*f4a2713aSLionel Sambuc union _XEvent {
7*f4a2713aSLionel Sambuc };
8*f4a2713aSLionel Sambuc void ProcessEvent() {
9*f4a2713aSLionel Sambuc   _XEvent pluginEvent = _XEvent();
10*f4a2713aSLionel Sambuc }
11*f4a2713aSLionel Sambuc */
12*f4a2713aSLionel Sambuc 
13*f4a2713aSLionel Sambuc // Example from PR11665:
14*f4a2713aSLionel Sambuc void f() {
15*f4a2713aSLionel Sambuc   union U { int field; } u = U();
16*f4a2713aSLionel Sambuc   (void)U().field;
17*f4a2713aSLionel Sambuc }
18*f4a2713aSLionel Sambuc 
19*f4a2713aSLionel Sambuc namespace PR17476 {
20*f4a2713aSLionel Sambuc struct string {
21*f4a2713aSLionel Sambuc   string(const char *__s);
22*f4a2713aSLionel Sambuc   string &operator+=(const string &__str);
23*f4a2713aSLionel Sambuc };
24*f4a2713aSLionel Sambuc 
25*f4a2713aSLionel Sambuc template <class ELFT> void finalizeDefaultAtomValues() {
26*f4a2713aSLionel Sambuc   auto startEnd = [&](const char * sym)->void {
27*f4a2713aSLionel Sambuc     string start("__");
28*f4a2713aSLionel Sambuc     start += sym;
29*f4a2713aSLionel Sambuc   }
30*f4a2713aSLionel Sambuc   ;
31*f4a2713aSLionel Sambuc   startEnd("preinit_array");
32*f4a2713aSLionel Sambuc }
33*f4a2713aSLionel Sambuc 
34*f4a2713aSLionel Sambuc void f() { finalizeDefaultAtomValues<int>(); }
35*f4a2713aSLionel Sambuc }
36