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