diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2012-01-24 21:15:41 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2012-01-24 21:15:41 +0000 |
| commit | 411fc65b4566e32ef2539de377648a30acf64e94 (patch) | |
| tree | 074e43440ab3774200fecb5fb00440b2d2e7f8ea /clang/test/SemaCXX/warn-new-overaligned-3.cpp | |
| parent | 0bba00dc2f4925bc32dd431f2972576b6d376a65 (diff) | |
| download | bcm5719-llvm-411fc65b4566e32ef2539de377648a30acf64e94.tar.gz bcm5719-llvm-411fc65b4566e32ef2539de377648a30acf64e94.zip | |
Add a new warning, -Wover-aligned, which detects attempts to use the default
allocator to construct an object which declares more alignment than the default
allocator actually provides. Fixes PR9527!
llvm-svn: 148857
Diffstat (limited to 'clang/test/SemaCXX/warn-new-overaligned-3.cpp')
| -rw-r--r-- | clang/test/SemaCXX/warn-new-overaligned-3.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/test/SemaCXX/warn-new-overaligned-3.cpp b/clang/test/SemaCXX/warn-new-overaligned-3.cpp new file mode 100644 index 00000000000..f3b0cb7dd18 --- /dev/null +++ b/clang/test/SemaCXX/warn-new-overaligned-3.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -Wover-aligned %s -isystem %S/Inputs -verify + +// This test ensures that we still get the warning even if we #include <new> +// where the header here simulates <new>. +#include <warn-new-overaligned-3.h> + +struct Test { + template <typename T> + struct SeparateCacheLines { + T data; + } __attribute__((aligned(256))); + + SeparateCacheLines<int> high_contention_data[10]; +}; + +void helper() { + Test t; + new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} + new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}} +} |

