2007-11-01 10:45:17 +08:00
|
|
|
// RUN: clang %s -verify -fsyntax-only
|
|
|
|
|
|
|
|
typedef void (* fp)(void);
|
|
|
|
void foo(void);
|
|
|
|
fp a[1] = { foo };
|
|
|
|
|
2007-11-28 05:35:27 +08:00
|
|
|
int myArray[5] = {1, 2, 3, 4, 5};
|
|
|
|
int *myPointer2 = myArray;
|
|
|
|
int *myPointer = &(myArray[2]);
|
|
|
|
|
2007-12-02 15:47:49 +08:00
|
|
|
|
|
|
|
extern int x;
|
|
|
|
void *g = &x;
|
|
|
|
int *h = &x;
|
|
|
|
|
2008-02-08 08:48:24 +08:00
|
|
|
int test() {
|
|
|
|
int a[10];
|
|
|
|
int b[10] = a; // expected-error {{initialization with "{...}" expected}}
|
2008-11-07 21:01:22 +08:00
|
|
|
int +; // expected-error {{expected identifier or '('}} expected-error {{declarator requires an identifier}} expected-error {{parse error}}
|
2008-02-08 08:48:24 +08:00
|
|
|
}
|
2008-05-04 09:13:36 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR2050
|
|
|
|
struct cdiff_cmd {
|
|
|
|
const char *name;
|
|
|
|
unsigned short argc;
|
|
|
|
int (*handler)();
|
|
|
|
};
|
|
|
|
int cdiff_cmd_open();
|
|
|
|
struct cdiff_cmd commands[] = {
|
|
|
|
{"OPEN", 1, &cdiff_cmd_open }
|
|
|
|
};
|
|
|
|
|
2008-05-21 11:39:11 +08:00
|
|
|
// PR2348
|
|
|
|
static struct { int z; } s[2];
|
|
|
|
int *t = &(*s).z;
|
|
|
|
|
|
|
|
// PR2349
|
|
|
|
short *a2(void)
|
|
|
|
{
|
|
|
|
short int b;
|
2008-08-10 09:58:45 +08:00
|
|
|
static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}}
|
2008-05-21 11:39:11 +08:00
|
|
|
|
|
|
|
return bp;
|
|
|
|
}
|
2008-05-31 02:07:22 +08:00
|
|
|
|
|
|
|
int pbool(void) {
|
|
|
|
typedef const _Bool cbool;
|
|
|
|
_Bool pbool1 = (void *) 0;
|
|
|
|
cbool pbool2 = &pbool;
|
|
|
|
return pbool2;
|
|
|
|
}
|
|
|
|
|
2008-08-19 08:58:40 +08:00
|
|
|
|
|
|
|
// rdar://5870981
|
|
|
|
union { float f; unsigned u; } u = { 1.0f };
|
|
|
|
|
2008-08-26 04:08:27 +08:00
|
|
|
// rdar://6156694
|
|
|
|
int f3(int x) { return x; }
|
|
|
|
typedef void (*vfunc)(void);
|
|
|
|
void *bar = (vfunc) f3;
|
2008-09-02 17:37:00 +08:00
|
|
|
|
|
|
|
// PR2747
|
|
|
|
struct sym_reg {
|
|
|
|
char nc_gpreg;
|
|
|
|
};
|
|
|
|
int sym_fw1a_scr[] = {
|
2008-09-02 18:10:14 +08:00
|
|
|
((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0,
|
|
|
|
8 * ((int)(&((struct sym_reg *)0)->nc_gpreg))
|
2008-09-02 17:37:00 +08:00
|
|
|
};
|
2008-11-03 17:28:22 +08:00
|
|
|
|
|
|
|
// PR3001
|
|
|
|
struct s1 s2 = {
|
|
|
|
.a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}}
|
|
|
|
.b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
|
|
|
|
}
|
|
|
|
|