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
89 lines
3.1 KiB
C
89 lines
3.1 KiB
C
// RUN: %clang_cc1 -std=c23 -verify -triple x86_64 -pedantic -Wno-conversion -Wno-constant-conversion %s
|
|
// RUN: %clang_cc1 -std=c23 -verify -triple x86_64 -pedantic -Wno-conversion -Wno-constant-conversion -fexperimental-new-constant-interpreter %s
|
|
|
|
/* WG14 N3018: Full
|
|
* The constexpr specifier for object definitions
|
|
*/
|
|
|
|
#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
|
|
#define UINT_MAX (__INT_MAX__ *2U +1U)
|
|
|
|
void Example0() {
|
|
constexpr unsigned int minusOne = -1;
|
|
// expected-error@-1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'const unsigned int'}}
|
|
constexpr unsigned int uint_max = -1U;
|
|
constexpr double onethird = 1.0/3.0;
|
|
constexpr double onethirdtrunc = (double)(1.0/3.0);
|
|
|
|
constexpr char string[] = { "\xFF", };
|
|
constexpr unsigned char ucstring[] = { "\xFF", };
|
|
// expected-error@-1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'const unsigned char'}}
|
|
constexpr char string1[] = { -1, 0, };
|
|
constexpr unsigned char ucstring1[] = { -1, 0, };
|
|
// expected-error@-1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'const unsigned char'}}
|
|
|
|
// TODO: Make sure these work correctly once char8_t and _Decimal are supported
|
|
// constexpr char8_t u8string[] = { 255, 0, }; // ok
|
|
// constexpr char8_t u8string[] = { u8"\xFF", }; // ok
|
|
// constexpr _Decimal32 small = DEC64_TRUE_MIN * 0;// constraint violation
|
|
}
|
|
|
|
void Example1() {
|
|
constexpr int K = 47;
|
|
enum {
|
|
A = K,
|
|
};
|
|
constexpr int L = K;
|
|
static int b = K + 1;
|
|
int array[K];
|
|
_Static_assert(K == 47);
|
|
}
|
|
|
|
constexpr int K = 47;
|
|
static const int b = K + 1;
|
|
|
|
void Example2() {
|
|
constexpr int A = 42LL;
|
|
constexpr signed short B = ULLONG_MAX;
|
|
// expected-error@-1 {{constexpr initializer evaluates to 18446744073709551615 which is not exactly representable in type 'const short'}}
|
|
constexpr float C = 47u;
|
|
|
|
constexpr float D = 432000000;
|
|
constexpr float E = 1.0 / 3.0;
|
|
// expected-error@-1 {{constexpr initializer evaluates to 3.333333e-01 which is not exactly representable in type 'const float'}}
|
|
constexpr float F = 1.0f / 3.0f;
|
|
}
|
|
|
|
|
|
void Example3() {
|
|
constexpr static unsigned short array[] = {
|
|
3000,
|
|
300000,
|
|
// expected-error@-1 {{constexpr initializer evaluates to 300000 which is not exactly representable in type 'const unsigned short'}}
|
|
-1
|
|
// expected-error@-1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'const unsigned short'}}
|
|
};
|
|
|
|
constexpr static unsigned short array1[] = {
|
|
3000,
|
|
3000,
|
|
-1
|
|
// expected-error@-1 {{constexpr initializer evaluates to -1 which is not exactly representable in type 'const unsigned short'}}
|
|
};
|
|
|
|
struct S {
|
|
int x, y;
|
|
};
|
|
constexpr struct S s = {
|
|
.x = __INT_MAX__,
|
|
.y = UINT_MAX,
|
|
// expected-error@-1 {{constexpr initializer evaluates to 4294967295 which is not exactly representable in type 'int'}}
|
|
};
|
|
}
|
|
|
|
void Example4() {
|
|
struct s { void *p; };
|
|
constexpr struct s A = { nullptr };
|
|
constexpr struct s B = A;
|
|
}
|