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
64 lines
2.7 KiB
C++
64 lines
2.7 KiB
C++
// RUN: %clang_cc1 -std=c++2a -verify %s
|
|
|
|
namespace functions
|
|
{
|
|
template<typename T>
|
|
struct S {
|
|
static void foo(int) requires false {}
|
|
// expected-note@-1 3{{because 'false' evaluated to false}}
|
|
static void bar(int) requires true {}
|
|
};
|
|
|
|
void a(int);
|
|
void a(double);
|
|
|
|
void baz() {
|
|
S<int>::foo(1); // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
S<int>::bar(1);
|
|
void (*p1)(int) = S<int>::foo; // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
void (*p3)(int) = S<int>::bar;
|
|
decltype(S<int>::foo)* a1 = nullptr; // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
decltype(S<int>::bar)* a2 = nullptr;
|
|
}
|
|
}
|
|
|
|
namespace methods
|
|
{
|
|
template<typename T>
|
|
struct A {
|
|
static void foo(int) requires (sizeof(T) == 1) {} // expected-note 3{{because 'sizeof(char[2]) == 1' (2 == 1) evaluated to false}}
|
|
static void bar(int) requires (sizeof(T) == 2) {} // expected-note 3{{because 'sizeof(char) == 2' (1 == 2) evaluated to false}}
|
|
// Make sure the function body is not instantiated before constraints are checked.
|
|
static auto baz(int) requires (sizeof(T) == 2) { return T::foo(); } // expected-note{{because 'sizeof(char) == 2' (1 == 2) evaluated to false}}
|
|
};
|
|
|
|
void baz() {
|
|
A<char>::foo(1);
|
|
A<char>::bar(1); // expected-error{{invalid reference to function 'bar': constraints not satisfied}}
|
|
A<char>::baz(1); // expected-error{{invalid reference to function 'baz': constraints not satisfied}}
|
|
A<char[2]>::foo(1); // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
A<char[2]>::bar(1);
|
|
void (*p1)(int) = A<char>::foo;
|
|
void (*p2)(int) = A<char>::bar; // expected-error{{invalid reference to function 'bar': constraints not satisfied}}
|
|
void (*p3)(int) = A<char[2]>::foo; // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
void (*p4)(int) = A<char[2]>::bar;
|
|
decltype(A<char>::foo)* a1 = nullptr;
|
|
decltype(A<char>::bar)* a2 = nullptr; // expected-error{{invalid reference to function 'bar': constraints not satisfied}}
|
|
decltype(A<char[2]>::foo)* a3 = nullptr; // expected-error{{invalid reference to function 'foo': constraints not satisfied}}
|
|
decltype(A<char[2]>::bar)* a4 = nullptr;
|
|
}
|
|
}
|
|
|
|
namespace operators
|
|
{
|
|
template<typename T>
|
|
struct A {
|
|
A<T> operator-(A<T> b) requires (sizeof(T) == 1) { return b; } // expected-note{{because 'sizeof(int) == 1' (4 == 1) evaluated to false}}
|
|
};
|
|
|
|
void baz() {
|
|
auto* x = &A<int>::operator-; // expected-error{{invalid reference to function 'operator-': constraints not satisfied}}
|
|
auto y = &A<char>::operator-;
|
|
}
|
|
}
|