[clang] [clang] Add some CodeGen tests for CWG 4xx issues (PR #83715)
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 4 07:04:57 PST 2024
================
@@ -0,0 +1,27 @@
+// 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
+// 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
+// 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
+// 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
+// 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
+// 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
+// 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
+
+namespace dr439 { // dr439: 2.7
+
+void f() {
+ int* p1 = new int;
+ const int* p2 = static_cast<const int*>(static_cast<void *>(p1));
+ bool b = p1 == p2; // b will have the value true.
+}
+
+} // namespace dr439
+
+// CHECK-LABEL: define {{.*}} void @dr439::f()()
+// CHECK: [[P1:%.+]] = alloca ptr, align 8
+// CHECK-NEXT: [[P2:%.+]] = alloca ptr, align 8
+// CHECK: [[TEMP0:%.+]] = load ptr, ptr [[P1]]
+// CHECK-NEXT: store ptr [[TEMP0:%.+]], ptr [[P2]]
+// CHECK-NEXT: [[TEMP1:%.+]] = load ptr, ptr [[P1]]
+// CHECK-NEXT: [[TEMP2:%.+]] = load ptr, ptr [[P2]]
+// CHECK-NEXT: {{.*}} = icmp eq ptr [[TEMP1]], [[TEMP2]]
----------------
erichkeane wrote:
So I don't think this sufficiently checks that 'b' would be true. 2 ways I can think to test this (perhaps both should be done anyway?).
1- Run this with -O3 (after changing `f` to return the result), and make sure it gets simplified to `ret i1 true`
2- Change to constexpr, and use a static-assert on it.
https://github.com/llvm/llvm-project/pull/83715
More information about the cfe-commits
mailing list