29 lines · c
1// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify -fms-compatibility2// RUN: %clang_cc1 %s -triple i686-pc-win32 -fsyntax-only -verify3// expected-no-diagnostics4 5typedef __typeof__(sizeof(0)) size_t;6 7#ifdef _MSC_VER8#ifndef _CRT_USE_BUILTIN_OFFSETOF9#error _CRT_USE_BUILTIN_OFFSETOF should be predefined in MSVC-compatible modes.10#endif11#else12#ifdef _CRT_USE_BUILTIN_OFFSETOF13#error _CRT_USE_BUILTIN_OFFSETOF should not be predefined in non-MSVC-compatible modes.14#endif15#endif16 17#if defined _MSC_VER && !defined _CRT_USE_BUILTIN_OFFSETOF18#ifdef __cplusplus19#define offsetof(s,m) ((::size_t)&reinterpret_cast<char const volatile&>((((s*)0)->m)))20#else21#define offsetof(s,m) ((size_t)&(((s*)0)->m))22#endif23#else24#define offsetof(s,m) __builtin_offsetof(s,m)25#endif26 27struct S { int a; };28_Static_assert(offsetof(struct S, a) == 0, "");29