xref: /llvm-project/clang-tools-extra/test/clang-tidy/checkers/cert/mem57-cpp-cpp17.cpp (revision 12babb08189cc1ca84d7fbb33d3c9726583b2e5a)
189a1d03eSRichard // RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
2*12babb08SJustin Bogner // RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
3*12babb08SJustin Bogner // RUN: clang-tidy -checks='-*,cert-mem57-cpp' --extra-arg=-Wno-unused-variable --warnings-as-errors='*' %s -- -std=c++17 -faligned-allocation
489a1d03eSRichard 
589a1d03eSRichard struct alignas(128) Vector {
689a1d03eSRichard   char Elems[128];
789a1d03eSRichard };
889a1d03eSRichard 
f()989a1d03eSRichard void f() {
1089a1d03eSRichard   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]
1189a1d03eSRichard   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]
1289a1d03eSRichard }
13