[X86] Move getGFNICtrlMask before CTLZ/CTTZ lowering. NFC.
[llvm-project.git] / clang / test / SemaCXX / warn-unsafe-buffer-usage-warning-unevaluated-context.cpp
blobcbf91f270bf3eb4a182d08d9bc48cb8968ddc9bd
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]
11 namespace std {
12 class type_info;
13 class bad_cast;
14 class bad_typeid;
16 using size_t = __typeof(sizeof(int));
17 void *malloc(size_t);
19 void foo(int v) {
22 void foo(int *p){}
24 void foo(int, 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
33 auto q = new int[10];
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