45 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -verify %s2 3struct ConstCopy {4 ConstCopy();5 ConstCopy(const ConstCopy&);6};7 8struct NonConstCopy {9 NonConstCopy();10 NonConstCopy(NonConstCopy&);11};12 13struct VirtualInheritsNonConstCopy : virtual NonConstCopy { 14 VirtualInheritsNonConstCopy();15 VirtualInheritsNonConstCopy(const VirtualInheritsNonConstCopy&);16};17 18struct ImplicitNonConstCopy1 : NonConstCopy { // expected-note {{candidate constructor}}19 ImplicitNonConstCopy1(); // expected-note {{candidate constructor}}20};21 22struct ImplicitNonConstCopy2 { // expected-note {{candidate constructor}}23 ImplicitNonConstCopy2(); // expected-note {{candidate constructor}}24 NonConstCopy ncc;25};26 27struct ImplicitNonConstCopy3 { // expected-note {{candidate constructor}}28 ImplicitNonConstCopy3(); // expected-note {{candidate constructor}}29 NonConstCopy ncc_array[2][3];30};31 32struct ImplicitNonConstCopy4 : VirtualInheritsNonConstCopy { // expected-note {{candidate constructor}}33 ImplicitNonConstCopy4(); // expected-note {{candidate constructor}}34};35 36void test_non_const_copy(const ImplicitNonConstCopy1 &cincc1,37 const ImplicitNonConstCopy2 &cincc2,38 const ImplicitNonConstCopy3 &cincc3,39 const ImplicitNonConstCopy4 &cincc4) {40 (void)sizeof(ImplicitNonConstCopy1(cincc1)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy1' to 'ImplicitNonConstCopy1'}}41 (void)sizeof(ImplicitNonConstCopy2(cincc2)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy2' to 'ImplicitNonConstCopy2'}}42 (void)sizeof(ImplicitNonConstCopy3(cincc3)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy3' to 'ImplicitNonConstCopy3'}}43 (void)sizeof(ImplicitNonConstCopy4(cincc4)); // expected-error{{no matching conversion for functional-style cast from 'const ImplicitNonConstCopy4' to 'ImplicitNonConstCopy4'}}44}45