blob: 72586b13c48da954f8e5efcd2a3e430d71bebd98 [file] [log] [blame]
Chris Lattner4ef8dd62007-11-01 02:45:17 +00001// RUN: clang %s -verify -fsyntax-only
2
3typedef void (* fp)(void);
4void foo(void);
5fp a[1] = { foo };
6
Chris Lattner4cc62712007-11-27 21:35:27 +00007int myArray[5] = {1, 2, 3, 4, 5};
8int *myPointer2 = myArray;
9int *myPointer = &(myArray[2]);
10
Chris Lattnerd411e042007-12-02 07:47:49 +000011
12extern int x;
13void *g = &x;
14int *h = &x;
15
Eli Friedmana312ce22008-02-08 00:48:24 +000016int test() {
17int a[10];
Sebastian Redl9f4d8632008-11-22 22:39:41 +000018int b[10] = a; // expected-error {{initialization with '{...}' expected}}
Chris Lattner1f6f54b2008-11-11 06:13:16 +000019int +; // expected-error {{expected identifier or '('}} expected-error {{parse error}}
Eli Friedmana312ce22008-02-08 00:48:24 +000020}
Chris Lattnerbe34ac62008-05-04 01:13:36 +000021
22
23// PR2050
24struct cdiff_cmd {
25 const char *name;
26 unsigned short argc;
27 int (*handler)();
28};
29int cdiff_cmd_open();
30struct cdiff_cmd commands[] = {
31 {"OPEN", 1, &cdiff_cmd_open }
32};
33
Eli Friedman97c0a392008-05-21 03:39:11 +000034// PR2348
35static struct { int z; } s[2];
36int *t = &(*s).z;
37
38// PR2349
39short *a2(void)
40{
41 short int b;
Chris Lattnerd8803632008-08-10 01:58:45 +000042 static short *bp = &b; // expected-error {{initializer element is not a compile-time constant}}
Eli Friedman97c0a392008-05-21 03:39:11 +000043
44 return bp;
45}
Eli Friedmanf8f873d2008-05-30 18:07:22 +000046
47int pbool(void) {
48 typedef const _Bool cbool;
49 _Bool pbool1 = (void *) 0;
50 cbool pbool2 = &pbool;
51 return pbool2;
52}
53
Chris Lattnerd5bac572008-08-19 00:58:40 +000054
55// rdar://5870981
56union { float f; unsigned u; } u = { 1.0f };
57
Daniel Dunbar1e465df2008-08-25 20:08:27 +000058// rdar://6156694
59int f3(int x) { return x; }
60typedef void (*vfunc)(void);
61void *bar = (vfunc) f3;
Eli Friedmanb529d832008-09-02 09:37:00 +000062
63// PR2747
64struct sym_reg {
65 char nc_gpreg;
66};
67int sym_fw1a_scr[] = {
Nuno Lopes67c86012008-09-02 10:10:14 +000068 ((int)(&((struct sym_reg *)0)->nc_gpreg)) & 0,
69 8 * ((int)(&((struct sym_reg *)0)->nc_gpreg))
Eli Friedmanb529d832008-09-02 09:37:00 +000070};
Chris Lattnere2f56192008-11-03 09:28:22 +000071
72// PR3001
73struct s1 s2 = {
74 .a = sizeof(struct s3), // expected-error {{invalid application of 'sizeof'}}
75 .b = bogus // expected-error {{use of undeclared identifier 'bogus'}}
76}
77