1 // The original example from https://github.com/llvm/llvm-project/issues/90501 2 3 // Test without PCH 4 // RUN: %clang_cc1 -Wno-unused-value -Wunsafe-buffer-usage -std=c++20 -include %s -verify %s 5 // Test with PCH 6 // RUN: %clang_cc1 -Wno-unused-value -std=c++20 -emit-pch -o %t %s 7 // RUN: %clang_cc1 -Wno-unused-value -Wunsafe-buffer-usage -std=c++20 -include-pch %t -verify %s 8 9 #ifndef A_H 10 #define A_H 11 a(int * s)12int a(int *s) { 13 s[2]; // <- expected warning here 14 #pragma clang unsafe_buffer_usage begin 15 return s[1]; 16 #pragma clang unsafe_buffer_usage end 17 } 18 19 #else 20 // expected-warning@-7{{unsafe buffer access}} 21 // expected-note@-8{{pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions}} main()22int main() { 23 int s[] = {1, 2, 3}; 24 return a(s); 25 } 26 27 #endif 28