| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) | ||
|
|
||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __counted_by_or_null on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| struct on_member_pointer_complete_ty { | ||
| struct size_known *buf __counted_by_or_null(count); | ||
| int count; | ||
| }; | ||
| // CHECK-LABEL: struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: `-FieldDecl {{.*}} referenced count 'int' | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct size_known *buf __counted_by_or_null(count); | ||
| struct { | ||
| int count; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: struct on_pointer_anon_count definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-RecordDecl {{.*}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' | ||
| // CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-Field {{.*}} 'count' 'int' | ||
|
|
||
| //============================================================================== | ||
| // __counted_by_or_null on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse counted_by_or_null as a type attribute. Currently it is parsed | ||
| // as a declaration attribute and is **not** late parsed resulting in the `count` | ||
| // field being unavailable. | ||
| // | ||
| // See `clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c` for test | ||
| // cases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // RUN: %clang_cc1 %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __counted_by_or_null(f) __attribute__((counted_by_or_null(f))) | ||
|
|
||
| struct size_unknown; | ||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __counted_by_or_null on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty { | ||
| int count; | ||
| struct size_known * buf __counted_by_or_null(count); | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf { | ||
| int count; | ||
| struct { | ||
| struct size_known *buf __counted_by_or_null(count); | ||
| }; | ||
| }; | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *buf __counted_by_or_null(count); | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __counted_by_or_null on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse counted_by_or_null as a type attribute. Currently it is parsed | ||
| // as a declaration attribute | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty_ty_pos { | ||
| int count; | ||
| struct size_known *__counted_by_or_null(count) buf; | ||
| }; | ||
|
|
||
| // TODO: This should be forbidden but isn't due to counted_by_or_null being treated as a | ||
| // declaration attribute. The attribute ends up on the outer most pointer | ||
| // (allowed by sema) even though syntactically its supposed to be on the inner | ||
| // pointer (would not allowed by sema due to pointee being a function type). | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_fn_ptr_ty_ty_pos_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} fn_ptr 'void (** __counted_by_or_null(count))(void)':'void (**)(void)' | ||
| struct on_member_pointer_fn_ptr_ty_ty_pos_inner { | ||
| int count; | ||
| void (* __counted_by_or_null(count) * fn_ptr)(void); | ||
| }; | ||
|
|
||
| // FIXME: The generated AST here is wrong. The attribute should be on the inner | ||
| // pointer. | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __counted_by_or_null(count)':'struct size_known **' | ||
| struct on_nested_pointer_inner { | ||
| int count; | ||
| // TODO: This should be disallowed because in the `-fbounds-safety` model | ||
| // `__counted_by_or_null` can only be nested when used in function parameters. | ||
| struct size_known *__counted_by_or_null(count) *buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_outer definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __counted_by_or_null(count)':'struct size_known **' | ||
| struct on_nested_pointer_outer { | ||
| int count; | ||
| struct size_known **__counted_by_or_null(count) buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __counted_by_or_null(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf_ty_pos { | ||
| int count; | ||
| struct { | ||
| struct size_known * __counted_by_or_null(count) buf; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_count_ty_pos definition | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' | ||
| // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' | ||
| // CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' | ||
| // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' | ||
| struct on_pointer_anon_count_ty_pos { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *__counted_by_or_null(count) buf; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __sized_by(f) __attribute__((sized_by(f))) | ||
|
|
||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| struct on_member_pointer_complete_ty { | ||
| struct size_known *buf __sized_by(count); | ||
| int count; | ||
| }; | ||
| // CHECK-LABEL: struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: `-FieldDecl {{.*}} referenced count 'int' | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct size_known *buf __sized_by(count); | ||
| struct { | ||
| int count; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: struct on_pointer_anon_count definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-RecordDecl {{.*}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' | ||
| // CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-Field {{.*}} 'count' 'int' | ||
|
|
||
| //============================================================================== | ||
| // __sized_by on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse sized_by as a type attribute. Currently it is parsed | ||
| // as a declaration attribute and is **not** late parsed resulting in the `count` | ||
| // field being unavailable. | ||
| // | ||
| // See `clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c` for test | ||
| // cases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // RUN: %clang_cc1 -fexperimental-late-parse-attributes %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __sized_by_or_null(f) __attribute__((sized_by_or_null(f))) | ||
|
|
||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by_or_null on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| struct on_member_pointer_complete_ty { | ||
| struct size_known *buf __sized_by_or_null(count); | ||
| int count; | ||
| }; | ||
| // CHECK-LABEL: struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: `-FieldDecl {{.*}} referenced count 'int' | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct size_known *buf __sized_by_or_null(count); | ||
| struct { | ||
| int count; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: struct on_pointer_anon_count definition | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-RecordDecl {{.*}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.*}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.*}} implicit 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.*}} implicit referenced count 'int' | ||
| // CHECK-NEXT: |-Field {{.*}} '' 'struct on_pointer_anon_count::(anonymous at {{.*}})' | ||
| // CHECK-NEXT: `-Field {{.*}} 'count' 'int' | ||
|
|
||
| //============================================================================== | ||
| // __sized_by_or_null on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse sized_by_or_null as a type attribute. Currently it is parsed | ||
| // as a declaration attribute and is **not** late parsed resulting in the `count` | ||
| // field being unavailable. | ||
| // | ||
| // See `clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs.c` for test | ||
| // cases. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // RUN: %clang_cc1 %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __sized_by_or_null(f) __attribute__((sized_by_or_null(f))) | ||
|
|
||
| struct size_unknown; | ||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by_or_null on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty { | ||
| int count; | ||
| struct size_known * buf __sized_by_or_null(count); | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf { | ||
| int count; | ||
| struct { | ||
| struct size_known *buf __sized_by_or_null(count); | ||
| }; | ||
| }; | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *buf __sized_by_or_null(count); | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by_or_null on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse sized_by_or_null as a type attribute. Currently it is parsed | ||
| // as a declaration attribute | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty_ty_pos { | ||
| int count; | ||
| struct size_known *__sized_by_or_null(count) buf; | ||
| }; | ||
|
|
||
| // TODO: This should be forbidden but isn't due to sized_by_or_null being treated as a | ||
| // declaration attribute. The attribute ends up on the outer most pointer | ||
| // (allowed by sema) even though syntactically its supposed to be on the inner | ||
| // pointer (would not allowed by sema due to pointee being a function type). | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_fn_ptr_ty_ty_pos_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} fn_ptr 'void (** __sized_by_or_null(count))(void)':'void (**)(void)' | ||
| struct on_member_pointer_fn_ptr_ty_ty_pos_inner { | ||
| int count; | ||
| void (* __sized_by_or_null(count) * fn_ptr)(void); | ||
| }; | ||
|
|
||
| // FIXME: The generated AST here is wrong. The attribute should be on the inner | ||
| // pointer. | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __sized_by_or_null(count)':'struct size_known **' | ||
| struct on_nested_pointer_inner { | ||
| int count; | ||
| // TODO: This should be disallowed because in the `-fbounds-safety` model | ||
| // `__sized_by_or_null` can only be nested when used in function parameters. | ||
| struct size_known *__sized_by_or_null(count) *buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_outer definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __sized_by_or_null(count)':'struct size_known **' | ||
| struct on_nested_pointer_outer { | ||
| int count; | ||
| struct size_known **__sized_by_or_null(count) buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by_or_null(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf_ty_pos { | ||
| int count; | ||
| struct { | ||
| struct size_known * __sized_by_or_null(count) buf; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_count_ty_pos definition | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' | ||
| // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' | ||
| // CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' | ||
| // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' | ||
| struct on_pointer_anon_count_ty_pos { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *__sized_by_or_null(count) buf; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| // RUN: %clang_cc1 %s -ast-dump | FileCheck %s | ||
|
|
||
| #define __sized_by(f) __attribute__((sized_by(f))) | ||
|
|
||
| struct size_unknown; | ||
| struct size_known { | ||
| int field; | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by on struct member pointer in decl attribute position | ||
| //============================================================================== | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty { | ||
| int count; | ||
| struct size_known * buf __sized_by(count); | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf::(anonymous at [[ANON_STRUCT_PATH]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf { | ||
| int count; | ||
| struct { | ||
| struct size_known *buf __sized_by(count); | ||
| }; | ||
| }; | ||
|
|
||
| struct on_pointer_anon_count { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *buf __sized_by(count); | ||
| }; | ||
|
|
||
| //============================================================================== | ||
| // __sized_by on struct member pointer in type attribute position | ||
| //============================================================================== | ||
| // TODO: Correctly parse sized_by as a type attribute. Currently it is parsed | ||
| // as a declaration attribute | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_complete_ty_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| struct on_member_pointer_complete_ty_ty_pos { | ||
| int count; | ||
| struct size_known *__sized_by(count) buf; | ||
| }; | ||
|
|
||
| // TODO: This should be forbidden but isn't due to sized_by being treated as a | ||
| // declaration attribute. The attribute ends up on the outer most pointer | ||
| // (allowed by sema) even though syntactically its supposed to be on the inner | ||
| // pointer (would not allowed by sema due to pointee being a function type). | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_member_pointer_fn_ptr_ty_ty_pos_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} fn_ptr 'void (** __sized_by(count))(void)':'void (**)(void)' | ||
| struct on_member_pointer_fn_ptr_ty_ty_pos_inner { | ||
| int count; | ||
| void (* __sized_by(count) * fn_ptr)(void); | ||
| }; | ||
|
|
||
| // FIXME: The generated AST here is wrong. The attribute should be on the inner | ||
| // pointer. | ||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_inner definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __sized_by(count)':'struct size_known **' | ||
| struct on_nested_pointer_inner { | ||
| int count; | ||
| // TODO: This should be disallowed because in the `-fbounds-safety` model | ||
| // `__sized_by` can only be nested when used in function parameters. | ||
| struct size_known *__sized_by(count) *buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_nested_pointer_outer definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: `-FieldDecl {{.+}} buf 'struct size_known ** __sized_by(count)':'struct size_known **' | ||
| struct on_nested_pointer_outer { | ||
| int count; | ||
| struct size_known **__sized_by(count) buf; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_buf_ty_pos definition | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} referenced count 'int' | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2:.+]])' | ||
| // CHECK-NEXT: `-IndirectFieldDecl {{.+}} implicit buf 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| // CHECK-NEXT: |-Field {{.+}} '' 'struct on_pointer_anon_buf_ty_pos::(anonymous at [[ANON_STRUCT_PATH2]])' | ||
| // CHECK-NEXT: `-Field {{.+}} 'buf' 'struct size_known * __sized_by(count)':'struct size_known *' | ||
| struct on_pointer_anon_buf_ty_pos { | ||
| int count; | ||
| struct { | ||
| struct size_known * __sized_by(count) buf; | ||
| }; | ||
| }; | ||
|
|
||
| // CHECK-LABEL: RecordDecl {{.+}} struct on_pointer_anon_count_ty_pos definition | ||
| // CHECK-NEXT: |-RecordDecl {{.+}} struct definition | ||
| // CHECK-NEXT: | `-FieldDecl {{.+}} count 'int' | ||
| // CHECK-NEXT: |-FieldDecl {{.+}} implicit 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3:.+]])' | ||
| // CHECK-NEXT: |-IndirectFieldDecl {{.+}} implicit referenced count 'int' | ||
| // CHECK-NEXT: | |-Field {{.+}} '' 'struct on_pointer_anon_count_ty_pos::(anonymous at [[ANON_STRUCT_PATH3]])' | ||
| // CHECK-NEXT: | `-Field {{.+}} 'count' 'int' | ||
| struct on_pointer_anon_count_ty_pos { | ||
| struct { | ||
| int count; | ||
| }; | ||
| struct size_known *__sized_by(count) buf; | ||
| }; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| // RUN: %clang_cc1 -verify -Wno-unused %s | ||
|
|
||
| struct A { | ||
| int y; | ||
| }; | ||
|
|
||
| struct B; // expected-note 4{{forward declaration of 'B'}} | ||
|
|
||
| void f(A *a, B *b) { | ||
| a->B::x; // expected-error {{incomplete type 'B' named in nested name specifier}} | ||
| a->A::x; // expected-error {{no member named 'x' in 'A'}} | ||
| a->A::y; | ||
| b->B::x; // expected-error {{member access into incomplete type 'B'}} | ||
| b->A::x; // expected-error {{member access into incomplete type 'B'}} | ||
| b->A::y; // expected-error {{member access into incomplete type 'B'}} | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| // REQUIRES: aarch64-registered-target | ||
| // RUN: %clang_cc1 -triple arm64-apple-ios -S -o - %s | FileCheck %s | ||
|
|
||
| // CHECK: _restartable_function: | ||
| // CHECK-NEXT: ldr x11, [x0] | ||
| // CHECK-NEXT: add x11, x11, #1 | ||
| // CHECK-NEXT: str x11, [x0] | ||
| // CHECK-NEXT: Ltmp0: | ||
| // CHECK-NEXT: b Ltmp0 | ||
| // CHECK-NEXT: LExit_restartable_function: | ||
| // CHECK-NEXT: ret | ||
| asm(".align 4\n" | ||
| " .text\n" | ||
| " .private_extern _restartable_function\n" | ||
| "_restartable_function:\n" | ||
| " ldr x11, [x0]\n" | ||
| " add x11, x11, #1\n" | ||
| " str x11, [x0]\n" | ||
| "1:\n" | ||
| " b 1b\n" | ||
| "LExit_restartable_function:\n" | ||
| " ret\n" | ||
| ); |