xref: /llvm-project/clang/test/Sema/bpf-attr-preserve-static-offset.c (revision 7c1d9b15eee3a34678addab2bab66f3020ac0753)
1 // RUN: %clang_cc1 -ast-dump -triple bpf-pc-linux-gnu %s | FileCheck %s
2 
3 // The 'preserve_static_offset' attribute should be propagated to
4 // inline declarations (foo's 'b', 'bb', 'c' but not 'd').
5 //
6 // CHECK:      RecordDecl {{.*}} struct foo definition
7 // CHECK-NEXT:   BPFPreserveStaticOffsetAttr
8 // CHECK-NEXT:   FieldDecl {{.*}} a
9 // CHECK-NEXT:   RecordDecl {{.*}} struct definition
10 // CHECK-NEXT:     FieldDecl {{.*}} aa
11 // CHECK-NEXT:   FieldDecl {{.*}} b
12 // CHECK-NEXT: RecordDecl {{.*}} union bar definition
13 // CHECK-NEXT:   BPFPreserveStaticOffsetAttr
14 // CHECK-NEXT:   FieldDecl {{.*}} a
15 // CHECK-NEXT:   FieldDecl {{.*}} b
16 
17 struct foo {
18   int a;
19   struct {
20     int aa;
21   } b;
22 } __attribute__((preserve_static_offset));
23 
24 union bar {
25   int a;
26   long b;
27 } __attribute__((preserve_static_offset));
28