// Explicit member declarations behave as in C++11.
namespacen3323_example{
template<classT>classzero_init{
public:
zero_init():val(static_cast<T>(0)){}
zero_init(Tval):val(val){}
operatorT&(){returnval;}//@13
operatorT()const{returnval;}//@14
private:
Tval;
};
voidDelete(){
zero_init<int*>p;
p=newint(7);
deletep;//@23
delete(p+0);
delete+p;
}
voidSwitch(){
zero_init<int>i;
i=7;
switch(i){}// @31
switch(i+0){}
switch(+i){}
}
}
#ifdef CXX1Y
#else
//expected-error@23 {{ambiguous conversion of delete expression of type 'zero_init<int *>' to a pointer}}
//expected-note@13 {{conversion to pointer type 'int *'}}
//expected-note@14 {{conversion to pointer type 'int *'}}
//expected-error@31 {{multiple conversions from switch condition type 'zero_init<int>' to an integral or enumeration type}}
//expected-note@13 {{conversion to integral type 'int'}}
//expected-note@14 {{conversion to integral type 'int'}}
#endif
namespaceextended_examples{
structA0{
operatorint();// matching and viable
};
structA1{
operatorint()&&;// matching and not viable
};
structA2{
operatorfloat();// not matching
};
structA3{
template<typenameT>operatorT();// not matching (ambiguous anyway)
};
structA4{
template<typenameT>operatorint();// not matching (ambiguous anyway)
};
structB1{
operatorint()&&;// @70
operatorint();// @71 -- duplicate declaration with different qualifier is not allowed
};
structB2{
operatorint()&&;// matching but not viable
operatorfloat();// not matching
};
voidfoo(A0a0,A1a1,A2a2,A3a3,A4a4,B2b2){
switch(a0){}
switch(a1){}// @81 -- fails for different reasons
switch(a2){}// @82
switch(a3){}// @83
switch(a4){}// @84
switch(b2){}// @85 -- fails for different reasons
}
}
//expected-error@71 {{cannot overload a member function without a ref-qualifier with a member function with ref-qualifier '&&'}}
//expected-note@70 {{previous declaration is here}}
//expected-error@82 {{statement requires expression of integer type ('extended_examples::A2' invalid)}}
//expected-error@83 {{statement requires expression of integer type ('extended_examples::A3' invalid)}}
//expected-error@84 {{statement requires expression of integer type ('extended_examples::A4' invalid)}}
#ifdef CXX1Y
//expected-error@81 {{statement requires expression of integer type ('extended_examples::A1' invalid)}}
//expected-error@85 {{statement requires expression of integer type ('extended_examples::B2' invalid)}}
#else
//expected-error@81 {{cannot initialize object parameter of type 'extended_examples::A1' with an expression of type 'extended_examples::A1'}}
//expected-error@85 {{cannot initialize object parameter of type 'extended_examples::B2' with an expression of type 'extended_examples::B2'}}
#endif
namespaceextended_examples_cxx1y{
structA1{// leads to viable match in C++1y, and no viable match in C++11
operatorint()&&;// matching but not viable
template<typenameT>operatorT();// In C++1y: matching and viable, since disambiguated by L.100
};
structA2{// leads to ambiguity in C++1y, and no viable match in C++11
operatorint()&&;// matching but not viable
template<typenameT>operatorint();// In C++1y: matching but ambiguous (disambiguated by L.105).
};
structB1{// leads to one viable match in both cases
operatorint();// matching and viable
template<typenameT>operatorT();// In C++1y: matching and viable, since disambiguated by L.110
};
structB2{// leads to one viable match in both cases
operatorint();// matching and viable
template<typenameT>operatorint();// In C++1y: matching but ambiguous, since disambiguated by L.115
};
structC{// leads to no match in both cases
operatorfloat();// not matching
template<typenameT>operatorT();// In C++1y: not matching, nor viable.
};
structD{// leads to viable match in C++1y, and no viable match in C++11
operatorint()&&;// matching but not viable
operatorfloat();// not matching
template<typenameT>operatorT();// In C++1y: matching and viable, since disambiguated by L.125
};
voidfoo(A1a1,A2a2,B1b1,B2b2,Cc,Dd){
switch(a1){}// @138 -- should presumably call templated conversion operator to convert to int.
switch(a2){}// @139
switch(b1){}
switch(b2){}
switch(c){}// @142
switch(d){}// @143
}
}
//expected-error@142 {{statement requires expression of integer type ('extended_examples_cxx1y::C' invalid)}}
#ifdef CXX1Y
//expected-error@139 {{statement requires expression of integer type ('extended_examples_cxx1y::A2' invalid)}}
#else
//expected-error@138 {{cannot initialize object parameter of type 'extended_examples_cxx1y::A1' with an expression of type 'extended_examples_cxx1y::A1'}}
//expected-error@139 {{cannot initialize object parameter of type 'extended_examples_cxx1y::A2' with an expression of type 'extended_examples_cxx1y::A2'}}
//expected-error@143 {{cannot initialize object parameter of type 'extended_examples_cxx1y::D' with an expression of type 'extended_examples_cxx1y::D'}}
//expected-error@168 {{ambiguous conversion of array size expression of type 'extended_examples_array_bounds::Foo' to an integral or enumeration type}}
//expected-note@162 {{conversion to integral type 'size_t'}}
//expected-note@163 {{conversion to integral type 'unsigned short' declared here}}