diff options
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp')
-rw-r--r-- | clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp b/clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp new file mode 100644 index 00000000000..676cb642d4a --- /dev/null +++ b/clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp @@ -0,0 +1,12 @@ +// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t +// RUN: clang-tidy --extra-arg='-std=c++17' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s +// RUN: clang-tidy --extra-arg='-std=c++2a' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s + +struct alignas(32) Vector { + char Elems[32]; +}; + +void f() { + auto *V1 = new Vector; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp] + auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp] +} |