1 // RUN: clang-cc %s -emit-llvm -o -
2 
3 // PR1895
4 // sizeof function
5 int zxcv(void);
6 int x=sizeof(zxcv);
7 int y=__alignof__(zxcv);
8 
9 
10 void *test(int *i) {
11  short a = 1;
12  i += a;
13  i + a;
14  a + i;
15 }
16 
17 _Bool test2b;
18 int test2() { if (test2b); return 0; }
19 
20 // PR1921
21 int test3() {
22   const unsigned char *bp;
23   bp -= (short)1;
24 }
25 
26 // PR2080 - sizeof void
27 int t1 = sizeof(void);
28 int t2 = __alignof__(void);
29 void test4() {
30   t1 = sizeof(void);
31   t2 = __alignof__(void);
32 
33   t1 = sizeof(test4());
34   t2 = __alignof__(test4());
35 }
36 
37 // 'const float' promotes to double in varargs.
38 int test5(const float x, float float_number) {
39   return __builtin_isless(x, float_number);
40 }
41 
42 // this one shouldn't fold
43 int ola() {
44   int a=2;
45   if ((0, (int)a) & 2) { return 1; }
46   return 2;
47 }
48 
49 // this one shouldn't fold as well
50 void eMaisUma() {
51 	double t[1];
52 	if (*t)
53 		return;
54 }
55 
56 // rdar://6520707
57 void f0(void (*fp)(void), void (*fp2)(void)) {
58   int x = fp - fp2;
59 }
60 
61 // noop casts as lvalues.
62 struct X {
63   int Y;
64 };
65 struct X foo();
66 int bar() {
67   return ((struct X)foo()).Y + 1;
68 }
69 
70 // PR3809: INC/DEC of function pointers.
71 void f2(void);
72 unsigned f1(void) {
73   void (*fp)(void) = f2;
74 
75   ++fp;
76   fp++;
77   --fp;
78   fp--;
79   return (unsigned) fp;
80 }
81 
82 union f3_x {int x; float y;};
83 int f3() {return ((union f3_x)2).x;}
84 
85 union f4_y {int x; _Complex float y;};
86 _Complex float f4() {return ((union f4_y)(_Complex float)2.0).y;}
87 
88 struct f5_a { int a; } f5_a;
89 union f5_z {int x; struct f5_a y;};
90 struct f5_a f5() {return ((union f5_z)f5_a).y;}
91 
92 // ?: in "lvalue"
93 struct s6 { int f0; };
94 int f6(int a0, struct s6 a1, struct s6 a2) {
95   return (a0 ? a1 : a2).f0;
96 }
97 
98 // PR4026
99 void f7() {
100   __func__;
101 }
102 
103 // PR4067
104 int f8() {
105   return ({ foo(); }).Y;
106 }
107 
108 // rdar://6880558
109 struct S;
110 struct C {
111   int i;
112   struct S *tab[];
113 };
114 struct S { struct C c; };
115 void f9(struct S *x) {
116   foo(((void)1, x->c).tab[0]);
117 }
118 
119