[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / SemaCXX / warn-new-overaligned.cpp
blobc5495e312dcc6fc121fb14f7e25f6b3101aba473
1 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
3 namespace test1 {
4 struct Test {
5 template <typename T>
6 struct SeparateCacheLines {
7 T data;
8 } __attribute__((aligned(256)));
10 SeparateCacheLines<int> high_contention_data[10];
13 void helper() {
14 Test t;
15 new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
16 new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
20 namespace test2 {
21 class Test {
22 typedef int __attribute__((aligned(256))) aligned_int;
23 aligned_int high_contention_data[10];
26 void helper() {
27 Test t;
28 new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
29 new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
33 namespace test3 {
34 struct Test {
35 template <typename T>
36 struct SeparateCacheLines {
37 T data;
38 } __attribute__((aligned(256)));
40 void* operator new(unsigned long) {
41 return 0; // expected-warning {{'operator new' should not return a null pointer unless it is declared 'throw()'}}
44 SeparateCacheLines<int> high_contention_data[10];
47 void helper() {
48 Test t;
49 new Test;
50 new Test[10]; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
54 namespace test4 {
55 struct Test {
56 template <typename T>
57 struct SeparateCacheLines {
58 T data;
59 } __attribute__((aligned(256)));
61 void* operator new[](unsigned long) {
62 return 0; // expected-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}}
65 SeparateCacheLines<int> high_contention_data[10];
68 void helper() {
69 Test t;
70 new Test; // expected-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}
71 new Test[10];