1- // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++98 -pedantic-errors -verify=expected %s
1+ // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++98 -pedantic-errors -verify=expected,cxx98 %s
22// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -pedantic-errors -verify=expected %s
33// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++14 -pedantic-errors -verify=expected %s
44// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -pedantic-errors -verify=expected %s
55// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -pedantic-errors -verify=expected %s
66// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -pedantic-errors -verify=expected,since-cxx23 %s
77// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++2c -pedantic-errors -verify=expected,since-cxx23,since-cxx26 %s
88
9+ #if __cplusplus == 199711L
10+ #define static_assert (...) __extension__ _Static_assert (__VA_ARGS__)
11+ // cxx98-error@-1 {{variadic macros are a C99 feature}}
12+ #endif
13+
14+ #if __cplusplus == 199711L
15+ #define __enable_constant_folding (x ) (__builtin_constant_p(x) ? (x) : (x))
16+ #else
17+ #define __enable_constant_folding
18+ #endif
19+
20+ namespace std {
21+ #if __cplusplus >= 202002L
22+ struct strong_ordering {
23+ int n;
24+ constexpr operator int () const { return n; }
25+ static const strong_ordering less, equal, greater;
26+ };
27+ constexpr strong_ordering strong_ordering::less{-1 },
28+ strong_ordering::equal{0 }, strong_ordering::greater{1 };
29+ #endif
30+ } // namespace std
31+
932namespace cwg2718 { // cwg2718: 2.7
1033struct B {};
1134struct D ;
@@ -18,6 +41,27 @@ void f(B b) {
1841struct D : B {};
1942} // namespace cwg2718
2043
44+ namespace cwg2749 { // cwg2749: 20
45+
46+ extern int x[2 ];
47+ struct Y {
48+ int i;
49+ int j;
50+ };
51+ extern Y y[2 ];
52+
53+ static_assert (__enable_constant_folding(static_cast <void *>(&x[0 ]) < static_cast <void *>(&x[1 ])), " " );
54+ static_assert (__enable_constant_folding(static_cast <void *>(&y[0 ].i) < static_cast <void *>(&y[0 ].j)), " " );
55+ static_assert (__enable_constant_folding(static_cast <void *>(&y[0 ].j) < static_cast <void *>(&y[1 ].i)), " " );
56+
57+ #if __cplusplus >= 202002L
58+ static_assert ((static_cast <void *>(&x[0 ]) <=> static_cast <void *>(&x[1 ])) == std::strong_ordering::less);
59+ static_assert ((static_cast <void *>(&y[0 ].i) <=> static_cast <void *>(&y[0 ].j)) == std::strong_ordering::less);
60+ static_assert ((static_cast <void *>(&y[0 ].j) <=> static_cast <void *>(&y[1 ].i)) == std::strong_ordering::less);
61+ #endif
62+
63+ } // namespace cwg2749
64+
2165namespace cwg2759 { // cwg2759: 19
2266#if __cplusplus >= 201103L
2367
0 commit comments