]> granicus.if.org Git - clang/blob - test/Sema/compound-literal.c
Fix PR1992 by computing the right type for string literals, which
[clang] / test / Sema / compound-literal.c
1 // RUN: clang -fsyntax-only -verify -pedantic %s
2
3 struct foo { int a, b; };
4
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
11 static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not constant}}
12 static int *p3 = (int []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char [2]', expected 'int'}}
13
14 typedef struct Test {int a;int b;} Test;
15 static Test* ll = &(Test) {0,0};
16
17 extern void fooFunc(struct foo *pfoo);
18
19 int main(int argc, char **argv) {
20  int *l = (int []){x, *p, *p2};
21  fooFunc(&(struct foo){ 1, 2 });
22 }
23
24