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
99 lines
3.8 KiB
C
99 lines
3.8 KiB
C
// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -verify %s
|
|
|
|
extern int a[] __attribute__((weak));
|
|
int b[] = {8,13,21};
|
|
struct {
|
|
int x[10];
|
|
} c;
|
|
const char str[] = "text";
|
|
|
|
void ignore(void) {
|
|
if (!a) {}
|
|
}
|
|
void test(void) {
|
|
if (!b) {} // expected-warning {{address of array 'b' will always evaluate to 'true'}}
|
|
if (b == 0) {} // expected-warning {{comparison of array 'b' equal to a null pointer is always false}}
|
|
if (!c.x) {} // expected-warning {{address of array 'c.x' will always evaluate to 'true'}}
|
|
if (c.x == 0) {} // expected-warning {{comparison of array 'c.x' equal to a null pointer is always false}}
|
|
if (!str) {} // expected-warning {{address of array 'str' will always evaluate to 'true'}}
|
|
if (0 == str) {} // expected-warning {{comparison of array 'str' equal to a null pointer is always false}}
|
|
}
|
|
|
|
int array[2];
|
|
int test1(void)
|
|
{
|
|
if (!array) { // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
return array[0];
|
|
} else if (array != 0) { // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
|
|
return array[1];
|
|
}
|
|
if (array == 0) // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
|
|
return 1;
|
|
return 0;
|
|
}
|
|
|
|
#define NULL (void*)0
|
|
|
|
int test2(int* pointer, char ch, void * pv) {
|
|
if (!&pointer) { // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
|
|
return 0;
|
|
}
|
|
|
|
if (&pointer) { // expected-warning {{address of 'pointer' will always evaluate to 'true'}}
|
|
return 0;
|
|
}
|
|
|
|
if (&pointer == NULL) {} // expected-warning {{comparison of address of 'pointer' equal to a null pointer is always false}}
|
|
|
|
if (&pointer != NULL) {} // expected-warning {{comparison of address of 'pointer' not equal to a null pointer is always true}}
|
|
|
|
return 1;
|
|
}
|
|
|
|
void test3(void) {
|
|
if (array) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
if (array != 0) {} // expected-warning {{comparison of array 'array' not equal to a null pointer is always true}}
|
|
if (!array) { } // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
if (array == 0) {} // expected-warning {{comparison of array 'array' equal to a null pointer is always false}}
|
|
|
|
if (array[0] &&
|
|
array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
|
|
if (array[0] ||
|
|
array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
|
|
if (array[0] &&
|
|
!array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
if (array[0] ||
|
|
!array) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
|
|
if (array && // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
array[0]) {}
|
|
if (!array || // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
array[0]) {}
|
|
|
|
if (array || // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
(!array && array[0])) {} // expected-warning {{address of array 'array' will always evaluate to 'true'}}
|
|
}
|
|
|
|
#define SAVE_READ(PTR) if( (PTR) && (&result) ) *result=*PTR;
|
|
void _HTTPClientErrorHandler(int me)
|
|
{
|
|
int *result;
|
|
SAVE_READ(&me);
|
|
}
|
|
|
|
void test_conditional_operator(void) {
|
|
int x;
|
|
x = b ? 1 : 0; // expected-warning {{address of array}}
|
|
x = c.x ? 1 : 0; // expected-warning {{address of array}}
|
|
x = str ? 1 : 0; // expected-warning {{address of array}}
|
|
x = array ? 1 : 0; // expected-warning {{address of array}}
|
|
x = &x ? 1 : 0; // expected-warning {{address of 'x'}}
|
|
}
|
|
|
|
void test4(void) {
|
|
int *a = (void *) 0;
|
|
int b = (&a) == ((void *) 0); // expected-warning {{comparison of address of 'a' equal to a null pointer is always false}}
|
|
}
|