brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.3 KiB · 52e58c2 Raw
81 lines · cpp
1// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify=precxx17 %std_cxx98-14 %s2// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -Wover-aligned -verify=cxx17 %std_cxx17- %s3 4namespace test1 {5struct Test {6  template <typename T>7  struct SeparateCacheLines {8    T data;9  } __attribute__((aligned(256)));10 11  SeparateCacheLines<int> high_contention_data[10];12};13 14void helper() {15  Test t;16  new Test;  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}17  new Test[10];  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}18}19}20 21namespace test2 {22struct S {23  char c[256];24};25 26class Test {27  typedef S __attribute__((aligned(256))) alignedS;28  alignedS high_contention_data[10];29};30 31void helper() {32  Test t;33  new Test;  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}34  new Test[10];  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}35}36}37 38namespace test3 {39struct Test {40  template <typename T>41  struct SeparateCacheLines {42    T data;43  } __attribute__((aligned(256)));44 45  void* operator new(unsigned long) {46    return 0; // precxx17-warning {{'operator new' should not return a null pointer unless it is declared 'throw()'}} \47                 cxx17-warning {{'operator new' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}48  }49 50  SeparateCacheLines<int> high_contention_data[10];51};52 53void helper() {54  Test t;55  new Test;56  new Test[10];  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}57}58}59 60namespace test4 {61struct Test {62  template <typename T>63  struct SeparateCacheLines {64    T data;65  } __attribute__((aligned(256)));66 67  void* operator new[](unsigned long) {68    return 0; // precxx17-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()'}} \69                 cxx17-warning {{'operator new[]' should not return a null pointer unless it is declared 'throw()' or 'noexcept'}}70  }71 72  SeparateCacheLines<int> high_contention_data[10];73};74 75void helper() {76  Test t;77  new Test;  // precxx17-warning {{type 'Test' requires 256 bytes of alignment and the default allocator only guarantees}}78  new Test[10];79}80}81