[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / AST / attr-counted-by-late-parsed-struct-ptrs.c
bloba585a45eeff03d1bff6bb6b82ffd65f6ef8d6d29
1 // RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s
3 #define __counted_by(f) __attribute__((counted_by(f)))
5 struct size_known {
6 int field;
7 };
9 //==============================================================================
10 // __counted_by on struct member pointer in decl attribute position
11 //==============================================================================
13 struct on_member_pointer_complete_ty {
14 struct size_known *buf __counted_by(count);
15 int count;
17 // CHECK-LABEL: struct on_member_pointer_complete_ty definition
18 // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __counted_by(count)':'struct size_known *'
19 // CHECK-NEXT: `-FieldDecl {{.*}} referenced count 'int'
21 struct on_pointer_anon_count {
22 struct size_known *buf __counted_by(count);
23 struct {
24 int count;
28 // CHECK-LABEL: struct on_pointer_anon_count definition
29 // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __counted_by(count)':'struct size_known *'
30 // CHECK-NEXT: |-RecordDecl {{.*}} struct definition
31 // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int'
32 // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})'
33 // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int'
34 // CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})'
35 // CHECK-NEXT: `-Field {{.*}} 'count' 'int'
37 //==============================================================================
38 // __counted_by on struct member pointer in type attribute position
39 //==============================================================================
40 // TODO: Correctly parse counted_by as a type attribute. Currently it is parsed
41 // as a declaration attribute and is **not** late parsed resulting in the `count`
42 // field being unavailable.
44 // See `clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c` for test
45 // cases.