[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / SemaCXX / warn-zero-nullptr-cxx20.cpp
blob32b259d00aee23b5eef47b1be7bc0b9926e3ef5d
1 // RUN: %clang_cc1 -fsyntax-only -verify %s -Wzero-as-null-pointer-constant -std=c++20
3 namespace std {
4 class strong_ordering;
6 // Mock how STD defined unspecified parameters for the operators below.
7 struct _CmpUnspecifiedParam {
8 consteval
9 _CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
12 struct strong_ordering {
13 signed char value;
15 friend constexpr bool operator==(strong_ordering v,
16 _CmpUnspecifiedParam) noexcept {
17 return v.value == 0;
19 friend constexpr bool operator<(strong_ordering v,
20 _CmpUnspecifiedParam) noexcept {
21 return v.value < 0;
23 friend constexpr bool operator>(strong_ordering v,
24 _CmpUnspecifiedParam) noexcept {
25 return v.value > 0;
27 friend constexpr bool operator>=(strong_ordering v,
28 _CmpUnspecifiedParam) noexcept {
29 return v.value >= 0;
31 static const strong_ordering equal, greater, less;
33 constexpr strong_ordering strong_ordering::equal = {0};
34 constexpr strong_ordering strong_ordering::greater = {1};
35 constexpr strong_ordering strong_ordering::less = {-1};
36 } // namespace std
38 struct A {
39 int a;
40 constexpr auto operator<=>(const A &other) const = default;
43 void test_cxx_rewritten_binary_ops() {
44 A a1, a2;
45 bool result;
46 result = (a1 < a2);
47 result = (a1 >= a2);
48 int *ptr = 0; // expected-warning{{zero as null pointer constant}}
49 result = (a1 > (ptr == 0 ? a1 : a2)); // expected-warning{{zero as null pointer constant}}
50 result = (a1 > ((a1 > (ptr == 0 ? a1 : a2)) ? a1 : a2)); // expected-warning{{zero as null pointer constant}}