Home | History | Annotate | Download | only in SemaCXX
      1 // RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s
      2 // RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s
      3 // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s
      4 
      5 #pragma ms_struct on
      6 
      7 struct A {
      8   unsigned long a:4;
      9   unsigned char b;
     10 };
     11 
     12 struct B : public A {
     13 #ifdef TEST_FOR_ERROR
     14   // expected-error@-2 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
     15 #else
     16   // expected-warning@-4 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
     17 #endif
     18   unsigned long c:16;
     19 	int d;
     20   B();
     21 };
     22 
     23 static_assert(__builtin_offsetof(B, d) == 12,
     24   "We can't allocate the bitfield into the padding under ms_struct");
     25 
     26 // rdar://16178895
     27 struct C {
     28 #ifdef TEST_FOR_ERROR
     29   // expected-error@-2 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
     30 #else
     31   // expected-warning@-4 {{ms_struct may not produce MSVC-compatible layouts for classes with base classes or virtual functions}}
     32 #endif
     33   virtual void foo();
     34   long long n;
     35 };
     36 
     37 static_assert(__builtin_offsetof(C, n) == 8,
     38               "long long field in ms_struct should be 8-byte aligned");
     39