[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / PCH / cxx2a-compare.cpp
blob019544d28c18471914300465ba8295144b19a5c3
1 // RUN: %clang_cc1 -pedantic-errors -std=c++2a -emit-pch %s -o %t
2 // RUN: %clang_cc1 -pedantic-errors -std=c++2a -include-pch %t -verify %s
3 // RUN: %clang_cc1 -pedantic-errors -std=c++2a -include-pch %t -emit-llvm %s -o -
6 #ifndef HEADER
7 #define HEADER
9 #include "Inputs/std-compare.h"
10 constexpr auto foo() {
11 return (42 <=> 101);
14 inline auto bar(int x) {
15 return (1 <=> x);
18 struct X {
19 int a;
20 friend constexpr std::strong_ordering operator<=>(const X &x, const X &y) {
21 return x.a <=> y.a;
24 constexpr auto baz(int x) {
25 return X{3} < X{x};
28 #else
30 // expected-no-diagnostics
32 static_assert(foo() < 0);
34 auto bar2(int x) {
35 return bar(x);
38 static_assert(!baz(3));
39 static_assert(baz(4));
41 #endif