blob: 1f4cdda1a1f5794fc57bba7d138c7b30af88a533 [file] [log] [blame]
Richard Smith3c7ad4e2012-02-08 06:41:34 +00001// RUN: %clang_cc1 -std=c++11 -verify -fsyntax-only %s
2
3struct S {
4 constexpr S(bool b) : b(b) {}
Richard Smith034185c2013-04-21 01:08:50 +00005 constexpr explicit operator bool() const { return b; }
Richard Smith3c7ad4e2012-02-08 06:41:34 +00006 bool b;
7};
8struct T {
Richard Smith034185c2013-04-21 01:08:50 +00009 constexpr operator int() const { return 1; }
Richard Smith3c7ad4e2012-02-08 06:41:34 +000010};
11struct U {
Richard Smith034185c2013-04-21 01:08:50 +000012 constexpr operator int() const { return 1; } // expected-note {{candidate}}
13 constexpr operator long() const { return 0; } // expected-note {{candidate}}
Richard Smith3c7ad4e2012-02-08 06:41:34 +000014};
15
16static_assert(S(true), "");
17static_assert(S(false), "not so fast"); // expected-error {{not so fast}}
18static_assert(T(), "");
19static_assert(U(), ""); // expected-error {{ambiguous}}
Richard Smithf506eaf2012-03-05 23:20:05 +000020
21static_assert(false, L"\x14hi" "!" R"x(")x"); // expected-error {{static_assert failed L"\024hi!\""}}