blob: 42a4e3523ad2f6d4e1ed782b093572c30e690530 [file] [log] [blame]
Nick Lewycky32d4abf2012-01-24 21:28:47 +00001// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify %s
Nick Lewyckyfca84b22012-01-24 21:15:41 +00002
3namespace test1 {
4struct Test {
5 template <typename T>
6 struct SeparateCacheLines {
7 T data;
8 } __attribute__((aligned(256)));
9
10 SeparateCacheLines<int> high_contention_data[10];
11};
12
13void helper() {
14 Test t;
15 new Test; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
16 new Test[10]; // expected-warning {{type 'test1::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
17}
18}
19
20namespace test2 {
21class Test {
22 typedef int __attribute__((aligned(256))) aligned_int;
23 aligned_int high_contention_data[10];
24};
25
26void helper() {
27 Test t;
28 new Test; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
29 new Test[10]; // expected-warning {{type 'test2::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
30}
31}
32
33namespace test3 {
34struct Test {
35 template <typename T>
36 struct SeparateCacheLines {
37 T data;
38 } __attribute__((aligned(256)));
39
40 void* operator new(unsigned long) {
41 return 0;
42 }
43
44 SeparateCacheLines<int> high_contention_data[10];
45};
46
47void helper() {
48 Test t;
49 new Test;
50 new Test[10]; // expected-warning {{type 'test3::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
51}
52}
53
54namespace test4 {
55struct Test {
56 template <typename T>
57 struct SeparateCacheLines {
58 T data;
59 } __attribute__((aligned(256)));
60
61 void* operator new[](unsigned long) {
62 return 0;
63 }
64
65 SeparateCacheLines<int> high_contention_data[10];
66};
67
68void helper() {
69 Test t;
70 new Test; // expected-warning {{type 'test4::Test' requires 256 bytes of alignment and the default allocator only guarantees}}
71 new Test[10];
72}
73}