Files
TheRock/compiler/amd-llvm/clang/test/CXX/drs/cwg24xx.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

238 lines
7.1 KiB
C++

// RUN: %clang_cc1 -std=c++98 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,cxx98-14,cxx98-17
// RUN: %clang_cc1 -std=c++11 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,cxx98-14,cxx98-17
// RUN: %clang_cc1 -std=c++14 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,cxx98-14,cxx98-17
// RUN: %clang_cc1 -std=c++17 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx17,cxx98-17
// RUN: %clang_cc1 -std=c++20 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx20,since-cxx17
// RUN: %clang_cc1 -std=c++23 -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx20,since-cxx17
// RUN: %clang_cc1 -std=c++2c -fexceptions -fcxx-exceptions -pedantic-errors %s -verify-directives -verify=expected,since-cxx20,since-cxx17
// cwg2406 is in cwg2406.cpp
namespace cwg2413 { // cwg2413: 23
template <typename T>
struct S {
operator T::R();
// cxx98-17-error@-1 {{missing 'typename' prior to dependent type name 'T::R' is a C++20 extension}}
void f() { operator T::R(); }
// cxx98-17-error@-1 {{missing 'typename' prior to dependent type name 'T::R' is a C++20 extension}}
};
} // namespace cwg2413
namespace cwg2428 { // cwg2428: 19
#if __cplusplus >= 202002L
template <typename>
concept C [[deprecated]] = true; // #cwg2428-C
template <typename>
[[deprecated]] concept C2 = true;
// since-cxx20-error@-1 {{expected unqualified-id}}
template <typename T>
concept C3 = C<T>;
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
template <typename T, C U>
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
requires C<T>
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
void f() {
bool b = C<int>;
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
};
void g(C auto a) {};
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
template <typename T>
auto h() -> C auto {
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto foo = T();
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto *bar = T();
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto &baz = T();
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
C auto &&quux = T();
// since-cxx20-warning@-1 {{'C' is deprecated}}
// since-cxx20-note@#cwg2428-C {{'C' has been explicitly marked deprecated here}}
return foo;
}
#endif
} // namespace cwg2428
namespace cwg2430 { // cwg2430: 2.7
struct S {
S f(S s) { return s; }
};
} // namespace cwg2430
namespace cwg2450 { // cwg2450: 18
#if __cplusplus >= 202302L
struct S {int a;};
template <S s>
void f(){}
void test() {
f<{0}>();
f<{.a= 0}>();
}
#endif
} // namespace cwg2450
namespace cwg2459 { // cwg2459: 18
#if __cplusplus >= 202302L
struct A {
constexpr A(float) {}
};
template<A> struct X {};
X<1> x;
#endif
} // namespace cwg2459
namespace cwg2445 { // cwg2445: 19
#if __cplusplus >= 202002L
template <typename> constexpr bool F = false;
template <typename T> struct A { };
template <typename T, typename U>
bool operator==(T, A<U *>);
template <typename T, typename U>
bool operator!=(A<T>, U) {
static_assert(F<T>, "Isn't this less specialized?");
return false;
}
bool f(A<int> ax, A<int *> ay) { return ay != ax; }
template<class T> concept AlwaysTrue=true;
template <class T> struct B {
template <AlwaysTrue U>
bool operator==(const B<U>&)const;
};
template <typename U>
bool operator==(const B<int>&,const B<U>&) {
static_assert(F<int>, "Isn't this less specialized?");
return false;
}
bool g(B<int> bx, B<int *> by) { return bx == by; }
struct C{
template<AlwaysTrue T>
int operator+(T){return 0;}
template<class T>
void operator-(T){}
};
template<class T>
void operator+(C&&,T){}
template<AlwaysTrue T>
int operator-(C&&,T){return 0;}
void t(int* iptr){
int x1 = C{} + iptr;
int x2 = C{} - iptr;
}
struct D{
template<AlwaysTrue T>
int operator+(T) volatile {return 1;}
};
template<class T>
void operator+(volatile D&,T) {}
int foo(volatile D& d){
return d + 1;
}
#endif
} // namespace cwg2445
namespace cwg2486 { // cwg2486: 4 c++17
struct C {
void fn() throw();
};
static void call(C& c, void (C::*f)()) {
(c.*f)();
}
static void callNE(C& c, void (C::*f)() throw()) {
// cxx98-14-warning@-1 {{mangled name of 'callNE' will change in C++17 due to non-throwing exception specification in function signature}}
(c.*f)();
}
void ref() {
C c;
call(c, &C::fn); // <= implicit cast removes noexcept
callNE(c, &C::fn);
}
void (*p)();
void (*pp)() throw() = p;
// cxx98-14-error@-1 {{target exception specification is not superset of source}}
// since-cxx17-error@-2 {{cannot initialize a variable of type 'void (*)() throw()' with an lvalue of type 'void (*)()': different exception specifications}}
struct S {
typedef void (*p)();
operator p(); // #cwg2486-conv
};
void (*q)() throw() = S();
// since-cxx17-error@-1 {{no viable conversion from 'S' to 'void (*)() throw()'}}
// since-cxx17-note@#cwg2486-conv {{candidate function}}
} // namespace cwg2486
namespace cwg2496 { // cwg2496: 21
#if __cplusplus >= 201102L
struct S {
virtual void f(); // #cwg2496-f
virtual void g() &; // #cwg2496-g
virtual void h(); // #cwg2496-h
virtual void i();
virtual void j() &;
virtual void k() &&;
virtual void l() &;
};
struct T : S {
virtual void f() &;
// expected-error@-1 {{cannot overload a member function with ref-qualifier '&' with a member function without a ref-qualifier}}
// expected-note@#cwg2496-f {{previous declaration is here}}
virtual void g();
// expected-error@-1 {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&'}}
// expected-note@#cwg2496-g {{previous declaration is here}}
virtual void h() &&;
// expected-error@-1 {{cannot overload a member function with ref-qualifier '&&' with a member function without a ref-qualifier}}
// expected-note@#cwg2496-h {{previous declaration is here}}
virtual void i();
virtual void j() &;
virtual void k() &;
virtual void l() &&;
};
#if __cplusplus >= 202002L
// We should not error on inconsistent ref-qualifiers if the functions
// have different constraints.
template <unsigned R> struct type {
void func() const requires(R == 0);
void func() & requires(R == 1);
};
#endif
#endif
}