blob: 53f381c3a011de626c227707c4bb7df42d744ed0 [file] [log] [blame]
Anders Carlsson6f7e2f42010-06-08 14:49:03 +00001// RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
Eli Friedman6f9f25d2009-12-11 20:21:38 +00002
3struct S {
4 virtual ~S() { }
5};
6
7// PR5706
8// Make sure this doesn't crash; the mangling doesn't matter because the name
9// doesn't have linkage.
10static struct : S { } obj8;
11
12void f() {
13 // Make sure this doesn't crash; the mangling doesn't matter because the
14 // generated vtable/etc. aren't modifiable (although it would be nice for
15 // codesize to make it consistent inside inline functions).
16 static struct : S { } obj8;
17}
18
19inline int f2() {
20 // FIXME: We don't mangle the names of a or x correctly!
21 static struct { int a() { static int x; return ++x; } } obj;
22 return obj.a();
23}
24
25int f3() { return f2(); }
26
27struct A {
28 typedef struct { int x; } *ptr;
29 ptr m;
30 int a() {
31 static struct x {
32 // FIXME: We don't mangle the names of a or x correctly!
33 int a(ptr A::*memp) { static int x; return ++x; }
34 } a;
35 return a.a(&A::m);
36 }
37};
38
39int f4() { return A().a(); }
Anders Carlsson6f7e2f42010-06-08 14:49:03 +000040
41int f5() {
42 static union {
43 int a;
44 };
45
46 // CHECK: _ZZ2f5vE1a
47 return a;
48}
49
50int f6() {
51 static union {
52 union {
53 int : 1;
54 };
55 int b;
56 };
57
58 // CHECK: _ZZ2f6vE1b
59 return b;
60}
61
62int f7() {
63 static union {
64 union {
65 int b;
66 } a;
67 };
68
69 // CHECK: _ZZ2f7vE1a
70 return a.b;
71}
John McCallcde5a402011-02-01 08:20:08 +000072
73// This used to cause an assert because the typedef-for-anonymous-tag
74// code was trying to claim the enum for the template.
75enum { T8 };
76template <class T> struct Test8 {
77 typedef T type;
John McCall38ca4f72011-02-01 08:30:38 +000078 Test8(type t) {} // tested later
John McCallcde5a402011-02-01 08:20:08 +000079};
80template <class T> void make_test8(T value) { Test8<T> t(value); }
81void test8() { make_test8(T8); }
John McCall38ca4f72011-02-01 08:30:38 +000082
83// CHECK: define internal void @"_ZNV3$_35test9Ev"(
84typedef volatile struct {
85 void test9() volatile {}
86} Test9;
87void test9() {
88 Test9 a;
89 a.test9();
90}
91
92// CHECK: define internal void @"_ZN5Test8I3$_2EC1ES0_"(