Files
TheRock/compiler/amd-llvm/clang/test/CXX/temp/temp.spec/temp.expl.spec/p7.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

339 lines
10 KiB
C++

// RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify %s
namespace Undefined {
template<typename T>
struct A {
template<typename U>
static constexpr int f(); // expected-note {{declared here}}
template<typename U>
static const int x; // expected-note {{declared here}}
template<typename U>
static const int x<U*>; // expected-note {{declared here}}
template<typename U>
struct B; // expected-note {{template is declared here}}
template<typename U>
struct B<U*>; // expected-note {{template is declared here}}
};
template<>
template<typename U>
constexpr int A<short>::f() {
return A<long>::f<U>();
}
template<>
template<typename U>
constexpr int A<short>::x = A<long>::x<U>;
template<>
template<typename U>
constexpr int A<short>::x<U*> = A<long>::x<U*>;
template<>
template<typename U>
struct A<short>::B<U*> {
static constexpr int y = A<long>::B<U*>::y;
};
template<>
template<typename U>
struct A<short>::B {
static constexpr int y = A<long>::B<U>::y;
};
template<>
template<typename U>
constexpr int A<long>::f() {
return 1;
}
template<>
template<typename U>
constexpr int A<long>::x = 1;
template<>
template<typename U>
constexpr int A<long>::x<U*> = 2;
template<>
template<typename U>
struct A<long>::B {
static constexpr int y = 1;
};
template<>
template<typename U>
struct A<long>::B<U*> {
static constexpr int y = 2;
};
static_assert(A<int>::f<int>() == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{undefined function 'f<int>' cannot be used in a constant expression}}
static_assert(A<int>::x<int> == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{initializer of 'x<int>' is unknown}}
static_assert(A<int>::x<int*> == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{initializer of 'x<int *>' is unknown}}
static_assert(A<int>::B<int>::y == 0); // expected-error {{implicit instantiation of undefined template 'Undefined::A<int>::B<int>'}}
static_assert(A<int>::B<int*>::y == 0); // expected-error {{implicit instantiation of undefined template 'Undefined::A<int>::B<int *>'}}
static_assert(A<short>::f<int>() == 1);
static_assert(A<short>::x<int> == 1);
static_assert(A<short>::x<int*> == 2);
static_assert(A<short>::B<int>::y == 1);
static_assert(A<short>::B<int*>::y == 2);
} // namespace Undefined
namespace Defined {
template<typename T>
struct A {
template<typename U>
static constexpr int f() {
return 0;
};
template<typename U>
static const int x = 0;
template<typename U>
static const int x<U*> = 0;
template<typename U>
struct B {
static constexpr int y = 0;
};
template<typename U>
struct B<U*> {
static constexpr int y = 0;
};
};
template<>
template<typename U>
constexpr int A<short>::f() {
return A<long>::f<U>();
}
template<>
template<typename U>
constexpr int A<short>::x = A<long>::x<U>;
template<>
template<typename U>
constexpr int A<short>::x<U*> = A<long>::x<U*>;
template<>
template<typename U>
struct A<short>::B<U*> {
static constexpr int y = A<long>::B<U*>::y;
};
template<>
template<typename U>
struct A<short>::B {
static constexpr int y = A<long>::B<U>::y;
};
template<>
template<typename U>
constexpr int A<long>::f() {
return 1;
}
template<>
template<typename U>
constexpr int A<long>::x = 1;
template<>
template<typename U>
constexpr int A<long>::x<U*> = 2;
template<>
template<typename U>
struct A<long>::B {
static constexpr int y = 1;
};
template<>
template<typename U>
struct A<long>::B<U*> {
static constexpr int y = 2;
};
static_assert(A<int>::f<int>() == 0);
static_assert(A<int>::x<int> == 0);
static_assert(A<int>::x<int*> == 0);
static_assert(A<int>::B<int>::y == 0);
static_assert(A<int>::B<int*>::y == 0);
static_assert(A<short>::f<int>() == 1);
static_assert(A<short>::x<int> == 1);
static_assert(A<short>::x<int*> == 2);
static_assert(A<short>::B<int>::y == 1);
static_assert(A<short>::B<int*>::y == 2);
} // namespace Defined
namespace Constrained {
template<typename T>
struct A {
// FIXME expected-note@-1 2{{defined here}}
template<typename U, bool V> requires V
static constexpr int f(); // expected-note {{declared here}}
// FIXME expected-note@-1 {{declared here}}
template<typename U, bool V> requires V
static const int x; // expected-note {{declared here}}
// FIXME expected-note@-2 2{{previous template declaration is here}}
// FIXME expected-note@-2 {{declared here}}
template<typename U, bool V> requires V
static const int x<U*, V>; // expected-note {{declared here}}
// FIXME expected-note@-1 {{partial specialization matches}}
template<typename U, bool V> requires V
struct B; // expected-note {{template is declared here}}
// FIXME expected-note@-2 2{{previous template declaration is here}}
// FIXME expected-note@-2 {{template is declared here}}
template<typename U, bool V> requires V
struct B<U*, V>; // expected-note {{template is declared here}}
// FIXME expected-note@-1 {{partial specialization matches}}
};
template<>
template<typename U, bool V> requires V
constexpr int A<short>::f() {
return A<long>::f<U, V>();
}
// FIXME expected-error@-3 {{out-of-line definition of 'f' does not match any declaration in 'Constrained::A<short>'}}
template<>
template<typename U, bool V> requires V
constexpr int A<short>::x = A<long>::x<U, V>;
// FIXME expected-error@-2 {{requires clause differs in template redeclaration}}
template<>
template<typename U, bool V> requires V
constexpr int A<short>::x<U*, V> = A<long>::x<U*, V>;
// FIXME expected-note@-1 {{partial specialization matches}}
template<>
template<typename U, bool V> requires V
struct A<short>::B<U*, V> {
static constexpr int y = A<long>::B<U*, V>::y;
};
// FIXME expected-note@-3 {{partial specialization matches}}
template<>
template<typename U, bool V> requires V
struct A<short>::B {
static constexpr int y = A<long>::B<U, V>::y;
};
// FIXME expected-error@-4 {{requires clause differs in template redeclaration}}
template<>
template<typename U, bool V> requires V
constexpr int A<long>::f() {
return 1;
}
// FIXME expected-error@-3 {{out-of-line definition of 'f' does not match any declaration in 'Constrained::A<long>'}}
template<>
template<typename U, bool V> requires V
constexpr int A<long>::x = 1;
// FIXME expected-error@-2 {{requires clause differs in template redeclaration}}
template<>
template<typename U, bool V> requires V
constexpr int A<long>::x<U*, V> = 2;
template<>
template<typename U, bool V> requires V
struct A<long>::B {
static constexpr int y = 1;
};
// FIXME expected-error@-4 {{requires clause differs in template redeclaration}}
template<>
template<typename U, bool V> requires V
struct A<long>::B<U*, V> {
static constexpr int y = 2;
};
static_assert(A<int>::f<int, true>() == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{undefined function 'f<int, true>' cannot be used in a constant expression}}
static_assert(A<int>::x<int, true> == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{initializer of 'x<int, true>' is unknown}}
static_assert(A<int>::x<int*, true> == 0); // expected-error {{static assertion expression is not an integral constant expression}}
// expected-note@-1 {{initializer of 'x<int *, true>' is unknown}}
static_assert(A<int>::B<int, true>::y == 0); // expected-error {{implicit instantiation of undefined template 'Constrained::A<int>::B<int, true>'}}
static_assert(A<int>::B<int*, true>::y == 0); // expected-error {{implicit instantiation of undefined template 'Constrained::A<int>::B<int *, true>'}}
static_assert(A<short>::f<int, true>() == 1);
// FIXME expected-error@-1 {{static assertion expression is not an integral constant expression}}
// FIXME expected-note@-2 {{undefined function 'f<int, true>' cannot be used in a constant expression}}
static_assert(A<short>::x<int, true> == 1);
// FIXME expected-error@-1 {{static assertion expression is not an integral constant expression}}
// FIXME expected-note@-2 {{initializer of 'x<int, true>' is unknown}}
static_assert(A<short>::x<int*, true> == 2);
// FIXME expected-error@-1 {{ambiguous partial specializations of 'x'}}
static_assert(A<short>::B<int, true>::y == 1);
// FIXME expected-error@-1 {{implicit instantiation of undefined template 'Constrained::A<short>::B<int, true>'}}
static_assert(A<short>::B<int*, true>::y == 2);
// FIXME expected-error@-1 {{ambiguous partial specializations of 'B<int *, true>'}}
} // namespace Constrained
namespace Dependent {
template<int I>
struct A {
template<int J>
static constexpr int f();
template<int J>
static const int x;
template<int J>
struct B;
};
template<>
template<int J>
constexpr int A<0>::f() {
return A<1>::f<J>();
}
template<>
template<int J>
constexpr int A<1>::f() {
return J;
}
template<>
template<int J>
constexpr int A<0>::x = A<1>::x<J>;
template<>
template<int J>
constexpr int A<1>::x = J;
template<>
template<int J>
struct A<0>::B {
static constexpr int y = A<1>::B<J>::y;
};
template<>
template<int J>
struct A<1>::B {
static constexpr int y = J;
};
static_assert(A<0>::f<2>() == 2);
static_assert(A<0>::x<2> == 2);
static_assert(A<0>::B<2>::y == 2);
} // namespace Dependent