brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.0 KiB · 59b866d Raw
46 lines · c
1// RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s2 3#define __counted_by_or_null(f)  __attribute__((counted_by_or_null(f)))4 5struct size_known {6  int field;7};8 9//==============================================================================10// __counted_by_or_null on struct member pointer in decl attribute position11//==============================================================================12 13struct on_member_pointer_complete_ty {14  struct size_known *buf __counted_by_or_null(count);15  int count;16};17// CHECK-LABEL: struct on_member_pointer_complete_ty definition18// CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'19// CHECK-NEXT: `-FieldDecl {{.*}} referenced count 'int'20 21struct on_pointer_anon_count {22  struct size_known *buf __counted_by_or_null(count);23  struct {24    int count;25  };26};27 28// CHECK-LABEL: struct on_pointer_anon_count definition29// CHECK-NEXT:  |-FieldDecl {{.*}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *'30// CHECK-NEXT:  |-RecordDecl {{.*}} struct definition31// 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 {{.*}} field_index 1 'struct on_pointer_anon_count::(anonymous at {{.*}})'35// CHECK-NEXT:    `-Field {{.*}} 'count' 'int'36 37//==============================================================================38// __counted_by_or_null on struct member pointer in type attribute position39//==============================================================================40// TODO: Correctly parse counted_by_or_null as a type attribute. Currently it is parsed41// as a declaration attribute and is **not** late parsed resulting in the `count`42// field being unavailable.43//44// See `clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c` for test45// cases.46