xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp (revision 12babb08189cc1ca84d7fbb33d3c9726583b2e5a)
1 // RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
2 // RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
3 // RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
4 
5 struct alignas(128) Vector {
6   char Elems[128];
7 };
8 
f()9 void f() {
10   auto *V1 = new Vector;        // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp]
11   auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment {{[0-9]+}} but the over-aligned type being allocated requires alignment 128 [cert-mem57-cpp]
12 }
13