Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin10 | FileCheck %s
      2 
      3 struct 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.
     10 static struct : S { } obj8;
     11 
     12 void 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 
     19 inline 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 
     25 int f3() { return f2(); }
     26 
     27 struct 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 
     39 int f4() { return A().a(); }
     40 
     41 int f5() {
     42   static union {
     43     int a;
     44   };
     45 
     46   // CHECK: _ZZ2f5vE1a
     47   return a;
     48 }
     49 
     50 int f6() {
     51   static union {
     52     union {
     53       int : 1;
     54     };
     55     int b;
     56   };
     57 
     58   // CHECK: _ZZ2f6vE1b
     59   return b;
     60 }
     61 
     62 int f7() {
     63   static union {
     64     union {
     65       int b;
     66     } a;
     67   };
     68 
     69   // CHECK: _ZZ2f7vE1a
     70   return a.b;
     71 }
     72 
     73 // This used to cause an assert because the typedef-for-anonymous-tag
     74 // code was trying to claim the enum for the template.
     75 enum { T8 };
     76 template <class T> struct Test8 {
     77   typedef T type;
     78   Test8(type t) {} // tested later
     79 };
     80 template <class T> void make_test8(T value) { Test8<T> t(value); }
     81 void test8() { make_test8(T8); }
     82 
     83 // CHECK-LABEL: define internal void @"_ZNV3$_35test9Ev"(
     84 typedef volatile struct {
     85   void test9() volatile {}
     86 } Test9;
     87 void test9() {
     88   Test9 a;
     89   a.test9();
     90 }
     91 
     92 // CHECK-LABEL: define internal void @"_ZN5Test8I3$_2EC1ES0_"(
     93