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