struct-decl.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // RUN: %clang_cc1 -fsyntax-only -verify %s
  2. // PR3459
  3. struct bar {
  4. char n[1];
  5. };
  6. struct foo {
  7. char name[(int)&((struct bar *)0)->n];
  8. char name2[(int)&((struct bar *)0)->n - 1]; //expected-error{{'name2' declared as an array with a negative size}}
  9. };
  10. // PR3430
  11. struct s {
  12. struct st {
  13. int v;
  14. } *ts;
  15. };
  16. struct st;
  17. int foo() {
  18. struct st *f;
  19. return f->v + f[0].v;
  20. }
  21. // PR3642, PR3671
  22. struct pppoe_tag {
  23. short tag_type;
  24. char tag_data[];
  25. };
  26. struct datatag {
  27. struct pppoe_tag hdr; //expected-warning{{field 'hdr' with variable sized type 'struct pppoe_tag' not at the end of a struct or class is a GNU extension}}
  28. char data;
  29. };
  30. // PR4092
  31. struct s0 {
  32. char a; // expected-note {{previous declaration is here}}
  33. char a; // expected-error {{duplicate member 'a'}}
  34. };
  35. struct s0 f0(void) {}
  36. // <rdar://problem/8177927> - This previously triggered an assertion failure.
  37. struct x0 {
  38. unsigned int x1;
  39. };
  40. // rdar://problem/9150338
  41. static struct test1 { // expected-warning {{'static' ignored on this declaration}}
  42. int x;
  43. };
  44. const struct test2 { // expected-warning {{'const' ignored on this declaration}}
  45. int x;
  46. };
  47. inline struct test3 { // expected-error {{'inline' can only appear on functions}}
  48. int x;
  49. };
  50. struct hiding_1 {};
  51. struct hiding_2 {};
  52. void test_hiding() {
  53. struct hiding_1 *hiding_1();
  54. extern struct hiding_2 *hiding_2;
  55. struct hiding_1 *p = hiding_1();
  56. struct hiding_2 *q = hiding_2;
  57. }
  58. struct PreserveAttributes {};
  59. typedef struct __attribute__((noreturn)) PreserveAttributes PreserveAttributes_t; // expected-warning {{'noreturn' attribute only applies to functions and methods}}