blob: 12ee9f9300ac32d105cce4ca11278b714f252ccb [file] [log] [blame]
Steve Naroff92590f92008-01-09 20:58:06 +00001// RUN: clang -fsyntax-only -verify -pedantic %s
Steve Naroffc7c66532007-12-05 04:00:10 +00002
3struct foo { int a, b; };
4
Steve Narofff91f9722008-01-09 00:05:37 +00005static struct foo t = (struct foo){0,0}; // -expected-error {{initializer element is not constant}}
6static struct foo t2 = {0,0};
7static struct foo t3 = t2; // -expected-error {{initializer element is not constant}}
8static int *p = (int []){2,4};
9static int x = (int){1}; // -expected-error {{initializer element is not constant}} -expected-warning{{braces around scalar initializer}}
10
Steve Naroff92590f92008-01-09 20:58:06 +000011static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not constant}}
12static int *p3 = (int []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char *', expected 'int'}}
13
Steve Naroffc7c66532007-12-05 04:00:10 +000014extern void fooFunc(struct foo *pfoo);
15
16int main(int argc, char **argv) {
Steve Naroff92590f92008-01-09 20:58:06 +000017 int *l = (int []){x, *p, *p2};
Steve Naroffc7c66532007-12-05 04:00:10 +000018 fooFunc(&(struct foo){ 1, 2 });
19}
20
Steve Narofff91f9722008-01-09 00:05:37 +000021