Clang Project

clang_source_code/test/CodeGenCXX/mangle-unnamed.cpp
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
4struct 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.
11static struct : S { } obj8;
12
13void 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
20inline 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
26int f3() { return f2(); }
27
28struct 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
40int f4() { return A().a(); }
41
42int f5() {
43  static union {
44    int a;
45  };
46  
47  // CHECK: _ZZ2f5vE1a
48  return a;
49}
50
51#if __cplusplus <= 199711L
52int f6() {
53  static union {
54    union {
55      int : 1;
56    };
57    int b;
58  };
59  
60  // CXX98: _ZZ2f6vE1b
61  return b;
62}
63#endif
64
65int f7() {
66  static union {
67    union {
68      int b;
69    } a;
70  };
71  
72  // CHECK: _ZZ2f7vE1a
73  return a.b;
74}
75
76// This used to cause an assert because the typedef-for-anonymous-tag
77// code was trying to claim the enum for the template.
78enum { T8 };
79template <class T> struct Test8 {
80  typedef T type;
81  Test8(type t) {} // tested later
82};
83template <class T> void make_test8(T value) { Test8<T> t(value); }
84void test8() { make_test8(T8); }
85
86// CHECK-LABEL: define internal void @"_ZNV3$_35test9Ev"(
87typedef volatile struct {
88  void test9() volatile {}
89} Test9;
90void test9() {
91  Test9 a;
92  a.test9();
93}
94
95// CHECK-LABEL: define internal void @"_ZN5Test8I3$_2EC1ES0_"(
96