pragma-ms_struct.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // RUN: %clang_cc1 -fsyntax-only -fms-extensions -verify -triple x86_64-apple-darwin9 %s
  2. #pragma ms_struct on
  3. #pragma ms_struct off
  4. #pragma ms_struct reset
  5. #pragma ms_struct // expected-warning {{incorrect use of '#pragma ms_struct on|off' - ignored}}
  6. #pragma ms_struct on top of spaghetti // expected-warning {{extra tokens at end of '#pragma ms_struct' - ignored}}
  7. struct foo
  8. {
  9. int a;
  10. int b;
  11. char c;
  12. };
  13. struct {
  14. unsigned long bf_1 : 12;
  15. unsigned long : 0;
  16. unsigned long bf_2 : 12;
  17. } __attribute__((__ms_struct__)) t1;
  18. struct S {
  19. double __attribute__((ms_struct)) d; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
  20. unsigned long bf_1 : 12;
  21. unsigned long : 0;
  22. unsigned long bf_2 : 12;
  23. } __attribute__((ms_struct)) t2;
  24. enum
  25. {
  26. A = 0,
  27. B,
  28. C
  29. } __attribute__((ms_struct)) e1; // expected-warning {{'ms_struct' attribute only applies to struct or union}}
  30. // rdar://10513599
  31. #pragma ms_struct on
  32. typedef struct
  33. {
  34. void *pv;
  35. int l;
  36. } Foo;
  37. typedef struct
  38. {
  39. void *pv1;
  40. Foo foo;
  41. unsigned short fInited : 1;
  42. void *pv2;
  43. } PackOddity;
  44. #pragma ms_struct off
  45. static int arr[sizeof(PackOddity) == 40 ? 1 : -1];
  46. struct __declspec(ms_struct) bad { // expected-warning {{__declspec attribute 'ms_struct' is not supported}}
  47. };