2009-03-24 02:24:46 +00:00
|
|
|
// RUN: clang-cc %s -emit-llvm -o -
|
2008-01-02 21:54:09 +00:00
|
|
|
|
|
|
|
// PR1895
|
|
|
|
// sizeof function
|
|
|
|
int zxcv(void);
|
|
|
|
int x=sizeof(zxcv);
|
|
|
|
int y=__alignof__(zxcv);
|
|
|
|
|
2008-01-03 06:36:51 +00:00
|
|
|
|
|
|
|
void *test(int *i) {
|
|
|
|
short a = 1;
|
|
|
|
i += a;
|
|
|
|
i + a;
|
|
|
|
a + i;
|
|
|
|
}
|
|
|
|
|
2008-01-30 07:01:17 +00:00
|
|
|
_Bool test2b;
|
2009-07-21 20:52:43 +00:00
|
|
|
int test2() { if (test2b); return 0; }
|
2008-01-30 07:01:17 +00:00
|
|
|
|
2008-01-31 04:12:50 +00:00
|
|
|
// PR1921
|
|
|
|
int test3() {
|
|
|
|
const unsigned char *bp;
|
|
|
|
bp -= (short)1;
|
|
|
|
}
|
|
|
|
|
2008-02-21 05:45:29 +00:00
|
|
|
// PR2080 - sizeof void
|
|
|
|
int t1 = sizeof(void);
|
|
|
|
int t2 = __alignof__(void);
|
|
|
|
void test4() {
|
|
|
|
t1 = sizeof(void);
|
|
|
|
t2 = __alignof__(void);
|
|
|
|
|
|
|
|
t1 = sizeof(test4());
|
|
|
|
t2 = __alignof__(test4());
|
|
|
|
}
|
|
|
|
|
2008-06-27 22:48:56 +00:00
|
|
|
// 'const float' promotes to double in varargs.
|
|
|
|
int test5(const float x, float float_number) {
|
|
|
|
return __builtin_isless(x, float_number);
|
|
|
|
}
|
|
|
|
|
2008-11-16 20:09:07 +00:00
|
|
|
// this one shouldn't fold
|
|
|
|
int ola() {
|
|
|
|
int a=2;
|
|
|
|
if ((0, (int)a) & 2) { return 1; }
|
|
|
|
return 2;
|
|
|
|
}
|
2008-11-19 17:44:31 +00:00
|
|
|
|
|
|
|
// this one shouldn't fold as well
|
|
|
|
void eMaisUma() {
|
2009-09-09 15:08:12 +00:00
|
|
|
double t[1];
|
|
|
|
if (*t)
|
|
|
|
return;
|
2008-11-19 17:44:31 +00:00
|
|
|
}
|
2009-02-11 07:21:43 +00:00
|
|
|
|
|
|
|
// rdar://6520707
|
|
|
|
void f0(void (*fp)(void), void (*fp2)(void)) {
|
|
|
|
int x = fp - fp2;
|
|
|
|
}
|
|
|
|
|
2009-03-18 04:02:57 +00:00
|
|
|
// noop casts as lvalues.
|
|
|
|
struct X {
|
|
|
|
int Y;
|
|
|
|
};
|
|
|
|
struct X foo();
|
|
|
|
int bar() {
|
|
|
|
return ((struct X)foo()).Y + 1;
|
|
|
|
}
|
2009-02-11 07:21:43 +00:00
|
|
|
|
2009-03-18 04:25:13 +00:00
|
|
|
// PR3809: INC/DEC of function pointers.
|
|
|
|
void f2(void);
|
|
|
|
unsigned f1(void) {
|
|
|
|
void (*fp)(void) = f2;
|
|
|
|
|
|
|
|
++fp;
|
|
|
|
fp++;
|
|
|
|
--fp;
|
|
|
|
fp--;
|
|
|
|
return (unsigned) fp;
|
|
|
|
}
|
|
|
|
|
2009-03-18 18:28:57 +00:00
|
|
|
union f3_x {int x; float y;};
|
|
|
|
int f3() {return ((union f3_x)2).x;}
|
|
|
|
|
2009-03-18 18:30:44 +00:00
|
|
|
union f4_y {int x; _Complex float y;};
|
|
|
|
_Complex float f4() {return ((union f4_y)(_Complex float)2.0).y;}
|
|
|
|
|
|
|
|
struct f5_a { int a; } f5_a;
|
|
|
|
union f5_z {int x; struct f5_a y;};
|
|
|
|
struct f5_a f5() {return ((union f5_z)f5_a).y;}
|
2009-03-24 02:38:23 +00:00
|
|
|
|
|
|
|
// ?: in "lvalue"
|
|
|
|
struct s6 { int f0; };
|
|
|
|
int f6(int a0, struct s6 a1, struct s6 a2) {
|
|
|
|
return (a0 ? a1 : a2).f0;
|
|
|
|
}
|
2009-04-21 23:00:09 +00:00
|
|
|
|
|
|
|
// PR4026
|
|
|
|
void f7() {
|
|
|
|
__func__;
|
|
|
|
}
|
2009-04-25 19:35:26 +00:00
|
|
|
|
|
|
|
// PR4067
|
|
|
|
int f8() {
|
|
|
|
return ({ foo(); }).Y;
|
|
|
|
}
|
2009-05-12 21:28:12 +00:00
|
|
|
|
|
|
|
// rdar://6880558
|
|
|
|
struct S;
|
|
|
|
struct C {
|
|
|
|
int i;
|
|
|
|
struct S *tab[];
|
|
|
|
};
|
|
|
|
struct S { struct C c; };
|
|
|
|
void f9(struct S *x) {
|
|
|
|
foo(((void)1, x->c).tab[0]);
|
|
|
|
}
|
|
|
|
|