brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 1e35101 Raw
64 lines · c
1// RUN: %clang_cc1 %s -std=c2x -emit-llvm -o - | FileCheck %s2 3// Test that null <-> nullptr_t conversions work as expected.4typedef typeof(nullptr) nullptr_t;5 6nullptr_t nullptr_t_val;7 8void bool_func(bool);9void nullptr_func(nullptr_t);10 11void test() {12  // Test initialization13  bool bool_from_nullptr_t = nullptr_t_val;14  nullptr_t nullptr_t_from_nullptr = nullptr;15  void *vp_from_nullptr_t = nullptr_t_val;16  nullptr_t nullptr_t_from_vp = (void *)0;17  nullptr_t nullptr_t_from_int = 0;18 19  // Test assignment20  bool_from_nullptr_t = nullptr_t_val;21  nullptr_t_from_nullptr = nullptr;22  vp_from_nullptr_t = nullptr_t_val;23  nullptr_t_from_vp = (void *)0;24  nullptr_t_from_int = 0;25 26  // Test calls27  bool_func(nullptr_t_from_nullptr);28  nullptr_func(nullptr_t_from_nullptr);29  nullptr_func(0);30  nullptr_func((void *)0);31  nullptr_func(nullptr);32  nullptr_func(false);33 34  // Allocation of locals35  // CHECK: %[[bool_from_nullptr_t:.*]] = alloca i836  // CHECK: %[[nullptr_t_from_nullptr:.*]] = alloca ptr37  // CHECK: %[[vp_from_nullptr_t:.*]] = alloca ptr38  // CHECK: %[[nullptr_t_from_vp:.*]] = alloca ptr39  // CHECK: %[[nullptr_t_from_int:.*]] = alloca ptr40 41  // Initialization of locals42  // CHECK: store i8 0, ptr %[[bool_from_nullptr_t]]43  // CHECK: store ptr null, ptr %[[nullptr_t_from_nullptr]]44  // CHECK: store ptr null, ptr %[[vp_from_nullptr_t]]45  // CHECK: store ptr null, ptr %[[nullptr_t_from_vp]]46  // CHECK: store ptr null, ptr %[[nullptr_t_from_int]]47 48  // Assignment expressions49  // CHECK: store i8 0, ptr %[[bool_from_nullptr_t]]50  // CHECK: store ptr null, ptr %[[nullptr_t_from_nullptr]]51  // CHECK: store ptr null, ptr %[[vp_from_nullptr_t]]52  // CHECK: store ptr null, ptr %[[nullptr_t_from_vp]]53  // CHECK: store ptr null, ptr %[[nullptr_t_from_int]]54 55  // Calls56  // CHECK: call void @bool_func(i1 noundef {{(zeroext )?}}false)57  // CHECK: call void @nullptr_func(ptr null)58  // CHECK: call void @nullptr_func(ptr null)59  // CHECK: call void @nullptr_func(ptr null)60  // CHECK: call void @nullptr_func(ptr null)61  // CHECK: call void @nullptr_func(ptr null)62}63 64