static-init.c revision d7d5f0223bd30dfd618762349c6209dd1d5ea3e6
1// RUN: clang-cc -arch i386 -fsyntax-only -verify %s
2
3#include <stdint.h>
4
5static int f = 10;
6static int b = f; // expected-error {{initializer element is not a compile-time constant}}
7
8float r  = (float) &r; // expected-error {{initializer element is not a compile-time constant}}
9intptr_t s = (intptr_t) &s;
10_Bool t = &t;
11
12
13union bar {
14	int i;
15};
16
17struct foo {
18	unsigned ptr;
19};
20
21union bar u[1];
22struct foo x = {(intptr_t) u}; // no-error
23struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}}
24