Files
TheRock/compiler/amd-llvm/clang/test/SemaCXX/cxx2a-compat.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

68 lines
2.5 KiB
C++

// RUN: %clang_cc1 -fsyntax-only -std=c++17 -Wc++20-compat-pedantic -verify %s
// RUN: %clang_cc1 -fsyntax-only -std=c++20 -pedantic -verify %s
struct A { // expected-note 0+{{candidate}}
A() = default; // expected-note 0+{{candidate}}
int x, y;
};
A a1 = {1, 2};
#if __cplusplus <= 201703L
// expected-warning@-2 {{aggregate initialization of type 'A' with user-declared constructors is incompatible with C++20}}
#else
// expected-error@-4 {{no matching constructor}}
#endif
A a2 = {};
struct B : A { A a; };
B b1 = {{}, {}}; // ok
B b2 = {1, 2, 3, 4};
#if __cplusplus <= 201703L
// expected-warning@-2 2{{aggregate initialization of type 'A' with user-declared constructors is incompatible with C++20}}
#else
// expected-error@-4 2{{no viable conversion from 'int' to 'A'}}
#endif
// Essentially any use of a u8 string literal in C++<=17 is broken by C++20.
// Just warn on all such string literals.
struct string { string(const char*); }; // expected-note 0+{{candidate}}
char u8arr[] = u8"hello";
const char *u8ptr = "wo" u8"rld";
string u8str = u8"test" u8"test";
#if __cplusplus <= 201703L
// expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
// expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
// expected-warning@-4 {{type of UTF-8 string literal will change}} expected-note@-4 {{remove 'u8' prefix}}
#else
// expected-error@-7 {{cannot initialize a variable of type 'const char *' with an lvalue of type 'const char8_t[6]'}}
// expected-error@-7 {{no viable conversion from 'const char8_t[9]' to 'string'}}
#endif
template<bool b>
struct C {
explicit(C)(int);
};
#if __cplusplus <= 201703L
// expected-warning@-3 {{this expression will be parsed as explicit(bool) in C++20}}
#if defined(__cpp_conditional_explicit)
#error "the feature test macro __cpp_conditional_explicit isn't correct"
#endif
#else
// expected-error@-8 {{does not refer to a value}}
// expected-error@-9 {{expected member name or ';'}}
// expected-error@-10 {{expected ')'}}
// expected-note@-12 {{declared here}}
// expected-note@-12 {{to match this '('}}
#if !defined(__cpp_conditional_explicit) || __cpp_conditional_explicit != 201806L
#error "the feature test macro __cpp_conditional_explicit isn't correct"
#endif
#endif
auto l = []() consteval {};
int consteval();
#if __cplusplus <= 201703L
// expected-warning@-3 {{'consteval' is a keyword in C++20}}
// expected-error@-4 {{expected body of lambda expression}}
#else
// expected-error@-5 {{expected unqualified-id}}
#endif