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

255 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 std {
__extension__ typedef __SIZE_TYPE__ size_t;
template<typename T> struct initializer_list {
const T *p; size_t n;
initializer_list(const T *p, size_t n);
};
} // namespace std
namespace cwg930 { // cwg930: 2.7
#if __cplusplus >= 201103L
static_assert(alignof(int[]) == alignof(int), "");
static_assert(alignof(int[][2]) == alignof(int[2]), "");
#endif
} // namespace cwg930
namespace cwg941 { // cwg941: 3.9
#if __cplusplus >= 201103L
template <typename>
void f() = delete;
template<> void f<int>() {}
template <typename>
struct A {
void f() = delete;
template <typename>
void g() = delete;
};
template<> void A<int>::f() {}
template<> template<> void A<int>::g<int>() {}
struct B {
template <typename>
void f() = delete;
};
template<> void B::f<int>() {}
#endif
} // namespace cwg941
namespace cwg948 { // cwg948: 3.7
#if __cplusplus >= 201103L
class A {
public:
constexpr A(int v) : v(v) { }
constexpr operator int() const { return v; }
private:
int v;
};
constexpr int id(int x)
{
return x;
}
void f() {
if (constexpr int i = id(101)) { }
switch (constexpr int i = id(2)) { default: break; case 2: break; }
for (; constexpr int i = id(0); ) { }
while (constexpr int i = id(0)) { }
if (constexpr A i = 101) { }
switch (constexpr A i = 2) { default: break; case 2: break; }
for (; constexpr A i = 0; ) { }
while (constexpr A i = 0) { }
}
#endif
} // namespace cwg948
namespace cwg950 { // cwg950: 3.1
#if __cplusplus >= 201103L
struct A {};
struct B : decltype(A()) {};
template <typename T>
struct C : decltype(T()) {};
#endif
} // namespace cwg950
namespace cwg952 { // cwg952: 2.8
namespace example1 {
struct A {
typedef int I; // #cwg952-I
};
struct B : private A { // #cwg952-B
};
struct C : B {
void f();
I i1;
// expected-error@-1 {{'I' is a private member of 'cwg952::example1::A'}}
// expected-note@#cwg952-B {{constrained by private inheritance here}}
// expected-note@#cwg952-I {{member is declared here}}
struct D {
I i2;
// expected-error@-1 {{'I' is a private member of 'cwg952::example1::A'}}
// expected-note@#cwg952-B {{constrained by private inheritance here}}
// expected-note@#cwg952-I {{member is declared here}}
void g();
};
};
void C::f() {
I i3;
// expected-error@-1 {{'I' is a private member of 'cwg952::example1::A'}}
// expected-note@#cwg952-B {{constrained by private inheritance here}}
// expected-note@#cwg952-I {{member is declared here}}
}
void C::D::g() {
I i4;
// expected-error@-1 {{'I' is a private member of 'cwg952::example1::A'}}
// expected-note@#cwg952-B {{constrained by private inheritance here}}
// expected-note@#cwg952-I {{member is declared here}}
}
} // namespace example1
namespace example2 {
struct A {
protected:
static int x;
};
struct B : A {
friend int get(B) { return x; }
};
} // namespace example2
} // namespace cwg952
namespace cwg960 { // cwg960: 3.0
struct a {};
class A {
#if __cplusplus >= 201103L
// Check lvalue ref vs rvalue ref vs pointer.
virtual a& rvalue_ref();
virtual a&& lvalue_ref();
virtual a& rvalue_vs_lvalue_ref(); // #cwg960-A-rvalue_vs_lvalue_ref
virtual a&& lvalue_vs_rvalue_ref(); // #cwg960-A-lvalue_vs_rvalue_ref
virtual a& rvalue_ref_vs_pointer(); // #cwg960-A-rvalue_ref_vs_pointer
virtual a* pointer_vs_rvalue_ref(); // #cwg960-A-pointer_vs_rvalue_ref
virtual a&& lvalue_ref_vs_pointer(); // #cwg960-A-lvalue_ref_vs_pointer
virtual a* pointer_vs_lvalue_ref(); // #cwg960-A-pointer_vs_lvalue_ref
#endif
};
class B : A {
#if __cplusplus >= 201103L
// Check lvalue ref vs rvalue ref vs pointer.
a& rvalue_ref() override;
a&& lvalue_ref() override;
a&& rvalue_vs_lvalue_ref() override;
// since-cxx11-error@-1 {{virtual function 'rvalue_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a &')}}
// since-cxx11-note@#cwg960-A-rvalue_vs_lvalue_ref {{overridden virtual function is here}}
a& lvalue_vs_rvalue_ref() override;
// since-cxx11-error@-1 {{virtual function 'lvalue_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a &&')}}
// since-cxx11-note@#cwg960-A-lvalue_vs_rvalue_ref {{overridden virtual function is here}}
a* rvalue_ref_vs_pointer() override;
// since-cxx11-error@-1 {{virtual function 'rvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &')}}
// since-cxx11-note@#cwg960-A-rvalue_ref_vs_pointer {{overridden virtual function is here}}
a& pointer_vs_rvalue_ref() override;
// since-cxx11-error@-1 {{virtual function 'pointer_vs_rvalue_ref' has a different return type ('a &') than the function it overrides (which has return type 'a *')}}
// since-cxx11-note@#cwg960-A-pointer_vs_rvalue_ref {{overridden virtual function is here}}
a* lvalue_ref_vs_pointer() override;
// since-cxx11-error@-1 {{virtual function 'lvalue_ref_vs_pointer' has a different return type ('a *') than the function it overrides (which has return type 'a &&')}}
// since-cxx11-note@#cwg960-A-lvalue_ref_vs_pointer {{overridden virtual function is here}}
a&& pointer_vs_lvalue_ref() override;
// since-cxx11-error@-1 {{virtual function 'pointer_vs_lvalue_ref' has a different return type ('a &&') than the function it overrides (which has return type 'a *')}}
// since-cxx11-note@#cwg960-A-pointer_vs_lvalue_ref {{overridden virtual function is here}}
#endif
};
} // namespace cwg960
namespace cwg974 { // cwg974: 3.3
#if __cplusplus >= 201103L
void test() {
auto lam = [](int x = 42) { return x; };
}
#endif
} // namespace cwg974
namespace cwg977 { // cwg977: 2.7
enum E { e = E() }; // #cwg977-E
#if !defined(_WIN32) || defined(__MINGW32__)
// expected-error@#cwg977-E {{invalid use of incomplete type 'E'}}
// expected-note@#cwg977-E {{definition of 'cwg977::E' is not complete until the closing '}'}}
#endif
#if __cplusplus >= 201103L
enum E2 : int { e2 = E2() };
enum struct E3 { e = static_cast<int>(E3()) };
enum struct E4 : int { e = static_cast<int>(E4()) };
#endif
} // namespace cwg977
namespace cwg988 { // cwg988: 2.7
#if __cplusplus >= 201103L
void f(int& lvalue_ref, int&& rvalue_ref) {
static_assert(__is_same(decltype(lvalue_ref)&, int&), "");
static_assert(__is_same(decltype(lvalue_ref)&&, int&), "");
static_assert(__is_same(decltype(rvalue_ref)&, int&), "");
static_assert(__is_same(decltype(rvalue_ref)&&, int&&), "");
}
#endif
} // namespace cwg988
namespace cwg990 { // cwg990: 3.5
#if __cplusplus >= 201103L
struct A { // #cwg990-A
A(std::initializer_list<int>); // #cwg990-A-init-list
};
struct B {
A a;
};
B b1 { };
B b2 { 1 };
// since-cxx11-error@-1 {{no viable conversion from 'int' to 'A'}}
// since-cxx11-note@#cwg990-A {{candidate constructor (the implicit copy constructor) not viable: no known conversion from 'int' to 'const A &' for 1st argument}}
// since-cxx11-note@#cwg990-A {{candidate constructor (the implicit move constructor) not viable: no known conversion from 'int' to 'A &&' for 1st argument}}
// since-cxx11-note@#cwg990-A-init-list {{candidate constructor not viable: no known conversion from 'int' to 'std::initializer_list<int>' for 1st argument}}
B b3 { { 1 } };
struct C {
C();
C(int);
C(std::initializer_list<int>) = delete; // #cwg990-deleted
};
C c1[3] { 1 }; // ok
C c2[3] { 1, {2} };
// since-cxx11-error@-1 {{call to deleted constructor of 'C'}}
// since-cxx11-note@#cwg990-deleted {{'C' has been explicitly marked deleted here}}
struct D {
D();
D(std::initializer_list<int>);
D(std::initializer_list<double>);
};
D d{};
#endif
} // namespace cwg990