brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 48aa015 Raw
38 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=gnu++98 %s2// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++98 %s3// RUN: %clang_cc1 -fsyntax-only -pedantic -verify -std=c++11 %s4 5struct ValueInt6{7  ValueInt(int v = 0) : ValueLength(v) {}8  operator int () const { return ValueLength; } // expected-note 3{{conversion to integral type 'int' declared here}}9private:10  int ValueLength;11};12 13enum E { e };14struct ValueEnum {15  operator E() const; // expected-note{{conversion to enumeration type 'E' declared here}}16};17 18struct ValueBoth : ValueInt, ValueEnum { };19 20struct IndirectValueInt : ValueInt { };21struct TwoValueInts : ValueInt, IndirectValueInt { }; // expected-warning{{direct base 'ValueInt' is inaccessible due to ambiguity:\n    struct TwoValueInts -> ValueInt\n    struct TwoValueInts -> IndirectValueInt -> ValueInt}}22 23 24void test() {25  (void)new int[ValueInt(10)];26#if __cplusplus <= 199711L // C++03 or earlier modes27  // expected-warning@-2{{implicit conversion from array size expression of type 'ValueInt' to integral type 'int' is a C++11 extension}}28#endif29 30  (void)new int[ValueEnum()];31#if __cplusplus <= 199711L32// expected-warning@-2{{implicit conversion from array size expression of type 'ValueEnum' to enumeration type 'E' is a C++11 extension}}33#endif34  (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