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