[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / CXX / drs / cwg658.cpp
blob2f7f1ad7deda566e982df0472f0db680e6adfd9e
1 // RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
2 // RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
3 // RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
4 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
5 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
6 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
7 // RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
9 namespace cwg658 { // cwg658: 2.7
11 void f(int* p1) {
12 char* p2 = reinterpret_cast<char*>(p1);
15 } // namespace cwg658
17 // We're checking that p1 is stored into p2 without changes.
19 // CHECK-LABEL: define {{.*}} void @cwg658::f(int*)(ptr noundef %p1)
20 // CHECK: [[P1_ADDR:%.+]] = alloca ptr, align 8
21 // CHECK-NEXT: [[P2:%.+]] = alloca ptr, align 8
22 // CHECK: store ptr %p1, ptr [[P1_ADDR]]
23 // CHECK-NEXT: [[TEMP:%.+]] = load ptr, ptr [[P1_ADDR]]
24 // CHECK-NEXT: store ptr [[TEMP]], ptr [[P2]]
25 // CHECK-LABEL: }