blob: 80219a906209e3f4bea1faf57f17379094fb3154 [file] [log] [blame]
Douglas Gregor6bc574d2010-06-30 00:20:43 +00001// RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s
2
3struct ValueInt
4{
5 ValueInt(int v = 0) : ValueLength(v) {}
6 operator int () const { return ValueLength; } // expected-note 3{{conversion to integral type 'int' declared here}}
7private:
8 int ValueLength;
9};
10
11enum E { e };
12struct ValueEnum {
13 operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}}
14};
15
16struct ValueBoth : ValueInt, ValueEnum { };
17
18struct IndirectValueInt : ValueInt { };
19struct TwoValueInts : ValueInt, IndirectValueInt { };
20
21void test() {
22 (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++0x extension}}
23 (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++0x extension}}
24 (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}}
25
26 (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}}
27}