brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · f7d033b Raw
63 lines · cpp
1// RUN: %clang_cc1 -fblocks -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump | FileCheck %s2// RUN: %clang_cc1 -fblocks -Wno-unused-value -std=c++20 -ast-dump -verify %s -ast-dump -fexperimental-new-constant-interpreter | FileCheck %s3 4// expected-no-diagnostics5 6struct P {7  consteval P() {}8};9 10struct A {11  A(int v) { this->data = new int(v); }12  const int& get() const {13    return *this->data;14  }15  ~A() { delete data; }16private:17  int *data;18};19 20void foo() {21  for (;A(1), P(), false;);22  // CHECK: foo23  // CHECK: ExprWithCleanups24  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','25  // CHECK-NEXT: BinaryOperator {{.*}} 'P' ','26  // CHECK-NEXT: CXXFunctionalCastExpr {{.*}} 'A'27  // CHECK-NEXT: CXXBindTemporaryExpr {{.*}} 'A'28  // CHECK-NEXT: CXXConstructExpr {{.*}} 'A'29  // CHECK: ConstantExpr {{.*}} 'P'30  // CHECK-NEXT: value:31  // CHECK-NEXT: ExprWithCleanups32}33 34void foobar() {35  A a(1);36  for (; ^{ auto ptr = &a.get(); }(), P(), false;);37  // CHECK: ExprWithCleanups38  // CHECK-NEXT: cleanup Block39  // CHECK-NEXT: BinaryOperator {{.*}} 'bool' ','40  // CHECK-NEXT: BinaryOperator {{.*}} 'P' ','41  // CHECK-NEXT: CallExpr42  // CHECK-NEXT: BlockExpr43  // CHECK: ConstantExpr {{.*}} 'P'44  // CHECK-NEXT: value:45  // CHECK-NEXT: ExprWithCleanups46  // CHECK-NOT:  cleanup Block47}48 49struct B {50  int *p = new int(38);51  consteval int get() { return *p; }52  constexpr ~B() { delete p; }53};54 55void bar() {56  // CHECK: bar57  // CHECK: ExprWithCleanups58  // CHECK: ConstantExpr59  // CHECK-NEXT: value:60  // CHECK-NEXT: ExprWithCleanups61  int k = B().get();62}63