Daniel Dunbar | 8d7d6e9 | 2009-02-21 23:45:41 +0000 | [diff] [blame] | 1 | // RUN: clang -arch i386 -fsyntax-only -verify %s |
Eli Friedman | 578a972 | 2009-02-22 06:45:27 +0000 | [diff] [blame^] | 2 | |
| 3 | #include <stdint.h> |
| 4 | |
Anders Carlsson | 1a86b33 | 2007-10-17 00:52:43 +0000 | [diff] [blame] | 5 | static int f = 10; |
Chris Lattner | d880363 | 2008-08-10 01:58:45 +0000 | [diff] [blame] | 6 | static int b = f; // expected-error {{initializer element is not a compile-time constant}} |
Eli Friedman | c1cc6dc | 2008-05-30 18:14:48 +0000 | [diff] [blame] | 7 | |
Eli Friedman | 578a972 | 2009-02-22 06:45:27 +0000 | [diff] [blame^] | 8 | float r = (float) &r; // expected-error {{initializer element is not a compile-time constant}} |
| 9 | intptr_t s = (intptr_t) &s; |
Eli Friedman | c1cc6dc | 2008-05-30 18:14:48 +0000 | [diff] [blame] | 10 | _Bool t = &t; |
Nuno Lopes | 8395081 | 2009-02-02 16:07:41 +0000 | [diff] [blame] | 11 | |
| 12 | |
| 13 | union bar { |
| 14 | int i; |
| 15 | }; |
| 16 | |
| 17 | struct foo { |
| 18 | unsigned ptr; |
| 19 | }; |
| 20 | |
| 21 | union bar u[1]; |
Eli Friedman | 578a972 | 2009-02-22 06:45:27 +0000 | [diff] [blame^] | 22 | struct foo x = {(intptr_t) u}; // no-error |
Nuno Lopes | ff77645 | 2009-02-02 22:57:15 +0000 | [diff] [blame] | 23 | struct foo y = {(char) u}; // expected-error {{initializer element is not a compile-time constant}} |