[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / CodeGen / aarch64-args.cpp
blobfe1298cc683a404e2cdcd221083f7ca637d63ad7
1 // RUN: %clang_cc1 -triple arm64-apple-ios7.0 -target-abi darwinpcs -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - -x c %s | FileCheck %s --check-prefix=CHECK-GNU-C
3 // RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GNU-CXX
5 // Empty structs are ignored for PCS purposes on Darwin and in C mode elsewhere.
6 // In C++ mode on ELF they consume a register slot though. Functions are
7 // slightly bigger than minimal to make confirmation against actual GCC
8 // behaviour easier.
10 #if __cplusplus
11 #define EXTERNC extern "C"
12 #else
13 #define EXTERNC
14 #endif
16 struct Empty {};
18 // CHECK: define{{.*}} i32 @empty_arg(i32 noundef %a)
19 // CHECK-GNU-C: define{{.*}} i32 @empty_arg(i32 noundef %a)
20 // CHECK-GNU-CXX: define{{.*}} i32 @empty_arg(i8 %e.coerce, i32 noundef %a)
21 EXTERNC int empty_arg(struct Empty e, int a) {
22 return a;
25 // CHECK: define{{.*}} void @empty_ret()
26 // CHECK-GNU-C: define{{.*}} void @empty_ret()
27 // CHECK-GNU-CXX: define{{.*}} void @empty_ret()
28 EXTERNC struct Empty empty_ret(void) {
29 struct Empty e;
30 return e;
33 // However, what counts as "empty" is a baroque mess. This is super-empty, it's
34 // ignored even in C++ mode. It also has sizeof == 0, violating C++, but that's
35 // legacy for you:
37 struct SuperEmpty {
38 int arr[0];
41 // CHECK: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
42 // CHECK-GNU-C: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
43 // CHECK-GNU-CXX: define{{.*}} i32 @super_empty_arg(i32 noundef %a)
44 EXTERNC int super_empty_arg(struct SuperEmpty e, int a) {
45 return a;
48 // This is not empty. It has 0 size but consumes a register slot for GCC.
50 struct SortOfEmpty {
51 struct SuperEmpty e;
54 // CHECK: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
55 // CHECK-GNU-C: define{{.*}} i32 @sort_of_empty_arg(i32 noundef %a)
56 // CHECK-GNU-CXX: define{{.*}} i32 @sort_of_empty_arg(i8 %e.coerce, i32 noundef %a)
57 EXTERNC int sort_of_empty_arg(struct Empty e, int a) {
58 return a;
61 // CHECK: define{{.*}} void @sort_of_empty_ret()
62 // CHECK-GNU-C: define{{.*}} void @sort_of_empty_ret()
63 // CHECK-GNU-CXX: define{{.*}} void @sort_of_empty_ret()
64 EXTERNC struct SortOfEmpty sort_of_empty_ret(void) {
65 struct SortOfEmpty e;
66 return e;