1*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s 2*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s 3*67e74705SXin Li // RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s 4*67e74705SXin Li 5*67e74705SXin Li struct ValueInt 6*67e74705SXin Li { ValueIntValueInt7*67e74705SXin Li ValueInt(int v = 0) : ValueLength(v) {} operator intValueInt8*67e74705SXin Li operator int () const { return ValueLength; } // expected-note 3{{conversion to integral type 'int' declared here}} 9*67e74705SXin Li private: 10*67e74705SXin Li int ValueLength; 11*67e74705SXin Li }; 12*67e74705SXin Li 13*67e74705SXin Li enum E { e }; 14*67e74705SXin Li struct ValueEnum { 15*67e74705SXin Li operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}} 16*67e74705SXin Li }; 17*67e74705SXin Li 18*67e74705SXin Li struct ValueBoth : ValueInt, ValueEnum { }; 19*67e74705SXin Li 20*67e74705SXin Li struct IndirectValueInt : ValueInt { }; 21*67e74705SXin Li struct TwoValueInts : ValueInt, IndirectValueInt { }; // expected-warning{{direct base 'ValueInt' is inaccessible due to ambiguity:\n struct TwoValueInts -> struct ValueInt\n struct TwoValueInts -> struct IndirectValueInt -> struct ValueInt}} 22*67e74705SXin Li 23*67e74705SXin Li test()24*67e74705SXin Livoid test() { 25*67e74705SXin Li (void)new int[ValueInt(10)]; 26*67e74705SXin Li #if __cplusplus <= 199711L // C++03 or earlier modes 27*67e74705SXin Li // expected-warning@-2{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}} 28*67e74705SXin Li #endif 29*67e74705SXin Li 30*67e74705SXin Li (void)new int[ValueEnum()]; 31*67e74705SXin Li #if __cplusplus <= 199711L 32*67e74705SXin Li // expected-warning@-2{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}} 33*67e74705SXin Li #endif 34*67e74705SXin Li (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}} 35*67e74705SXin Li 36*67e74705SXin Li (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}} 37*67e74705SXin Li } 38