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

74 lines
2.0 KiB
C++

// RUN: %clang_cc1 -std=c++17 %s -verify
// RUN: %clang_cc1 -std=c++20 %s -verify
// RUN: %clang_cc1 -std=c++20 %s -verify -Wc++17-compat -DCOMPAT
//
// RUN: %clang_cc1 -std=c++17 %s -E -o - | FileCheck %s --check-prefix=CXX17
// RUN: %clang_cc1 -std=c++20 %s -E -o - | FileCheck %s --check-prefix=CXX20
namespace N {
struct A {};
void operator<=(A, A);
#if __cplusplus > 201703L
void operator<=>(A, A);
#ifdef COMPAT
// expected-warning@-2 {{'<=>' operator is incompatible with C++ standards before C++20}}
#endif
#endif
template<auto> struct X {};
X<operator<=>
#if __cplusplus <= 201703L
// expected-warning@-2 {{'<=>' is a single token in C++20; add a space to avoid a change in behavior}}
#else
>
#endif
#ifdef COMPAT
// expected-warning@-7 {{'<=>' operator is incompatible with C++ standards before C++20}}
#endif
x;
}
// <=> can be formed by pasting other comparison operators.
#if __cplusplus > 201703L
#define STR(x) #x
#define STR_EXPANDED(x) STR(x)
#define PASTE(x, y) x ## y
constexpr char a[] = STR_EXPANDED(PASTE(<, =>));
constexpr char b[] = STR_EXPANDED(PASTE(<=, >));
static_assert(__builtin_strcmp(a, "<=>") == 0);
static_assert(__builtin_strcmp(b, "<=>") == 0);
#endif
// -E must not accidentally form a <=> token.
// CXX17: preprocess1: < =>
// CXX17: preprocess2: <=>
// CXX17: preprocess3: < =>
// CXX17: preprocess4: <=>=
// CXX17: preprocess5: <=>>
// CXX17: preprocess6: <=>>=
// CXX17: preprocess7: <=>
// CXX17: preprocess8: <=>=
//
// CXX20: preprocess1: < =>
// CXX20: preprocess2: <= >
// CXX20: preprocess3: < =>
// CXX20: preprocess4: <= >=
// CXX20: preprocess5: <= >>
// CXX20: preprocess6: <= >>=
// CXX20: preprocess7: <=>
// CXX20: preprocess8: <=>=
#define ID(x) x
[[some_vendor::some_attribute( // expected-warning {{unknown attribute}}
preprocess1: ID(<)ID(=>),
preprocess2: ID(<=)ID(>),
preprocess3: ID(<)ID(=)ID(>),
preprocess4: ID(<=)ID(>=),
preprocess5: ID(<=)ID(>>),
preprocess6: ID(<=)ID(>>=),
preprocess7: ID(<=>) // expected-warning 0-1{{'<=>'}}
preprocess8: ID(<=>=) // expected-warning 0-1{{'<=>'}}
)]];