Files
TheRock/compiler/amd-llvm/clang/test/CXX/temp/temp.param/p8-cxx20.cpp
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
1.9 KiB
C++

// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -verify %s
struct A { int n; };
template<A a> struct B {
static constexpr A &v = a; // expected-error {{binding reference of type 'A' to value of type 'const A' drops 'const' qualifier}}
};
template<A a> struct C {
static constexpr const A &v = a;
};
// All such template parameters in the program of the same type with the same
// value denote the same template parameter object.
template<A a, typename T> void check() {
static_assert(&a == &T::v); // expected-error {{failed}}
}
using T = C<A{1}>;
template void check<A{1}, T>();
template void check<A{2}, T>(); // expected-note {{instantiation of}}
// Different types with the same value are unequal.
struct A2 { int n; };
template<A2 a2> struct C2 {
static constexpr const A2 &v = a2;
};
static_assert((void*)&C<A{}>::v != (void*)&C2<A2{}>::v);
// A template parameter object shall have constant destruction.
namespace ConstDestruction {
struct D {
int n;
bool can_destroy;
constexpr ~D() {
if (!can_destroy)
throw "oh no"; // expected-note {{subexpression not valid}}
}
};
template<D d>
void f() {} // expected-note 2{{non-type template argument is not a constant expression}}
void g() {
f<D{0, true}>();
f<D{0, false}>(); // expected-error {{no matching function}}
}
// We can SFINAE on constant destruction.
template<typename T> auto h(T t) -> decltype(f<T{1, false}>());
template<typename T> auto h(T t) -> decltype(f<T{1, true}>());
void i() {
h(D());
// Ensure we don't cache an invalid template argument after we've already
// seen it in a SFINAE context.
f<D{1, false}>(); // expected-error {{no matching function}}
f<D{1, true}>();
}
template<D d> struct Z {};
Z<D{2, true}> z1;
Z<D{2, false}> z2; // expected-error {{non-type template argument is not a constant expression}} expected-note-re {{in call to '{{.*}}.~D()'}}
}