Files
TheRock/compiler/amd-llvm/clang/test/C/C23/n2607.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

66 lines
2.8 KiB
C

// RUN: %clang_cc1 -std=c2x -Wall -pedantic -verify %s
// RUN: %clang_cc1 -std=c17 -Wall -pedantic -verify %s
/* WG14 N2607: Partial
* Compatibility of Pointers to Arrays with Qualifiers
*
* FIXME: We consider this partially implemented because there are still issues
* with the composite type from a conditional operator. Further, we don't issue
* any diagnostics in C17 or earlier when we need at least a pedantic
* diagnostic about the type incompatibilities.
*/
void matrix_fun(int N, const float x[N][N]);
void test1(void) {
int N = 100;
float x[N][N];
// FIXME: This is OK in C23 but should be diagnosed as passing incompatible
// pointer types in C17 and earlier.
matrix_fun(N, x);
}
#define TEST(Expr, Type) _Generic(Expr, Type : 1)
void test2(void) {
typedef int array[1];
array reg_array;
const array const_array = { 0 };
// An array and its elements are identically qualified. We have to test this
// using pointers to the array and element, because the controlling
// expression of _Generic will undergo lvalue conversion, which drops
// qualifiers.
(void)_Generic(&reg_array, int (*)[1] : 1);
(void)_Generic(&reg_array[0], int * : 1);
(void)_Generic(&const_array, const int (*)[1] : 1);
(void)_Generic(&const_array[0], const int * : 1);
// But identical qualification does *not* apply to the _Atomic specifier,
// because that's a special case. You cannot apply the _Atomic specifier or
// qualifier to an array type directly.
_Atomic array atomic_array; // expected-error {{_Atomic cannot be applied to array type 'array'}}
_Atomic(array) also_atomic_array; // expected-error {{_Atomic cannot be applied to array type 'array'}}
// Ensure we support arrays of restrict-qualified pointer types.
int *restrict array_of_restricted_ptrs[1];
int *restrict md_array_of_restricted_ptrs[1][1];
}
void test3(void) {
// Validate that we pick the correct composite type for a conditional
// operator in the presence of qualifiers.
const int const_array[1] = { 0 };
int array[1];
// FIXME: the type here should be `const int (*)[1]`, but for some reason,
// Clang is deciding it's `void *`. This relates to N2607 because the
// conditional operator is not properly implementing 6.5.15p7 regarding
// qualifiers, despite that wording not being touched by this paper.
// However, it should get a pedantic diagnostic in C17 about use of
// incompatible pointer types.
(void)_Generic(1 ? &const_array : &array, const int (*)[1] : 1); /* expected-error {{controlling expression type 'void *' not compatible with any generic association type}}
expected-warning {{pointer type mismatch ('const int (*)[1]' and 'int (*)[1]')}}
*/
}