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