]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CodeGenCXX/std-byte.cpp
Vendor import of clang release_50 branch r309439:
[FreeBSD/FreeBSD.git] / test / CodeGenCXX / std-byte.cpp
1 // RUN: %clang_cc1 -std=c++1z -Werror -triple i386-unknown-unknown -emit-llvm -O1 -disable-llvm-passes -o - %s | FileCheck %s
2
3 // std::byte should be considered equivalent to char for aliasing.
4
5 namespace std {
6 enum byte : unsigned char {};
7 }
8
9 // CHECK-LABEL: define void @test0(
10 extern "C" void test0(std::byte *sb, int *i) {
11   // CHECK: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR:!.*]]
12   *sb = std::byte{0};
13
14   // CHECK: store i32 1, i32* %{{.*}} !tbaa [[TAG_INT:!.*]]
15   *i = 1;
16 }
17
18 enum byte : unsigned char {};
19 namespace my {
20 enum byte : unsigned char {};
21 namespace std {
22 enum byte : unsigned char {};
23 } // namespace std
24 } // namespace my
25
26 // Make sure we don't get confused with other enums named 'byte'.
27
28 // CHECK-LABEL: define void @test1(
29 extern "C" void test1(::byte *b, ::my::byte *mb, ::my::std::byte *msb) {
30   *b = ::byte{0};
31   *mb = ::my::byte{0};
32   *msb = ::my::std::byte{0};
33   // CHECK-NOT: store i8 0, i8* %{{.*}} !tbaa [[TAG_CHAR]]
34 }
35
36 // CHECK:  !"any pointer", [[TYPE_CHAR:!.*]],
37 // CHECK: [[TYPE_CHAR]] = !{!"omnipotent char", [[TAG_CXX_TBAA:!.*]],
38 // CHECK: [[TAG_CXX_TBAA]] = !{!"Simple C++ TBAA"}
39 // CHECK: [[TAG_CHAR]] = !{[[TYPE_CHAR:!.*]], [[TYPE_CHAR]], i64 0}
40 // CHECK: [[TAG_INT]] = !{[[TYPE_INT:!.*]], [[TYPE_INT]], i64 0}
41 // CHECK: [[TYPE_INT]] = !{!"int", [[TYPE_CHAR]]