Steve Naroff | c7c6653 | 2007-12-05 04:00:10 +0000 | [diff] [blame] | 1 | // RUN: clang -fsyntax-only -verify %s |
| 2 | |
| 3 | struct foo { int a, b; }; |
| 4 | |
Steve Naroff | f91f972 | 2008-01-09 00:05:37 +0000 | [diff] [blame^] | 5 | static struct foo t = (struct foo){0,0}; // -expected-error {{initializer element is not constant}} |
| 6 | static struct foo t2 = {0,0}; |
| 7 | static struct foo t3 = t2; // -expected-error {{initializer element is not constant}} |
| 8 | static int *p = (int []){2,4}; |
| 9 | static int x = (int){1}; // -expected-error {{initializer element is not constant}} -expected-warning{{braces around scalar initializer}} |
| 10 | |
Steve Naroff | c7c6653 | 2007-12-05 04:00:10 +0000 | [diff] [blame] | 11 | extern void fooFunc(struct foo *pfoo); |
| 12 | |
| 13 | int main(int argc, char **argv) { |
| 14 | fooFunc(&(struct foo){ 1, 2 }); |
| 15 | } |
| 16 | |
Steve Naroff | f91f972 | 2008-01-09 00:05:37 +0000 | [diff] [blame^] | 17 | |