Eric Fiselier | 0683c0e | 2018-05-07 21:07:10 +0000 | [diff] [blame^] | 1 | // Test diagnostics for ill-formed STL <compare> headers. |
| 2 | |
| 3 | // RUN: %clang_cc1 -triple x86_64-apple-darwin -fcxx-exceptions -fsyntax-only -pedantic -verify -Wsign-compare -std=c++2a %s |
| 4 | |
| 5 | void compare_not_found_test() { |
| 6 | // expected-error@+1 {{cannot deduce return type of 'operator<=>' because type partial_ordering was not found; include <compare>}} |
| 7 | (void)(0.0 <=> 42.123); |
| 8 | } |
| 9 | |
| 10 | namespace std { |
| 11 | inline namespace __1 { |
| 12 | struct partial_ordering; // expected-note {{forward declaration}} |
| 13 | } |
| 14 | } // namespace std |
| 15 | |
| 16 | auto compare_incomplete_test() { |
| 17 | // expected-error@+1 {{incomplete type 'std::partial_ordering' where a complete type is required}} |
| 18 | return (-1.2 <=> 123.0); |
| 19 | } |
| 20 | |
| 21 | namespace std { |
| 22 | inline namespace __1 { |
| 23 | struct partial_ordering { |
| 24 | unsigned value; |
| 25 | }; |
| 26 | } // namespace __1 |
| 27 | } // namespace std |
| 28 | |
| 29 | auto missing_member_test() { |
| 30 | // expected-error@+1 {{standard library implementation of 'std::partial_ordering' is not supported; member 'equivalent' is missing}} |
| 31 | return (1.0 <=> 1.0); |
| 32 | } |
| 33 | |
| 34 | namespace std { |
| 35 | inline namespace __1 { |
| 36 | struct strong_ordering { |
| 37 | long long value; |
| 38 | static const strong_ordering equivalent; // expected-note {{declared here}} |
| 39 | }; |
| 40 | } // namespace __1 |
| 41 | } // namespace std |
| 42 | |
| 43 | auto test_non_constexpr_var() { |
| 44 | // expected-error@+1 {{standard library implementation of 'std::strong_ordering' is not supported; member 'equivalent' does not have expected form}} |
| 45 | return (1 <=> 0); |
| 46 | } |
| 47 | |
| 48 | namespace std { |
| 49 | inline namespace __1 { |
| 50 | struct strong_equality { |
| 51 | char value = 0; |
| 52 | constexpr strong_equality() = default; |
| 53 | // non-trivial |
| 54 | constexpr strong_equality(strong_equality const &other) : value(other.value) {} |
| 55 | }; |
| 56 | } // namespace __1 |
| 57 | } // namespace std |
| 58 | |
| 59 | struct Class {}; |
| 60 | using MemPtr = void (Class::*)(int); |
| 61 | |
| 62 | auto test_non_trivial(MemPtr LHS, MemPtr RHS) { |
| 63 | // expected-error@+1 {{standard library implementation of 'std::strong_equality' is not supported; the type is not trivially copyable}} |
| 64 | return LHS <=> RHS; |
| 65 | } |