static-init.c revision ff77645058c5d56b4f3273e27f7492c78288825e
11a86b33c1870fee08d281c9f07ac1280195a7faeAnders Carlsson// RUN: clang -fsyntax-only -verify %s 21a86b33c1870fee08d281c9f07ac1280195a7faeAnders Carlssonstatic int f = 10; 3d8803632d248a360a040ff03eff1162988058036Chris Lattnerstatic int b = f; // expected-error {{initializer element is not a compile-time constant}} 4c1cc6dccd42b91a2ebb397415940da91dbf36103Eli Friedman 5839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopesfloat r = (float) &r; // FIXME: should give an error: ptr value used where a float was expected 6c1cc6dccd42b91a2ebb397415940da91dbf36103Eli Friedmanlong long s = (long long) &s; 7c1cc6dccd42b91a2ebb397415940da91dbf36103Eli Friedman_Bool t = &t; 8839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes 9839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes 10839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopesunion bar { 11839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes int i; 12839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes}; 13839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes 14839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopesstruct foo { 15839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes unsigned ptr; 16839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes}; 17839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopes 18839508150a7a595b6172217eeddc4d024fc201c5Nuno Lopesunion bar u[1]; 19ff77645058c5d56b4f3273e27f7492c78288825eNuno Lopesstruct foo x = {(long) u}; // no-error 20ff77645058c5d56b4f3273e27f7492c78288825eNuno Lopesstruct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}} 21