1*67e74705SXin Li // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
2*67e74705SXin Li
test1(int cond,float a,float b)3*67e74705SXin Li float test1(int cond, float a, float b) {
4*67e74705SXin Li return cond ? a : b;
5*67e74705SXin Li }
6*67e74705SXin Li
test2(int cond,float a,double b)7*67e74705SXin Li double test2(int cond, float a, double b) {
8*67e74705SXin Li return cond ? a : b;
9*67e74705SXin Li }
10*67e74705SXin Li
11*67e74705SXin Li void f();
12*67e74705SXin Li
test3()13*67e74705SXin Li void test3(){
14*67e74705SXin Li 1 ? f() : (void)0;
15*67e74705SXin Li }
16*67e74705SXin Li
test4()17*67e74705SXin Li void test4() {
18*67e74705SXin Li int i; short j;
19*67e74705SXin Li float* k = 1 ? &i : &j;
20*67e74705SXin Li }
21*67e74705SXin Li
test5()22*67e74705SXin Li void test5() {
23*67e74705SXin Li const int* cip;
24*67e74705SXin Li void* vp;
25*67e74705SXin Li cip = 0 ? vp : cip;
26*67e74705SXin Li }
27*67e74705SXin Li
28*67e74705SXin Li void test6();
29*67e74705SXin Li void test7(int);
test8()30*67e74705SXin Li void* test8() {return 1 ? test6 : test7;}
31*67e74705SXin Li
32*67e74705SXin Li
33*67e74705SXin Li void _efree(void *ptr);
34*67e74705SXin Li
_php_stream_free3()35*67e74705SXin Li void _php_stream_free3() {
36*67e74705SXin Li (1 ? free(0) : _efree(0));
37*67e74705SXin Li }
38*67e74705SXin Li
_php_stream_free4()39*67e74705SXin Li void _php_stream_free4() {
40*67e74705SXin Li 1 ? _efree(0) : free(0);
41*67e74705SXin Li }
42*67e74705SXin Li
43*67e74705SXin Li // PR5526
44*67e74705SXin Li struct test9 { int a; };
45*67e74705SXin Li void* test9spare();
test9(struct test9 * p)46*67e74705SXin Li void test9(struct test9 *p) {
47*67e74705SXin Li p ? p : test9spare();
48*67e74705SXin Li }
49*67e74705SXin Li
50*67e74705SXin Li // CHECK: @test10
51*67e74705SXin Li // CHECK: select i1 {{.*}}, i32 4, i32 5
test10(int c)52*67e74705SXin Li int test10(int c) {
53*67e74705SXin Li return c ? 4 : 5;
54*67e74705SXin Li }
55*67e74705SXin Li enum { Gronk = 5 };
56*67e74705SXin Li
57*67e74705SXin Li // rdar://9289603
58*67e74705SXin Li // CHECK: @test11
59*67e74705SXin Li // CHECK: select i1 {{.*}}, i32 4, i32 5
test11(int c)60*67e74705SXin Li int test11(int c) {
61*67e74705SXin Li return c ? 4 : Gronk;
62*67e74705SXin Li }
63*67e74705SXin Li
64*67e74705SXin Li // CHECK: @test12
65*67e74705SXin Li // CHECK: select i1 {{.*}}, double 4.0{{.*}}, double 2.0
test12(int c)66*67e74705SXin Li double test12(int c) {
67*67e74705SXin Li return c ? 4.0 : 2.0;
68*67e74705SXin Li }
69*67e74705SXin Li // CHECK: @test13
70*67e74705SXin Li // CHECK: call {{.*}} @f2(
71*67e74705SXin Li int f2(void);
test13()72*67e74705SXin Li void test13() {
73*67e74705SXin Li f2() ? (void)0 : (void)0;
74*67e74705SXin Li }
75