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
134 lines
3.0 KiB
C++
134 lines
3.0 KiB
C++
// Testing that the compiler can select the correct template specialization
|
|
// from different template aliasing.
|
|
//
|
|
// RUN: rm -rf %t
|
|
// RUN: split-file %s %t
|
|
// RUN: cd %t
|
|
//
|
|
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
|
|
// RUN: %clang_cc1 -std=c++20 %t/b.cpp -fprebuilt-module-path=%t \
|
|
// RUN: -fsyntax-only -verify
|
|
|
|
//--- a.cppm
|
|
|
|
// For template type parameters
|
|
export module a;
|
|
export template <class C>
|
|
struct S {
|
|
static constexpr bool selected = false;
|
|
};
|
|
|
|
export struct A {};
|
|
|
|
export template <>
|
|
struct S<A> {
|
|
static constexpr bool selected = true;
|
|
};
|
|
|
|
export using B = A;
|
|
|
|
// For template template parameters
|
|
|
|
export template <template<typename> typename C>
|
|
struct V {
|
|
static constexpr bool selected = false;
|
|
};
|
|
|
|
export template <>
|
|
struct V<S> {
|
|
static constexpr bool selected = true;
|
|
};
|
|
|
|
// For template non type parameters
|
|
export template <int X>
|
|
struct Numbers {
|
|
static constexpr bool selected = false;
|
|
static constexpr int value = X;
|
|
};
|
|
|
|
export template<>
|
|
struct Numbers<43> {
|
|
static constexpr bool selected = true;
|
|
static constexpr int value = 43;
|
|
};
|
|
|
|
export template <const int *>
|
|
struct Pointers {
|
|
static constexpr bool selected = false;
|
|
};
|
|
|
|
export int IntegralValue = 0;
|
|
export template<>
|
|
struct Pointers<&IntegralValue> {
|
|
static constexpr bool selected = true;
|
|
};
|
|
|
|
export template <void *>
|
|
struct NullPointers {
|
|
static constexpr bool selected = false;
|
|
};
|
|
|
|
export template<>
|
|
struct NullPointers<nullptr> {
|
|
static constexpr bool selected = true;
|
|
};
|
|
|
|
export template<int (&)[5]>
|
|
struct Array {
|
|
static constexpr bool selected = false;
|
|
};
|
|
|
|
export int array[5];
|
|
export template<>
|
|
struct Array<array> {
|
|
static constexpr bool selected = true;
|
|
};
|
|
|
|
//--- b.cpp
|
|
// expected-no-diagnostics
|
|
import a;
|
|
|
|
// Testing for different qualifiers
|
|
static_assert(S<B>::selected);
|
|
static_assert(S<::B>::selected);
|
|
static_assert(::S<B>::selected);
|
|
static_assert(::S<::B>::selected);
|
|
typedef A C;
|
|
static_assert(S<C>::selected);
|
|
static_assert(S<::C>::selected);
|
|
static_assert(::S<C>::selected);
|
|
static_assert(::S<::C>::selected);
|
|
|
|
namespace D {
|
|
C getAType();
|
|
typedef C E;
|
|
}
|
|
|
|
static_assert(S<D::E>::selected);
|
|
static_assert(S<decltype(D::getAType())>::selected);
|
|
|
|
// Testing we can select the correct specialization for different
|
|
// template template argument alising.
|
|
|
|
static_assert(V<S>::selected);
|
|
static_assert(V<::S>::selected);
|
|
static_assert(::V<S>::selected);
|
|
static_assert(::V<::S>::selected);
|
|
|
|
// Testing for template non type parameters
|
|
static_assert(Numbers<43>::selected);
|
|
static_assert(Numbers<21 * 2 + 1>::selected);
|
|
static_assert(Numbers<42 + 1>::selected);
|
|
static_assert(Numbers<44 - 1>::selected);
|
|
static_assert(Numbers<Numbers<43>::value>::selected);
|
|
static_assert(!Numbers<44>::selected);
|
|
|
|
static_assert(Pointers<&IntegralValue>::selected);
|
|
static_assert(!Pointers<nullptr>::selected);
|
|
static_assert(NullPointers<nullptr>::selected);
|
|
static_assert(!NullPointers<(void*)&IntegralValue>::selected);
|
|
|
|
static_assert(Array<array>::selected);
|
|
int another_array[5];
|
|
static_assert(!Array<another_array>::selected);
|