xref: /llvm-project/clang/test/CXX/drs/cwg439.cpp (revision ed128c7df9b4e60bfd814dc9fd22de1dde4a2c1c)
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
8 
9 namespace cwg439 { // cwg439: 2.7
10 
f()11 void f() {
12   int* p1 = new int;
13   const int* p2 = static_cast<const int*>(static_cast<void *>(p1));
14   bool b = p1 == p2; // b will have the value true.
15 }
16 
17 } // namespace cwg439
18 
19 // We're checking that p2 was copied from p1, and then was carried over
20 // to the comparison without change.
21 
22 // CHECK-LABEL: define {{.*}} void @cwg439::f()()
23 // CHECK:         [[P1:%.+]] = alloca ptr, align 8
24 // CHECK-NEXT:    [[P2:%.+]] = alloca ptr, align 8
25 // CHECK:         [[TEMP0:%.+]] = load ptr, ptr [[P1]]
26 // CHECK-NEXT:    store ptr [[TEMP0:%.+]], ptr [[P2]]
27 // CHECK-NEXT:    [[TEMP1:%.+]] = load ptr, ptr [[P1]]
28 // CHECK-NEXT:    [[TEMP2:%.+]] = load ptr, ptr [[P2]]
29 // CHECK-NEXT:    {{.*}} = icmp eq ptr [[TEMP1]], [[TEMP2]]
30 // CHECK-LABEL: }
31