Files
TheRock/compiler/amd-llvm/clang/test/Analysis/store-union-aggregates.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

36 lines
1.6 KiB
C

// RUN: %clang_analyze_cc1 -verify %s
// expected-no-diagnostics
struct SizedBufferPtr {
union {
int* buffer_ptr;
} /*anonymous*/;
int size;
};
extern int global_buf_size;
extern int global_buf[];
void analysis_entry_point_rdar167136849(void) {
// When binding the initial value for "buffers".
// We will first bind the first array element: buffers[0] <- cv{cv{&Elem{global_buf, 0}}}
// This is of type "struct SizedBufferPtr" so we dispatch this bind to bind by fields.
// So we bind: buffers[0].union anonymous <- cv{&Elem{global_buf, 0}}
// Because that is "isUnionType", its bound using "bindAggregate", thus add a default binding.
// After this we have in the Store: { default at 0: cv{&Elem{global_buf, 0}} }
// We then bind the second field: buffers[0].size <- reg{global_buf_size}
// After this we have in the Store: { default at 0: cv{&Elem{global_buf, 0}}, direct at 64: reg{global_buf_size} }
// We are done with the initializer expression, so we realize that
// the second element of "buffers" didn't have an explicit initializer,
// so we need to bind a suitable default value using "setImplicitDefaultValue".
// That happens to add a default binding 0 to "buffer", which overwrites the previous default binding that "bindAggregate" added.
// After this we falsely conclude that "buffers[0].buffer_ptr" is a nullptr.
struct SizedBufferPtr buffers[2] = {
{.buffer_ptr = global_buf, .size = global_buf_size},
// [1] is not explicitly initialized, so it will be defaulted to zero.
};
*buffers[0].buffer_ptr = 2; // no-warning: writing indirectly to "global_buf" is fine
}