| Richard Smith | 3c7ad4e | 2012-02-08 06:41:34 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s |
| 2 | |
| 3 | struct S { |
| 4 | constexpr S(bool b) : b(b) {} |
| Richard Smith | 034185c | 2013-04-21 01:08:50 +0000 | [diff] [blame] | 5 | constexpr explicit operator bool() const { return b; } |
| Richard Smith | 3c7ad4e | 2012-02-08 06:41:34 +0000 | [diff] [blame] | 6 | bool b; |
| 7 | }; |
| 8 | struct T { |
| Richard Smith | 034185c | 2013-04-21 01:08:50 +0000 | [diff] [blame] | 9 | constexpr operator int() const { return 1; } |
| Richard Smith | 3c7ad4e | 2012-02-08 06:41:34 +0000 | [diff] [blame] | 10 | }; |
| 11 | struct U { |
| Richard Smith | 034185c | 2013-04-21 01:08:50 +0000 | [diff] [blame] | 12 | constexpr operator int() const { return 1; } // expected-note {{candidate}} |
| 13 | constexpr operator long() const { return 0; } // expected-note {{candidate}} |
| Richard Smith | 3c7ad4e | 2012-02-08 06:41:34 +0000 | [diff] [blame] | 14 | }; |
| 15 | |
| 16 | static_assert(S(true), ""); |
| 17 | static_assert(S(false), "not so fast"); // expected-error {{not so fast}} |
| 18 | static_assert(T(), ""); |
| 19 | static_assert(U(), ""); // expected-error {{ambiguous}} |
| Richard Smith | f506eaf | 2012-03-05 23:20:05 +0000 | [diff] [blame] | 20 | |
| 21 | static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed L"\024hi!\""}} |