2008-01-10 04:58:06 +08:00
|
|
|
// RUN: clang -fsyntax-only -verify -pedantic %s
|
2007-12-05 12:00:10 +08:00
|
|
|
|
|
|
|
struct foo { int a, b; };
|
|
|
|
|
2008-01-09 08:05:37 +08:00
|
|
|
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}}
|
|
|
|
|
2008-01-10 04:58:06 +08:00
|
|
|
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 *', expected 'int'}}
|
|
|
|
|
2008-01-15 02:19:28 +08:00
|
|
|
typedef struct Test {int a;int b;} Test;
|
|
|
|
static Test* ll = &(Test) {0,0};
|
|
|
|
|
2007-12-05 12:00:10 +08:00
|
|
|
extern void fooFunc(struct foo *pfoo);
|
|
|
|
|
|
|
|
int main(int argc, char **argv) {
|
2008-01-10 04:58:06 +08:00
|
|
|
int *l = (int []){x, *p, *p2};
|
2007-12-05 12:00:10 +08:00
|
|
|
fooFunc(&(struct foo){ 1, 2 });
|
|
|
|
}
|
|
|
|
|
2008-01-09 08:05:37 +08:00
|
|
|
|