CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
146 lines
4.3 KiB
C
146 lines
4.3 KiB
C
// RUN: %clang_cc1 -fsyntax-only -verify=expected,immediate %s
|
|
// RUN: %clang_cc1 -fsyntax-only -fexperimental-late-parse-attributes -verify=expected,late %s
|
|
|
|
#define __sized_by_or_null(f) __attribute__((sized_by_or_null(f)))
|
|
|
|
// This has been adapted from clang/test/Sema/attr-counted-by-vla.c, but with VLAs replaced with pointers
|
|
|
|
struct bar;
|
|
|
|
struct not_found {
|
|
int size;
|
|
struct bar *ptr __sized_by_or_null(bork); // expected-error {{use of undeclared identifier 'bork'}}
|
|
};
|
|
|
|
struct no_found_size_not_in_substruct {
|
|
unsigned long flags;
|
|
unsigned char size; // expected-note {{'size' declared here}}
|
|
struct A {
|
|
int dummy;
|
|
int * ptr __sized_by_or_null(size); // expected-error {{'sized_by_or_null' field 'size' isn't within the same struct as the annotated pointer}}
|
|
} a;
|
|
};
|
|
|
|
struct not_found_size_not_in_unnamed_substruct {
|
|
unsigned char size; // expected-note {{'size' declared here}}
|
|
struct {
|
|
int dummy;
|
|
int * ptr __sized_by_or_null(size); // expected-error {{'sized_by_or_null' field 'size' isn't within the same struct as the annotated pointer}}
|
|
} a;
|
|
};
|
|
|
|
struct not_found_size_not_in_unnamed_substruct_2 {
|
|
struct {
|
|
unsigned char size; // expected-note {{'size' declared here}}
|
|
};
|
|
struct {
|
|
int dummy;
|
|
int * ptr __sized_by_or_null(size); // expected-error {{'sized_by_or_null' field 'size' isn't within the same struct as the annotated pointer}}
|
|
} a;
|
|
};
|
|
|
|
struct not_found_size_in_other_unnamed_substruct {
|
|
struct {
|
|
unsigned char size;
|
|
} a1;
|
|
|
|
struct {
|
|
int dummy;
|
|
int * ptr __sized_by_or_null(size); // expected-error {{use of undeclared identifier 'size'}}
|
|
};
|
|
};
|
|
|
|
struct not_found_size_in_other_substruct {
|
|
struct _a1 {
|
|
unsigned char size;
|
|
} a1;
|
|
|
|
struct {
|
|
int dummy;
|
|
int * ptr __sized_by_or_null(size); // expected-error {{use of undeclared identifier 'size'}}
|
|
};
|
|
};
|
|
|
|
struct not_found_size_in_other_substruct_2 {
|
|
struct _a2 {
|
|
unsigned char size;
|
|
} a2;
|
|
|
|
int * ptr __sized_by_or_null(size); // expected-error {{use of undeclared identifier 'size'}}
|
|
};
|
|
|
|
struct not_found_suggest {
|
|
int bork;
|
|
struct bar **ptr __sized_by_or_null(blork); // expected-error {{use of undeclared identifier 'blork'}}
|
|
};
|
|
|
|
int global; // expected-note {{'global' declared here}}
|
|
|
|
struct found_outside_of_struct {
|
|
int bork;
|
|
struct bar ** ptr __sized_by_or_null(global); // expected-error {{field 'global' in 'sized_by_or_null' not inside structure}}
|
|
};
|
|
|
|
struct self_referrential {
|
|
int bork;
|
|
// immediate-error@+2{{use of undeclared identifier 'self'}}
|
|
// late-error@+1{{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
|
|
struct bar *self[] __sized_by_or_null(self);
|
|
};
|
|
|
|
struct non_int_size {
|
|
double dbl_size;
|
|
struct bar ** ptr __sized_by_or_null(dbl_size); // expected-error {{'sized_by_or_null' requires a non-boolean integer type argument}}
|
|
};
|
|
|
|
struct array_of_ints_size {
|
|
int integers[2];
|
|
struct bar ** ptr __sized_by_or_null(integers); // expected-error {{'sized_by_or_null' requires a non-boolean integer type argument}}
|
|
};
|
|
|
|
struct not_a_c99_fam {
|
|
int size;
|
|
struct bar *non_c99_fam[0] __sized_by_or_null(size); // expected-error {{'sized_by_or_null' only applies to pointers; did you mean to use 'counted_by'?}}
|
|
};
|
|
|
|
struct annotated_with_anon_struct {
|
|
unsigned long flags;
|
|
struct {
|
|
unsigned char size;
|
|
int * ptr __sized_by_or_null(crount); // expected-error {{use of undeclared identifier 'crount'}}
|
|
};
|
|
};
|
|
|
|
//==============================================================================
|
|
// __sized_by_or_null on a struct ptr with element type that has unknown size
|
|
//==============================================================================
|
|
|
|
struct size_unknown;
|
|
struct on_member_ptr_incomplete_ty_ty_pos {
|
|
int size;
|
|
struct size_unknown * ptr __sized_by_or_null(size);
|
|
};
|
|
|
|
struct on_member_ptr_incomplete_const_ty_ty_pos {
|
|
int size;
|
|
const struct size_unknown * ptr __sized_by_or_null(size);
|
|
};
|
|
|
|
struct on_member_ptr_void_ty_ty_pos {
|
|
int size;
|
|
void * ptr __sized_by_or_null(size);
|
|
};
|
|
|
|
typedef void(fn_ty)(int);
|
|
|
|
struct on_member_ptr_fn_ptr_ty {
|
|
int size;
|
|
fn_ty* * ptr __sized_by_or_null(size);
|
|
};
|
|
|
|
struct on_member_ptr_fn_ty {
|
|
int size;
|
|
// expected-error@+1{{'sized_by_or_null' cannot be applied to a pointer with pointee of unknown size because 'fn_ty' (aka 'void (int)') is a function type}}
|
|
fn_ty * ptr __sized_by_or_null(size);
|
|
};
|