summaryrefslogtreecommitdiffstats
path: root/clang/test/Sema/compound-literal.c
blob: 83657245f501c23c0833acf78efeb82d4e41a40c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// RUN: clang -fsyntax-only -verify -pedantic %s

struct foo { int a, b; };

static struct foo t = (struct foo){0,0}; // -expected-error {{initializer element is not constant}}
static struct foo t2 = {0,0}; 
static struct foo t3 = t2; // -expected-error {{initializer element is not constant}}
static int *p = (int []){2,4}; 
static int x = (int){1}; // -expected-error {{initializer element is not constant}} -expected-warning{{braces around scalar initializer}}

static int *p2 = (int []){2,x}; // -expected-error {{initializer element is not constant}}
static int *p3 = (int []){2,"x"}; // -expected-warning {{incompatible pointer to integer conversion initializing 'char [2]', expected 'int'}}

typedef struct Test {int a;int b;} Test;
static Test* ll = &(Test) {0,0};

extern void fooFunc(struct foo *pfoo);

int main(int argc, char **argv) {
 int *l = (int []){x, *p, *p2};
 fooFunc(&(struct foo){ 1, 2 });
}


OpenPOWER on IntegriCloud