1- // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++98 -verify=expected %s
1+ // RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++98 -Wgnu-folding-constant - verify=expected %s
22// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -verify=expected %s
33// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++14 -verify=expected %s
44// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++17 -verify=expected %s
55// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++20 -verify=expected %s
66// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++23 -verify=expected,since-cxx23 %s
77// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++2c -verify=expected,since-cxx23,since-cxx26 %s
88
9+ namespace std {
10+ #if __cplusplus >= 202002L
11+ struct strong_ordering {
12+ int n;
13+ constexpr operator int () const { return n; }
14+ static const strong_ordering less, equal, greater;
15+ };
16+ constexpr strong_ordering strong_ordering::less{-1 },
17+ strong_ordering::equal{0 }, strong_ordering::greater{1 };
18+ #endif
19+ }
20+
921namespace cwg2718 { // cwg2718: 2.7
1022struct B {};
1123struct D ;
@@ -18,6 +30,38 @@ void f(B b) {
1830struct D : B {};
1931} // namespace cwg2718
2032
33+ namespace cwg2749 { // cwg2749: 19
34+
35+ extern int x[2 ];
36+ struct Y {
37+ int i;
38+ int j;
39+ };
40+ extern Y y[2 ];
41+
42+ #if __cplusplus >= 201103L
43+ static_assert (static_cast <void *>(x + 0 ) < static_cast <void *>(x + 1 ), " " );
44+ static_assert (static_cast <void *>(&y[0 ].i) < static_cast <void *>(&y[0 ].j), " " );
45+ static_assert (static_cast <void *>(&y[0 ].j) < static_cast <void *>(&y[1 ].i), " " );
46+ #else
47+ enum X {
48+ a = static_cast <void *>(x + 0 ) < static_cast <void *>(x + 1 ),
49+ // expected-warning@-1 {{expression is not an integral constant expression; folding it to a constant is a GNU extension}}
50+ b = static_cast <void *>(&y[0 ].i ) < static_cast <void *>(&y[0 ].j ),
51+ // expected-warning@-1 {{expression is not an integral constant expression; folding it to a constant is a GNU extension}}
52+ c = static_cast <void *>(&y[0 ].j ) < static_cast <void *>(&y[1 ].i )
53+ // expected-warning@-1 {{expression is not an integral constant expression; folding it to a constant is a GNU extension}}
54+ };
55+ #endif
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