brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 409350f Raw
44 lines · cpp
1// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s2// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s3// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s4// RUN: %clang_cc1 -fsyntax-only -DNO_PRAGMA -mms-bitfields -verify -triple armv7-apple-darwin9 -std=c++11 %s5 6#ifndef NO_PRAGMA7#pragma ms_struct on8#endif9 10struct A {11  unsigned long a:4;12  unsigned char b;13};14 15struct B : public A {16#ifdef TEST_FOR_ERROR17  // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}18#elif defined(TEST_FOR_WARNING)19  // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}20#endif21  unsigned long c:16;22	int d;23  B();24};25 26static_assert(__builtin_offsetof(B, d) == 12,27  "We can't allocate the bitfield into the padding under ms_struct");28// expected-warning@-2 {{'offsetof' on non-standard-layout type 'B'}}29 30struct C {31#ifdef TEST_FOR_ERROR32  // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}33#elif defined(TEST_FOR_WARNING)34  // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}}35#endif36  virtual void foo();37  long long n;38};39 40static_assert(__builtin_offsetof(C, n) == 8,41              "long long field in ms_struct should be 8-byte aligned");42// expected-warning@-2 {{'offsetof' on non-standard-layout type 'C'}}43 44