Douglas Gregor | 6bc574d | 2010-06-30 00:20:43 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -pedantic -verify %s |
| 2 | |
| 3 | struct 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}} |
| 7 | private: |
| 8 | int ValueLength; |
| 9 | }; |
| 10 | |
| 11 | enum E { e }; |
| 12 | struct ValueEnum { |
| 13 | operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}} |
| 14 | }; |
| 15 | |
| 16 | struct ValueBoth : ValueInt, ValueEnum { }; |
| 17 | |
| 18 | struct IndirectValueInt : ValueInt { }; |
Stephen Hines | 0e2c34f | 2015-03-23 12:09:02 -0700 | [diff] [blame] | 19 | 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}} |
| 20 | |
Douglas Gregor | 6bc574d | 2010-06-30 00:20:43 +0000 | [diff] [blame] | 21 | |
| 22 | void test() { |
Douglas Gregor | b3df138 | 2011-10-12 19:26:40 +0000 | [diff] [blame] | 23 | (void)new int[ValueInt(10)]; // expected-warning{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}} |
| 24 | (void)new int[ValueEnum()]; // expected-warning{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}} |
Douglas Gregor | 6bc574d | 2010-06-30 00:20:43 +0000 | [diff] [blame] | 25 | (void)new int[ValueBoth()]; // expected-error{{ambiguous conversion of array size expression of type 'ValueBoth' to an integral or enumeration type}} |
| 26 | |
| 27 | (void)new int[TwoValueInts()]; // expected-error{{ambiguous conversion of array size expression of type 'TwoValueInts' to an integral or enumeration type}} |
| 28 | } |