1 // RUN: %clang_cc1 -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
3 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
13 struct ExplicitConvToBool
{
14 explicit operator bool(); // expected-note {{explicit}}
15 #if __cplusplus <= 199711L // C++03 or earlier modes
16 // expected-warning@-2{{explicit conversion functions are a C++11 extension}}
20 void test_conv_to_bool(ConvToBool ctb
, ConvToInt cti
, ExplicitConvToBool ecb
) {
45 void accepts_bool(bool) { } // expected-note{{candidate function}}
47 struct ExplicitConvToRef
{
48 explicit operator int&(); // expected-note {{explicit}}
49 #if (__cplusplus <= 199711L) // C++03 or earlier modes
50 // expected-warning@-2{{explicit conversion functions are a C++11 extension}}
54 void test_explicit_bool(ExplicitConvToBool ecb
) {
56 bool b2
= ecb
; // expected-error{{no viable conversion from 'ExplicitConvToBool' to 'bool'}}
57 accepts_bool(ecb
); // expected-error{{no matching function for call to}}
60 void test_explicit_conv_to_ref(ExplicitConvToRef ecr
) {
61 int& i1
= ecr
; // expected-error{{no viable conversion from 'ExplicitConvToRef' to 'int'}}
68 explicit operator A
&(); // expected-note {{explicit}}
69 #if __cplusplus <= 199711L // C++03 or earlier modes
70 // expected-warning@-2{{explicit conversion functions are a C++11 extension}}
72 operator B
&(); // expected-note{{candidate}}
75 void test_copy_init_conversions(C c
) {
76 A
&a
= c
; // expected-error{{no viable conversion from 'C' to 'A'}}