Debian Codegraph @

clang/test/CodeGen/pointer-overflow.c

raw
1 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - | FileCheck %s --check-prefix=DEFAULT
2 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv | FileCheck %s --check-prefix=DEFAULT
3 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -ftrapv | FileCheck %s --check-prefix=DEFAULT
4 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -emit-llvm -o - -fwrapv-pointer | FileCheck %s --check-prefix=FWRAPV-POINTER
5
6 void test(void) {
7 // -fwrapv-pointer should turn off inbounds for GEP's
8 extern int* P;
9 ++P;
10 // DEFAULT: getelementptr inbounds nuw i32, ptr
11 // FWRAPV-POINTER: getelementptr i32, ptr
12 }
13
14 struct S {
15 int a;
16 int b;
17 int c: 10;
18 int d: 10;
19 };
20
21 int test_struct(struct S* s) {
22 // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
23 return s->b;
24 // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
25 // FWRAPV-POINTER: getelementptr %struct.S, ptr
26 }
27
28 int test_struct_bitfield(struct S* s) {
29 // -fwrapv-pointer should turn off inbounds nuw for struct GEP's
30 return s->d;
31 // DEFAULT: getelementptr inbounds nuw %struct.S, ptr
32 // FWRAPV-POINTER: getelementptr %struct.S, ptr
33 }