[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg1748.cpp
blobf216963d69f2a237cb5e3b6868f2743b08490a3c
1 // RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
2 // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
3 // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
4 // RUN: %clang_cc1 -std=c++1z %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | FileCheck %s
6 // cwg1748: 3.7
8 // FIXME: __SIZE_TYPE__ expands to 'long long' on some targets.
9 __extension__ typedef __SIZE_TYPE__ size_t;
11 void *operator new(size_t, void *);
12 void *operator new[](size_t, void *);
14 struct X { X(); };
16 // The reserved placement allocation functions get inlined
17 // even if we can't see their definitions. They do not
18 // perform a null check.
20 // CHECK-LABEL: define {{.*}} @_Z1fPv(
21 // CHECK-NOT: call
22 // CHECK-NOT: icmp{{.*}} null
23 // CHECK-NOT: br i1
24 // CHECK: call void @_ZN1XC1Ev(
25 // CHECK: }
26 X *f(void *p) { return new (p) X; }
28 // CHECK-LABEL: define {{.*}} @_Z1gPv(
29 // CHECK-NOT: call
30 // CHECK-NOT: icmp{{.*}} null
31 // CHECK-NOT: br i1
32 // CHECK: call void @_ZN1XC1Ev(
33 // CHECK: br i1
34 // CHECK: }
35 X *g(void *p) { return new (p) X[5]; }