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

265 lines
8.5 KiB
C++

// RUN: %clang_cc1 -std=c++98 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected
// RUN: %clang_cc1 -std=c++11 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
// RUN: %clang_cc1 -std=c++14 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
// RUN: %clang_cc1 -std=c++17 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
// RUN: %clang_cc1 -std=c++20 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
// RUN: %clang_cc1 -std=c++23 %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
// RUN: %clang_cc1 -std=c++2c %s -fexceptions -fcxx-exceptions -pedantic-errors -verify-directives -verify=expected,since-cxx11
namespace cwg1710 { // cwg1710: no
// FIXME: all of the following is well-formed
template <typename T> struct D1 : T::template B<int>::template C<int> {};
template <typename T> struct D2 : T::B<int>::template C<int> {};
// expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
template <typename T> struct D3 : T::template B<int>::C<int> {};
// expected-error@-1 {{use 'template' keyword to treat 'C' as a dependent template name}}
template <typename T> struct D4 : T::B<int>::C<int> {};
// expected-error@-1 {{use 'template' keyword to treat 'B' as a dependent template name}}
// expected-error@-2 {{use 'template' keyword to treat 'C' as a dependent template name}}
} // namespace cwg1710
namespace cwg1715 { // cwg1715: 3.9
#if __cplusplus >= 201103L
struct B {
template<class T> B(T, typename T::Q);
};
class S {
using Q = int;
template<class T> friend B::B(T, typename T::Q);
};
struct D : B {
using B::B;
};
struct E : B { // #cwg1715-E
template<class T> E(T t, typename T::Q q) : B(t, q) {} // #cwg1715-E-ctor
};
B b(S(), 1);
D d(S(), 2);
E e(S(), 3);
// since-cxx11-error@-1 {{no matching constructor for initialization of 'E'}}
// since-cxx11-note@#cwg1715-E-ctor {{candidate template ignored: substitution failure [with T = S]: 'Q' is a private member of 'cwg1715::S'}}
// since-cxx11-note@#cwg1715-E {{candidate constructor (the implicit copy constructor) not viable: requires 1 argument, but 2 were provided}}
// since-cxx11-note@#cwg1715-E {{candidate constructor (the implicit move constructor) not viable: requires 1 argument, but 2 were provided}}
#endif
} // namespace cwg1715
namespace cwg1719 { // cwg1719: 19
#if __cplusplus >= 201103L
struct CStruct {
int one;
int two;
};
struct CStruct2 {
int one;
int two;
};
struct CStructWithQualifiers {
const int one;
volatile int two;
};
static_assert(__is_layout_compatible(CStruct, const CStruct2), "");
static_assert(__is_layout_compatible(CStruct, volatile CStruct2), "");
static_assert(__is_layout_compatible(const CStruct, volatile CStruct2), "");
static_assert(__is_layout_compatible(int, const int), "");
static_assert(__is_layout_compatible(int, volatile int), "");
static_assert(__is_layout_compatible(const int, volatile int), "");
static_assert(__is_layout_compatible(CStruct, CStructWithQualifiers), "");
static_assert(__is_layout_compatible(int[], const volatile int[]), "");
#endif
} // namespace cwg1719
namespace cwg1722 { // cwg1722: 9
#if __cplusplus >= 201103L
void f() {
const auto lambda = [](int x) { return x + 1; };
// Without the DR applied, this static_assert would fail.
static_assert(
noexcept((int (*)(int))(lambda)),
"Lambda-to-function-pointer conversion is expected to be noexcept");
}
#endif
} // namespace cwg1722
namespace cwg1734 { // cwg1734: no
#if __cplusplus >= 201103L
struct A {
A(const A&) = delete;
};
// FIXME: 'A' should not be trivially copyable because the class lacks at least
// one non-deleted copy constructor, move constructor, copy assignment
// operator, or move assignment operator.
static_assert(__is_trivially_copyable(A), "");
#endif
} // namespace cwg1734
// cwg1736 is in cwg1736.cpp
namespace cwg1738 { // cwg1738: sup P0136R1
#if __cplusplus >= 201103L
struct A {
template <typename T>
A(int, T) {}
};
struct B : A {
using A::A;
};
// FIXME: this is well-formed since P0136R1
template B::B(int, double);
// since-cxx11-error@-1 {{explicit instantiation of 'B' does not refer to a function template, variable template, member function, member class, or static data member}}
#endif
} // namespace cwg1738
// cwg1748 is in cwg1748.cpp
namespace cwg1753 { // cwg1753: 11
typedef int T;
struct A { typedef int T; };
namespace B { typedef int T; }
void f(T n) {
n.~T();
n.T::~T();
n.cwg1753::~T();
// expected-error@-1 {{'cwg1753' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T' (aka 'int')}}
n.cwg1753::T::~T();
n.A::~T();
// expected-error@-1 {{the type of object expression ('T' (aka 'int')) does not match the type being destroyed ('A') in pseudo-destructor expression}}
n.A::T::~T();
n.B::~T();
// expected-error@-1 {{'B' does not refer to a type name in pseudo-destructor expression; expected the name of type 'T' (aka 'int')}}
n.B::T::~T();
#if __cplusplus >= 201103L
n.decltype(n)::~T();
// since-cxx11-error@-1 {{'decltype(n)' (aka 'int') is not a class, namespace, or enumeration}}
n.T::~decltype(n)();
// since-cxx11-error@-1 {{expected a class name after '~' to name a destructor}}
n.~decltype(n)(); // OK
#endif
}
} // namespace cwg1753
namespace cwg1756 { // cwg1756: 3.7
#if __cplusplus >= 201103L
// Direct-list-initialization of a non-class object
int a{0};
struct X { operator int(); } x;
int b{x};
#endif
} // namespace cwg1756
namespace cwg1758 { // cwg1758: 3.7
#if __cplusplus >= 201103L
// Explicit conversion in copy/move list initialization
struct X { X(); };
struct Y { explicit operator X(); } y;
X x{y};
struct A {
A() {}
A(const A &) {}
};
struct B {
operator A() { return A(); }
} b;
A a{b};
#endif
} // namespace cwg1758
namespace cwg1762 { // cwg1762: 14
#if __cplusplus >= 201103L
float operator ""_E(const char *);
float operator ""E(const char *);
// since-cxx11-error@-1 {{invalid suffix on literal; C++11 requires a space between literal and identifier}}
// since-cxx11-warning@-2 {{user-defined literal suffixes not starting with '_' are reserved; no literal will invoke this operator}}
#endif
} // namespace cwg1762
// cwg1772 is in cwg177x.cpp
namespace cwg1778 { // cwg1778: 9
// Superseded by P1286R2.
#if __cplusplus >= 201103L
struct A { A() noexcept(true) = default; };
struct B { B() noexcept(false) = default; };
static_assert(noexcept(A()), "");
static_assert(!noexcept(B()), "");
struct C { A a; C() noexcept(false) = default; };
struct D { B b; D() noexcept(true) = default; };
static_assert(!noexcept(C()), "");
static_assert(noexcept(D()), "");
#endif
} // namespace cwg1778
// cwg1779 is in cwg177x.cpp
namespace cwg1794 { // cwg1794: 2.7
// NB: dup 1710
#if __cplusplus >= 201103L
template <template <typename> class Template> struct Internal {
template <typename Arg> using Bind = Template<Arg>;
};
template <template <typename> class Template, typename Arg>
using Instantiate = Template<Arg>;
template <template <typename> class Template, typename Argument>
using Bind = Instantiate<Internal<Template>::template Bind, Argument>;
#endif
} // namespace cwg1794
namespace cwg1780 { // cwg1780: 23
#if __cplusplus >= 201103L
#if __cplusplus >= 201703L
#define CONSTEXPR constexpr
#elif __cplusplus >= 201103L
#define CONSTEXPR
#endif
auto l = []() -> int { return 5; };
using L = decltype(l);
class A {
friend CONSTEXPR auto L::operator()() const -> int;
// since-cxx11-error@-1 {{a member of a lambda should not be the target of a friend declaration}}
};
#undef CONSTEXPR
#if __cplusplus >= 201402L
auto gl = [](auto a) { return 5; }; // #cwg1780-spec
using GL = decltype(gl);
template <>
auto GL::operator()(int a) const {
// since-cxx11-error@-1 {{a member of a lambda should not be explicitly specialized}}
// since-cxx11-note-re@#cwg1780-spec {{{{'\(lambda at .+\)'}} defined here}}
return 6;
}
auto gll = [](auto a) -> int { return 5; }; // #cwg1780-inst
using GLL = decltype(gll);
template auto GLL::operator()<int>(int a) const -> int;
// since-cxx11-error@-1 {{a member of a lambda should not be explicitly instantiated}}
// since-cxx11-note-re@#cwg1780-inst {{{{'\(lambda at .+\)'}} defined here}}
#endif
#endif
} // namespace cwg1780