1 // RUN: %clang_cc1 -std=c++20 -Wno-all -Wunsafe-buffer-usage \
2 // RUN: -fsafe-buffer-usage-suggestions \
3 // RUN: -fblocks -verify %s
5 // RUN: %clang -x c++ -frtti -fsyntax-only -fblocks %s 2>&1 | FileCheck --allow-empty %s
6 // RUN: %clang_cc1 -std=c++11 -fblocks %s 2>&1 | FileCheck --allow-empty %s
7 // RUN: %clang_cc1 -std=c++20 -fblocks %s 2>&1 | FileCheck --allow-empty %s
8 // CHECK-NOT: [-Wunsafe-buffer-usage]
16 using size_t = __typeof(sizeof(int));
26 void uneval_context_fix() {
27 auto p
= new int[10]; // expected-warning{{'p' is an unsafe pointer used for buffer access}}
29 // Warn on the following DREs
30 _Generic(1, int: p
[2], float: 3); // expected-note{{used in buffer access here}}
32 // Do not warn for following DREs
34 foo(sizeof(q
[1]), // no-note
35 sizeof(decltype(q
[1]))); // no-note
36 __typeof(q
[5]) x
; // no-note
37 int *r
= (int *)malloc(sizeof(q
[5])); // no-note
38 int y
= sizeof(q
[5]); // no-note
39 __is_pod(__typeof(q
[5])); // no-note
40 __is_trivially_constructible(__typeof(q
[5]), decltype(q
[5])); // no-note
41 _Generic(q
[1], int: 2, float: 3); // no-note
42 _Generic(1, int: 2, float: q
[3]); // no-note
43 decltype(q
[2]) var
= y
; // no-note
44 noexcept(q
[2]); // no-note
45 typeid(q
[3]); // no-note