1 // Test the -cc1 flag. There's no -fno-... option in -cc1 invocations,
2 // just the positive option.
4 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify=OFF %s
5 // RUN: %clang_cc1 -std=c++20 -Wunsafe-buffer-usage -verify=ON %s \
6 // RUN: -fsafe-buffer-usage-suggestions
8 // Test driver flags. Now there's both -f... and -fno-... to worry about.
10 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
11 // RUN: -Xclang -verify=OFF %s
12 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
13 // RUN: -fsafe-buffer-usage-suggestions \
14 // RUN: -Xclang -verify=ON %s
15 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
16 // RUN: -fno-safe-buffer-usage-suggestions \
17 // RUN: -Xclang -verify=OFF %s
19 // In case of driver flags, last flag takes precedence.
21 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
22 // RUN: -fsafe-buffer-usage-suggestions \
23 // RUN: -fno-safe-buffer-usage-suggestions \
24 // RUN: -Xclang -verify=OFF %s
25 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
26 // RUN: -fno-safe-buffer-usage-suggestions \
27 // RUN: -fsafe-buffer-usage-suggestions \
28 // RUN: -Xclang -verify=ON %s
30 // Passing through -Xclang.
32 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
33 // RUN: -Xclang -fsafe-buffer-usage-suggestions \
34 // RUN: -Xclang -verify=ON %s
36 // -Xclang flags take precedence over driver flags.
38 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
39 // RUN: -Xclang -fsafe-buffer-usage-suggestions \
40 // RUN: -fno-safe-buffer-usage-suggestions \
41 // RUN: -Xclang -verify=ON %s
42 // RUN: %clang -fsyntax-only -std=c++20 -Wunsafe-buffer-usage \
43 // RUN: -fno-safe-buffer-usage-suggestions \
44 // RUN: -Xclang -fsafe-buffer-usage-suggestions \
45 // RUN: -Xclang -verify=ON %s
47 [[clang::unsafe_buffer_usage
]] void bar(int *);
49 void foo(int *x
) { // \
50 // ON-warning{{'x' is an unsafe pointer used for buffer access}}
51 // FIXME: Better "OFF" warning?
53 // ON-note {{used in buffer access here}} \
54 // OFF-warning{{unsafe buffer access}} \
55 // OFF-note {{pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions}}
58 // ON-note {{used in pointer arithmetic here}} \
59 // OFF-warning{{unsafe pointer arithmetic}} \
60 // OFF-note {{pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions}}
63 // ON-warning{{function introduces unsafe buffer manipulation}} \
64 // OFF-warning{{function introduces unsafe buffer manipulation}} \
65 // OFF-note {{pass -fsafe-buffer-usage-suggestions to receive code hardening suggestions}}