brintos

brintos / llvm-project-archived public Read only

0
0
Text · 5.9 KiB · 598a28b Raw
211 lines · cpp
1// RUN: %clang_cc1 -triple i686-mingw32 %std_cxx11-14 -ast-dump %s | FileCheck %s2// RUN: %clang_cc1 -triple i686-mingw32 %std_cxx17- -ast-dump %s | FileCheck %s -check-prefix=CHECK-1Z3 4template<class T>5class P {6 public:7  P(T* t) {}8};9 10namespace foo {11class A { public: A(int = 0) {} };12enum B {};13typedef int C;14}15 16// CHECK: VarDecl {{0x[0-9a-fA-F]+}} <line:[[@LINE+1]]:1, col:36> col:15 ImplicitConstrArray 'foo::A[2]'17static foo::A ImplicitConstrArray[2];18 19int main() {20  // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::A *'21  P<foo::A> p14 = new foo::A;22  // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::B *'23  P<foo::B> p24 = new foo::B;24  // CHECK: CXXNewExpr {{0x[0-9a-fA-F]+}} <col:19, col:28> 'foo::C *'25  P<foo::C> pr4 = new foo::C;26}27 28foo::A getName() {29  // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:10, col:17> 'foo::A'30  return foo::A();31}32 33void destruct(foo::A *a1, foo::A *a2, P<int> *p1) {34  // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:8> '<bound member function type>' ->~A35  a1->~A();36  // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:16> '<bound member function type>' ->~A37  a2->foo::A::~A();38  // CHECK: MemberExpr {{0x[0-9a-fA-F]+}} <col:3, col:13> '<bound member function type>' ->~P39  p1->~P<int>();40}41 42struct D {43  D(int);44  ~D();45};46 47void construct() {48  using namespace foo;49  A a = A(12);50  // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'A' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'51  D d = D(12);52  // CHECK: CXXConstructExpr {{0x[0-9a-fA-F]+}} <col:9, col:13> 'D' 'void (int){{( __attribute__\(\(thiscall\)\))?}}'53}54 55namespace PR38987 {56struct A { A(); };57template <class T> void f() { T{}; }58template void f<A>();59// CHECK: CXXTemporaryObjectExpr {{.*}} <col:31, col:33> 'PR38987::A'60}61 62void abort() __attribute__((noreturn));63 64namespace std {65typedef decltype(sizeof(int)) size_t;66 67template <typename E> struct initializer_list {68  const E *p;69  size_t n;70  initializer_list(const E *p, size_t n) : p(p), n(n) {}71};72 73template <typename F, typename S> struct pair {74  F f;75  S s;76  pair(const F &f, const S &s) : f(f), s(s) {}77};78 79struct string {80  const char *str;81  string() { abort(); }82  string(const char *S) : str(S) {}83  ~string() { abort(); }84};85 86template<typename K, typename V>87struct map {88  using T = pair<K, V>;89  map(initializer_list<T> i, const string &s = string()) {}90  ~map() { abort(); }91};92 93}; // namespace std94 95// CHECK: NamespaceDecl {{.*}} attributed_decl96namespace attributed_decl {97  void f() {98    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:28>99    [[maybe_unused]] int i1;100    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>101    __attribute__((unused)) int i2;102    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:35>103    int __attribute__((unused)) i3;104    // CHECK: DeclStmt {{.*}} <<built-in>:{{.*}}, {{.*}}:[[@LINE+1]]:40>105    __declspec(dllexport) extern int i4;106    // CHECK: DeclStmt {{.*}} <line:[[@LINE+1]]:5, col:40>107    extern int __declspec(dllexport) i5;108  }109}110 111// CHECK-1Z: NamespaceDecl {{.*}} attributed_case112namespace attributed_case {113void f(int n) {114  switch (n) {115  case 0:116    n--;117    // CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+4]]:35>118    // CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:20>119    __attribute__((fallthrough))120    // CHECK: FallThroughAttr {{.*}} <line:[[@LINE+1]]:22>121      __attribute__((fallthrough));122  case 1:123    n++;124    break;125  }126}127} // namespace attributed_case128 129// CHECK: NamespaceDecl {{.*}} attributed_stmt130namespace attributed_stmt {131  // In DO_PRAGMA and _Pragma cases, `LoopHintAttr` comes from <scratch space>132  // file.133 134  #define DO_PRAGMA(x) _Pragma (#x)135 136  void f() {137    // CHECK: AttributedStmt {{.*}} <line:[[@LINE-3]]:24, line:[[@LINE+2]]:33>138    DO_PRAGMA (unroll(2))139    for (int i = 0; i < 10; ++i);140 141    // CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+3]]:33>142    // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:13, col:22>143    #pragma unroll(2)144    for (int i = 0; i < 10; ++i);145 146    // CHECK: AttributedStmt {{.*}} <line:[[@LINE+2]]:5, line:[[@LINE+5]]:33>147    // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:41>148    #pragma clang loop vectorize(enable)149    // CHECK: LoopHintAttr {{.*}} <line:[[@LINE+1]]:19, col:42>150    #pragma clang loop interleave(enable)151    for (int i = 0; i < 10; ++i);152 153    // CHECK: AttributedStmt {{.*}} <line:[[@LINE+1]]:5, line:[[@LINE+2]]:33>154    _Pragma("unroll(2)")155    for (int i = 0; i < 10; ++i);156  }157}158 159#if __cplusplus >= 201703L160// CHECK-1Z: FunctionDecl {{.*}} construct_with_init_list161std::map<int, int> construct_with_init_list() {162  // CHECK-1Z-NEXT: CompoundStmt163  // CHECK-1Z-NEXT: ReturnStmt {{.*}} <line:[[@LINE+5]]:3, col:35164  // CHECK-1Z-NEXT: ExprWithCleanups {{.*}} <col:10, col:35165  // CHECK-1Z-NEXT: CXXBindTemporaryExpr {{.*}} <col:10, col:35166  // CHECK-1Z-NEXT: CXXTemporaryObjectExpr {{.*}} <col:10, col:35167  // CHECK-1Z-NEXT: CXXStdInitializerListExpr {{.*}} <col:28, col:35168  return std::map<int, int>{{0, 0}};169}170 171// CHECK-1Z: NamespaceDecl {{.*}} in_class_init172namespace in_class_init {173  struct A {};174 175  // CHECK-1Z: CXXRecordDecl {{.*}} struct B definition176  struct B {177    // CHECK-1Z: FieldDecl {{.*}} a 'A'178    // CHECK-1Z-NEXT: InitListExpr {{.*}} <col:11, col:12179    A a = {};180  };181}182 183// CHECK-1Z: NamespaceDecl {{.*}} delegating_constructor_init184namespace delegating_constructor_init {185  struct A {};186 187  struct B : A {188    A a;189    B(A a) : a(a) {}190  };191 192  // CHECK-1Z: CXXRecordDecl {{.*}} struct C definition193  struct C : B {194    // CHECK-1Z: CXXConstructorDecl {{.*}} C195    // CHECK-1Z-NEXT: CXXCtorInitializer 'B'196    // CHECK-1Z-NEXT: CXXConstructExpr {{.*}} <col:11, col:15197    // CHECK-1Z-NEXT: InitListExpr {{.*}} <col:13, col:14198    C() : B({}) {};199  };200}201 202// CHECK-1Z: NamespaceDecl {{.*}} new_init203namespace new_init {204  void A() {205    // CHECK-1Z: CXXNewExpr {{.*}} <line:[[@LINE+2]]:5, col:14206    // CHECK-1Z-NEXT: InitListExpr {{.*}} <col:12, col:14207    new int{0};208  }209}210#endif211