static-init.c 691 B

123456789101112131415161718192021222324
  1. // RUN: %clang_cc1 -fsyntax-only -verify -Wno-bool-conversion %s
  2. typedef __typeof((int*) 0 - (int*) 0) intptr_t;
  3. static int f = 10;
  4. static int b = f; // expected-error {{initializer element is not a compile-time constant}}
  5. float r = (float) (intptr_t) &r; // expected-error {{initializer element is not a compile-time constant}}
  6. intptr_t s = (intptr_t) &s;
  7. _Bool t = &t;
  8. union bar {
  9. int i;
  10. };
  11. struct foo {
  12. short ptr;
  13. };
  14. union bar u[1];
  15. struct foo x = {(intptr_t) u}; // expected-error {{initializer element is not a compile-time constant}}
  16. struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
  17. intptr_t z = (intptr_t) u; // no-error