// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: throw expression throws a pointer; it should throw a non-pointer value instead [misc-throw-by-value-catch-by-reference]
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
}
}
voidcatchByValue(){
try{
testThrowFunc();
}catch(logic_errore){
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
}
}
voidcatchByReference(){
try{
testThrowFunc();
}catch(logic_error&e){
}
}
voidcatchByConstReference(){
try{
testThrowFunc();
}catch(constlogic_error&e){
}
}
voidcatchTypedef(){
try{
testThrowFunc();
}catch(logic_ptr){
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]
}
}
voidcatchAll(){
try{
testThrowFunc();
}catch(...){
}
}
voidcatchLiteral(){
try{
testThrowFunc();
}catch(constchar*){
}catch(constwchar_t*){
// disabled for now until it is clear
// how to enable them in the test
//} catch (const char16_t*) {
//} catch (const char32_t*) {
}
}
// catching fundamentals should not warn
voidcatchFundamental(){
try{
testThrowFunc();
}catch(int){
}catch(double){
}catch(unsignedlong){
}
}
structTrivialType{
doublex;
doubley;
};
voidcatchTrivial(){
try{
testThrowFunc();
}catch(TrivialType){
}
}
typedeflogic_error&fine;
voidadditionalTests(){
try{
}catch(inti){// ok
throwi;// ok
}catch(finee){// ok
throwe;// ok
}catch(logic_error*e){
// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: catch handler catches a pointer value; should throw a non-pointer value and catch by reference instead [misc-throw-by-value-catch-by-reference]