Files
TheRock/compiler/amd-llvm/clang/test/Sema/attr-counted-by-late-parsed-struct-ptrs-anon.c
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

85 lines
2.7 KiB
C

// RUN: %clang_cc1 -fexperimental-late-parse-attributes -fsyntax-only -verify %s
// Test that counted_by works correctly with late parsing when ActOnFields
// is called before late-parsed attributes are evaluated. This allows offset
// expressions in counted_by to be evaluated.
#define __counted_by(f) __attribute__((counted_by(f)))
struct size_known {
int field;
};
//==============================================================================
// Verify anonymous struct handling works correctly under current ordering.
// GetEnclosingNamedOrTopAnonRecord must correctly walk through anonymous
// structs when the struct is already marked complete.
//==============================================================================
// count in outer struct, buf in anonymous struct
struct on_pointer_anon_buf {
int count;
struct {
struct size_known *buf __counted_by(count);
};
};
// both count and buf in anonymous struct
struct on_pointer_anon_both {
struct {
int count;
struct size_known *buf __counted_by(count);
};
};
// nested anonymous structs
struct on_pointer_nested_anon {
int count;
struct {
struct {
struct size_known *buf __counted_by(count);
};
};
};
//==============================================================================
// Verify non-anonymous unnamed structs correctly reject counted_by if it
// references fields in the outer struct.
//==============================================================================
// count in outer, buf in non-anonymous unnamed struct: should reject
struct on_pointer_named_inner {
int count; // expected-note{{'count' declared here}}
struct {
// expected-error@+1{{'counted_by' field 'count' isn't within the same struct as the annotated pointer}}
struct size_known *buf __counted_by(count);
} inner;
};
// both in non-anonymous unnamed struct: should accept
struct on_pointer_named_inner_both {
struct {
int count;
struct size_known *buf __counted_by(count);
} inner;
};
//==============================================================================
// TODO: allow future sizeof, offsetof expressions in the new ordering
// of ActOnFields
//==============================================================================
#define offsetof(t, d) __builtin_offsetof(t, d)
struct pointer_sizeof {
// TODO: Allow this
// expected-error@+1{{'counted_by' argument must be a simple declaration reference}}
struct size_known *p __counted_by(sizeof(struct pointer_sizeof));
};
struct pointer_offsetof {
// TODO: Allow this
// expected-error@+1{{'counted_by' argument must be a simple declaration reference}}
struct size_known *q __counted_by(offsetof(struct pointer_offsetof, q));
};