Files
TheRock/compiler/amd-llvm/clang/test/Sema/expr-address-of.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

126 lines
3.6 KiB
C

// RUN: %clang_cc1 %s -verify -fsyntax-only -Wno-strict-prototypes
struct xx { int bitf:1; };
struct entry { struct xx *whatever;
int value;
int bitf:1; };
void add_one(int *p) { (*p)++; }
void test(void) {
register struct entry *p;
add_one(&p->value);
struct entry pvalue;
add_one(&p->bitf); // expected-error {{address of bit-field requested}}
add_one(&pvalue.bitf); // expected-error {{address of bit-field requested}}
add_one(&p->whatever->bitf); // expected-error {{address of bit-field requested}}
}
void foo(void) {
register int x[10];
&x[10]; // expected-error {{address of register variable requested}}
register int *y;
int *x2 = &y; // expected-error {{address of register variable requested}}
int *x3 = &y[10];
}
void testVectorComponentAccess(void) {
typedef float v4sf __attribute__ ((vector_size (16)));
static v4sf q;
float* r = &q[0]; // expected-error {{address of vector element requested}}
}
typedef __attribute__(( ext_vector_type(4) )) float float4;
float *testExtVectorComponentAccess(float4 x) {
return &x.w; // expected-error {{address of vector element requested}}
}
void f0(void) {
register int *x0;
int *_dummy0 = &(*x0);
register int *x1;
int *_dummy1 = &(*(x1 + 1));
}
void f1(void) {
register int x0[10];
int *_dummy00 = x0; // expected-error {{address of register variable requested}}
int *_dummy01 = &(*x0); // expected-error {{address of register variable requested}}
register int x1[10];
int *_dummy1 = &(*(x1 + 1)); // expected-error {{address of register variable requested}}
register int *x2;
int *_dummy2 = &(*(x2 + 1));
register int x3[10][10][10];
int(*_dummy3)[10] = &x3[0][0]; // expected-error {{address of register variable requested}}
register struct { int f0[10]; } x4;
int *_dummy4 = &x4.f0[2]; // expected-error {{address of register variable requested}}
add_one(x0); // expected-error {{address of register variable requested}}
(void)sizeof(x0); // OK, not an array decay.
int *p = ((int *)x0)++; // expected-error {{address of register variable requested}}
}
void f2(void) {
register int *y;
int *_dummy0 = &y; // expected-error {{address of register variable requested}}
int *_dummy1 = &y[10];
}
void f3(void) {
extern void f4(void);
void (*_dummy0)(void) = &****f4;
}
void f4(void) {
register _Complex int x;
int *_dummy0 = &__real__ x; // expected-error {{address of register variable requested}}
}
void f5(void) {
register int arr[2];
int *_dummy0 = &(int*) arr; // expected-error {{address of register variable requested}}
int *_dummy1 = &(arr + 1); // expected-error {{address of register variable requested}}
}
void f6(register int x) {
int * dummy0 = &x; // expected-error {{address of register variable requested}}
}
char* f7(void) {
register struct {char* x;} t1 = {"Hello"};
char* dummy1 = &(t1.x[0]);
struct {int a : 10; struct{int b : 10;};} t2;
int* dummy2 = &(t2.a); // expected-error {{address of bit-field requested}}
int* dummy3 = &(t2.b); // expected-error {{address of bit-field requested}}
void* t3 = &*(void*)0;
}
void f8(void) {
void *dummy0 = &f8(); // expected-error {{cannot take the address of an rvalue of type 'void'}}
extern void v;
void *dummy1 = &(1 ? v : f8()); // expected-error {{cannot take the address of an rvalue of type 'void'}}
void *dummy2 = &(f8(), v); // expected-error {{cannot take the address of an rvalue of type 'void'}}
void *dummy3 = &({ ; }); // expected-error {{cannot take the address of an rvalue of type 'void'}}
}
void f9(void) {
extern void knr();
void (*_dummy0)() = &****knr;
}