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