1*89a1d03eSRichard // RUN: %check_clang_tidy -std=c++14-or-later %s cppcoreguidelines-pro-bounds-pointer-arithmetic %t 2*89a1d03eSRichard 3*89a1d03eSRichard // Fix PR36489 and detect auto-deduced value correctly. 4*89a1d03eSRichard char *getPtr(); getPtrAuto()5*89a1d03eSRichardauto getPtrAuto() { return getPtr(); } 6*89a1d03eSRichard decltype(getPtr()) getPtrDeclType(); getPtrDeclTypeAuto()7*89a1d03eSRicharddecltype(auto) getPtrDeclTypeAuto() { return getPtr(); } 8*89a1d03eSRichard auto getPtrWithTrailingReturnType() -> char *; 9*89a1d03eSRichard auto_deduction_binary()10*89a1d03eSRichardvoid auto_deduction_binary() { 11*89a1d03eSRichard auto p1 = getPtr() + 1; 12*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: do not use pointer arithmetic 13*89a1d03eSRichard auto p2 = getPtrAuto() + 1; 14*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: do not use pointer arithmetic 15*89a1d03eSRichard auto p3 = getPtrWithTrailingReturnType() + 1; 16*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: do not use pointer arithmetic 17*89a1d03eSRichard auto p4 = getPtr(); 18*89a1d03eSRichard auto *p5 = getPtr(); 19*89a1d03eSRichard p4 = p4 + 1; 20*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use pointer arithmetic 21*89a1d03eSRichard p5 = p5 + 1; 22*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: do not use pointer arithmetic 23*89a1d03eSRichard auto p6 = getPtrDeclType() + 1; 24*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: do not use pointer arithmetic 25*89a1d03eSRichard auto p7 = getPtrDeclTypeAuto() + 1; 26*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:34: warning: do not use pointer arithmetic 27*89a1d03eSRichard auto *p8 = getPtrDeclType() + 1; 28*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: do not use pointer arithmetic 29*89a1d03eSRichard auto *p9 = getPtrDeclTypeAuto() + 1; 30*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:35: warning: do not use pointer arithmetic 31*89a1d03eSRichard } 32*89a1d03eSRichard auto_deduction_subscript()33*89a1d03eSRichardvoid auto_deduction_subscript() { 34*89a1d03eSRichard char p1 = getPtr()[2]; 35*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 36*89a1d03eSRichard auto p2 = getPtr()[3]; 37*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 38*89a1d03eSRichard 39*89a1d03eSRichard char p3 = getPtrAuto()[4]; 40*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 41*89a1d03eSRichard auto p4 = getPtrAuto()[5]; 42*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 43*89a1d03eSRichard 44*89a1d03eSRichard char p5 = getPtrWithTrailingReturnType()[6]; 45*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 46*89a1d03eSRichard auto p6 = getPtrWithTrailingReturnType()[7]; 47*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 48*89a1d03eSRichard 49*89a1d03eSRichard auto p7 = getPtrDeclType()[8]; 50*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 51*89a1d03eSRichard auto p8 = getPtrDeclTypeAuto()[9]; 52*89a1d03eSRichard // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: do not use pointer arithmetic 53*89a1d03eSRichard } 54