Files
TheRock/compiler/amd-llvm/clang/test/CXX/dcl.decl/dcl.fct.def/dcl.fct.def.default/p1.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

89 lines
4.2 KiB
C++

// RUN: %clang_cc1 -verify=expected,pre20 %s -std=c++11
// RUN: %clang_cc1 -verify=expected,pre20 %s -std=c++17
// RUN: %clang_cc1 -verify=expected %s -std=c++20
// A function that is explicitly defaulted shall
struct A {
// -- be a special member function [C++20: or a comparison operator function],
A(int) = default;
#if __cplusplus <= 201703L
// expected-error@-2 {{only special member functions may be defaulted}}
#else
// expected-error@-4 {{only special member functions and comparison operators may be defaulted}}
#endif
A(A) = default; // expected-error {{must pass its first argument by reference}}
void f(A) = default; // expected-error-re {{only special member functions{{( and comparison operators)?}} may be defaulted}}
bool operator==(const A&) const = default; // pre20-warning {{defaulted comparison operators are a C++20 extension}}
bool operator!=(const A&) const = default; // pre20-warning {{defaulted comparison operators are a C++20 extension}}
bool operator<(const A&) const = default; // pre20-error {{only special member functions may be defaulted}}
bool operator>(const A&) const = default; // pre20-error {{only special member functions may be defaulted}}
bool operator<=(const A&) const = default; // pre20-error {{only special member functions may be defaulted}}
bool operator>=(const A&) const = default; // pre20-error {{only special member functions may be defaulted}}
bool operator<=>(const A&) const = default; // pre20-error 1+{{}} pre20-warning {{'<=>' is a single token in C++20}}
A operator+(const A&) const = default; // expected-error-re {{only special member functions{{( and comparison operators)?}} may be defaulted}}
// -- have the same declared function type as if it had been implicitly
// declared
void operator=(const A &) = default; // expected-error {{must return 'A &'}}
A(...) = default;
A(const A &, ...) = default;
A &operator=(const A&) const = default;
A &operator=(A) const = default; // expected-error {{must be an lvalue refe}}
#if __cplusplus <= 201703L
// expected-error@-5 {{cannot be variadic}}
// expected-error@-5 {{cannot be variadic}}
// expected-error@-5 {{may not have 'const'}}
// expected-error@-5 {{may not have 'const'}}
#else
// expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit default constructor}}
// expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit copy constructor}}
// expected-warning@-10 {{implicitly deleted}} expected-note@-10 {{declared type does not match the type of an implicit copy assignment}}
#endif
// (except for possibly differing ref-qualifiers
A &operator=(A &&) & = default;
// and except that in the case of a copy constructor or copy assignment
// operator, the parameter type may be "reference to non-const T")
A(A &) = default;
A &operator=(A &) = default;
// -- not have default arguments
A(double = 0.0) = default; // expected-error {{cannot have default arguments}}
A(const A & = 0) = default; // expected-error {{cannot have default arguments}}
};
struct A2 {
A2(...);
A2(const A2 &, ...);
A2 &operator=(const A2&) const;
};
A2::A2(...) = default; // expected-error {{cannot be variadic}}
A2::A2(const A2&, ...) = default; // expected-error {{cannot be variadic}}
A2 &A2::operator=(const A2&) const = default; // expected-error {{may not have 'const'}}
struct B {
B(B&);
B &operator=(B&);
};
struct C : B {
C(const C&) = default;
C &operator=(const C&) = default;
#if __cplusplus <= 201703L
// expected-error@-3 {{is const, but a member or base requires it to be non-const}}
// expected-error@-3 {{is const, but a member or base requires it to be non-const}}
#else
// expected-warning@-6 {{implicitly deleted}} expected-note@-6 {{type does not match}}
// expected-warning@-6 {{implicitly deleted}} expected-note@-6 {{type does not match}}
#endif
};
struct D : B { // expected-note 2{{base class}}
D(const D&);
D &operator=(const D&);
};
D::D(const D&) = default; // expected-error {{would delete}} expected-error {{is const, but}}
D &D::operator=(const D&) = default; // expected-error {{would delete}} expected-error {{is const, but}}